Description
    :param score_structure: list [(id, best_score, best_query, status, net decoy count, net active count), ..., ]
    :param fpf: float. False positive fraction at which the enrichment factor will be calculated.
    :param sort_order: string. 'asc' (binding free energy estimate) 'dsc' (probability)
    :return: ef_structure: list [(id, best_score, best_query, status, gamma), ..., ]
    gamma is 1 if the score of the molecule is better than the false positive threshold and 0 otherwise

def make_ef_structure(score_structure, fpf, sort_order):
    """
    Description
    :param score_structure: list [(id, best_score, best_query, status, net decoy count, net active count), ..., ]
    :param fpf: float. False positive fraction at which the enrichment factor will be calculated.
    :param sort_order: string. 'asc' (binding free energy estimate) 'dsc' (probability)
    :return: ef_structure: list [(id, best_score, best_query, status, gamma), ..., ]
    gamma is 1 if the score of the molecule is better than the false positive threshold and 0 otherwise
    """

    # set variables
    n = len([x[4] for x in score_structure if x[3] == '0']) # Total no. of decoys

    # if it wasn't defined, set the false positive fraction to the appropriate default value
    if not fpf:
        fpf = float(1) / n

    # if there are an insufficient number of decoys return None
    if n < int(round(1 / fpf)):
        return None

    # determine score threshold
    decoy_threshold = int(round(n * fpf))                                               # number of decoys corresponding
                                                                                        # to fpf
    active_list_at_threshold = [x for x in score_structure if x[4] == decoy_threshold]  # actives at ef fpf
    active_list_at_threshold.sort(key=lambda x: x[5], reverse=True)                     # sorted by active count
    score_threshold = float(active_list_at_threshold[0][1])                             # score at max active count
    ef_structure = []
    for mol in score_structure:
        score = float(mol[1])
        if sort_order == 'asc':
            if score <= score_threshold:
                gamma = 1
            elif score > score_threshold:
                gamma = 0
        elif sort_order == 'dsc':
            if score >= score_threshold:
                gamma = 1
            elif score < score_threshold:
                gamma = 0
        tup = mol[0:4] + (gamma,)
        ef_structure.append(tup)

    return ef_structure