#this version used in the final server just matches predictions to the residue pairs #and formats the output. the header and "END" record is added by model_eva.pl import sys import math predFileName = sys.argv[1] featureFileName = sys.argv[2] outFileName = sys.argv[3] #L = int(sys.argv[4]) #sequence len #L5 = L/5 #top L/5 contacts (not used now) predFile = open(predFileName, 'r') featFile = open(featureFileName, 'r') outFile = open(outFileName, 'w') preds = [] predsWithRes = [] #[predValue, res1, res2] thresh = 1/(1 + math.pow((8.0/3), 2)) #values LESS than this will be counted NOT in contact for line in predFile: items = line.split() if float(items[0]) < thresh: preds.append("skip") continue """ if 'e' in line: line = '0.0\n' """ preds.append(float(line.rstrip())) countPreds = 0 for line in featFile: if preds[countPreds] == "skip": predsWithRes.append("skip") countPreds += 1 continue items = line[line.find('#'):].split(' ') targetID = items[1] res1 = int(items[3]) #the first residue (i) res2 = int(items[5]) #the second residue (j) predsWithRes.append([preds[countPreds], res1, res2, targetID]) countPreds += 1 predsWithRes.sort(reverse=True, key=lambda x: x[0]) #sort by predValue for i in range(0, len(preds)): if predsWithRes[i] == "skip": continue else: outFile.write(str(predsWithRes[i][1]) + ' ' + str(predsWithRes[i][2]) + ' ' + '0' + ' ' + '8' + ' ' + str(predsWithRes[i][0]) + ' ' + str(predsWithRes[i][3]) + '\n') #res1, res2, predValue, targetID outFile.close() predFile.close() featFile.close()