filename = 'allscores.txt' # filename with our scores
# 13 proteins of our subfamily
proteins_of_subfamily = ['A0A1J7GNR1', 'A0A2G2W5D7', 'A0A498KQB0', 'A0A4D6LNE0', 'A0A564Y1F9', 'A0A5N6L5B8', 'A0A811R5I4', 'A0A8J5BUC7', 'A0AAD3Y780', 'A0AAN8SM74', 'A0ABD3E0I4', 'A0ACC0L1T6', 'M8AUX6']
# parsing file
with open(filename, 'r') as scorefile:
    lines = scorefile.readlines()
# list of our subfamily protein scores
scoresofsubfamily = []

for line in lines: # reading every ling
    for protein in proteins_of_subfamily:
        if protein in line.split('|')[0]: # finding our proteins
            score = float(line.split(' ')[1].strip())
            scoresofsubfamily.append(score) # appending scores
            break

for ourscore in sorted(scoresofsubfamily): # walk through array of our scores
    # metrics
    FP = 0
    TP = 0
    FN = 0
    TN = 0
    for line in lines:
        proteinname = line.split('|')[0] # name of every protein
        score = float(line.split(' ')[1].strip()) # score of every protein
        # counting metrics
        if ourscore <= score and proteinname in proteins_of_subfamily:
            TP += 1
        elif ourscore <= score and proteinname not in proteins_of_subfamily:
            FP += 1
        elif ourscore > score and proteinname in proteins_of_subfamily:
            FN += 1
        elif ourscore > score and proteinname not in proteins_of_subfamily:
            TN += 1
    # returning metrics
    print(f'score = {ourscore}, TP = {TP}, FP = {FP}, FN = {FN}, TN = {TN}')
