def PieceWiseOptimalityFunction(Min, Optimal, Max, X_in):
    """
    A piecewise function of X_in, with parameters of Min, Max, and Optimal, that will return a number between 0 and 1.
    A linear increase from 0 to 1 across the X_in range of (Min, Optimal].
    A linear decrease from 1 to 0 across the X_in range of (Optimal, Max].
    Y=0 All else.

    Used to make a GCContent score, for example, where the optimal GCContent would be 50, with a Min of 25, and a Max of 75self.

    Example:

    >>> PieceWiseOptimalityFunction(25,50,75,25)
    0

    >>> PieceWiseOptimalityFunction(25,50,75,50)
    1.0

    >>> PieceWiseOptimalityFunction(25,50,75,55)
    0.8

    """
    if Min < X_in <= Optimal:
        Y = 1/(Optimal-Min) * (X_in - Min)
    elif Optimal < X_in <= Max:
        Y = 1/(Optimal-Max) * (X_in - Max)
    else:
        Y=0
    return(Y)