import rrEval import os acc = [] #[sep6, sep12, sep24] values for each sequence separation see rrEval.py for more details cov = [] #[sep6, sep12, sep24] values for each sequence separation see rrEval.py for more details trueDir = os.getcwd() + "/true" #change to where the .RR files are located (empty dir except .RR files) predDir = os.getcwd()+ "/svmIndividual" #change to the predictions. empty dir except for prediction files. Must start with 5 character name matching the .RR file name beginning seqDir = os.getcwd() + "/seq" L = ((1)) #multiplies the sequence length which determines the num of preds evaluated. out = open('svm_plusReg_L.txt', 'w') trueFiles = [] scores = [] #list of lists of [acc6, acc12, acc24, cov6, cov12, cov24] seqsAndSizes = []# [targetID, target length in residues] for file in os.listdir(trueDir): if file.endswith('.RR'): trueFiles.append(trueDir + "/" + file) for file in os.listdir(seqDir): #directory target .fasta files (no headers. only sequence. one line) if file.endswith('.fasta'): check = open(seqDir + "/" + file, 'r') n = '' for line in check: if line[0] == '>': n = line[1:6] continue seqsAndSizes.append([n, len(line)]) #targetID, L for file in os.listdir(predDir): name = file[:5] #the target name try: tf = [x for x in trueFiles if name in x] tf = tf[0] proLen = [x[1] for x in seqsAndSizes if name in x][0] scores.append(rrEval.main([tf, (predDir + "/" + file), name, int(L * proLen)])) scores[-1].append(name) except: print name + " didn't work\n" continue #calc the averages of the scores array numOfTargets = len(scores) sums = [0, 0, 0, 0, 0, 0] for x in scores: out.write( "-----------------------------------------------\n") out.write(str(x[6]) + "\n") out.write("acc6: " + str(x[0]) + "\n") #acc6 out.write("acc12: " + str(x[1]) + "\n") #acc12 out.write("acc24: " + str(x[2]) + "\n" + "\n") #acc24 out.write("cov6: " + str(x[3]) + "\n") #cov6 out.write("cov12: " + str(x[4]) + "\n") #cov12 out.write("cov24: " + str(x[5]) + "\n") #cov24 out.write("-----------------------------------------------\n") sums[0] = sums[0] + x[0] sums[1] = sums[1] + x[1] sums[2] = sums[2] + x[2] sums[3] = sums[3] + x[3] sums[4] = sums[4] + x[4] sums[5] = sums[5] + x[5] sums[0] = sums[0]/numOfTargets sums[1] = sums[1]/numOfTargets sums[2] = sums[2]/numOfTargets sums[3] = sums[3]/numOfTargets sums[4] = sums[4]/numOfTargets sums[5] = sums[5]/numOfTargets out.write( "evaluation complete on: " + str(numOfTargets) + " prediction files\n") out.write ("averages: [acc6, acc12, acc24, cov6, cov12, cov24]"+"\n") out.write(str(sums))