Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSP_Rank/calc_CSP_RANK_method.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
89 lines (74 sloc)
3.05 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# calc_CSP_metrics.py | |
# calculate Fmeasure, Precision, Recall for each apo/holo pair with CSP data | |
# determine binding residues using UCBShift predictions for holo form, spectra aligned to holo shifts | |
import sys | |
from os.path import basename | |
from util import * | |
from paths import * | |
from os.path import exists, isfile, isdir, join | |
from os import listdir | |
from tqdm import tqdm | |
CSPmethod = "MONTE" | |
# CSPmethod = "EVENAS2001" | |
# CSPmethod = "GRZESIEK1996" | |
# CSPmethod = "WILLIAMSON2013" | |
CSmethod = "" | |
while CSmethod not in ['SPARTA', 'UCBShift', 'ShiftX', 'consensus']: | |
CSmethod = input("What CS prediciton method to use? [SPARTA, UCBShift, ShiftX, consensus]") | |
data_source_file = './csp_stats_'+CSmethod+'.csv' | |
if CSPmethod != "MONTE": | |
data_source_file = './csp_stats_'+CSPmethod+'_'+CSmethod+'.csv' | |
z_value = 0 | |
def align_shifts_to_seq(aligned_sequence, sequence, shifts): | |
new_shifts = [] | |
seq_index = 0 | |
for i in range(len(aligned_sequence)): | |
if seq_index < len(sequence) and aligned_sequence[i] == sequence[seq_index]: | |
new_shifts.append(shifts[seq_index]) | |
seq_index += 1 | |
else: | |
new_shifts.append(-1) | |
return new_shifts | |
if __name__ == "__main__": | |
data = parse_csv(data_source_file) | |
apos = [str(data['apo_bmrb']) for data in data] | |
bounds = [data['holo_pdb'] for data in data] | |
for i, holo in enumerate(bounds): | |
apo = apos[i] | |
if holo in [ '1klq', '2kri', '2lgf', '2lv6', '2n7k']: | |
continue | |
print(apo) | |
print(holo) | |
def add_data(apo, holo): | |
try: | |
TP, FP, FN, TN = get_confusion(apo, holo, "MONTE", CSmethod, "", "", structure_source = "NMR_medoid") | |
F, MCC, consensus = get_F_MCC_cons(TP, FP, FN, TN) | |
new_values = [F, MCC, consensus] | |
new_columns = ["F_NMR", "MCC_NMR", "consensus_NMR"] | |
update_row(data_source_file, apo, holo, new_values, new_columns) | |
except Exception as e: | |
print(e) | |
if e == "TypeError: cannot unpack non-iterable NoneType object": | |
print("No NMR data") | |
return | |
raise | |
try: | |
TP, FP, FN, TN = get_confusion(apo, holo, "MONTE", CSmethod, "", "", structure_source = "AF2_top_rank") | |
F, MCC, consensus = get_F_MCC_cons(TP, FP, FN, TN) | |
new_values = [F, MCC, consensus] | |
new_columns = ["F_AF2", "MCC_AF2", "consensus_AF2"] | |
update_row(data_source_file, apo, holo, new_values, new_columns) | |
except Exception as e: | |
print(e) | |
if e == "TypeError: cannot unpack non-iterable NoneType object": | |
print("No NMR data") | |
return | |
raise | |
try: | |
add_data(apo, holo) | |
except Exception as e: | |
print(e) | |
if e == "TypeError: cannot unpack non-iterable NoneType object": | |
print("No NMR data") | |
continue | |
raise |