#python sda_pick_positive.py sdaClassFile sdaPredFile outputConfidenceFile import sys import subprocess try: cFile = open(sys.argv[1], 'r') except: print ("file doesn't exist") quit() try: pFile = open(sys.argv[2], 'r') except: print ("file doesn't exist") quit() outFile = open(sys.argv[3], 'w') outFile.close() #subprocess.call(['chmod', '777', sys.argv[3]]) outFile = open(sys.argv[3], 'w') cLines = cFile.readlines() #get all the class predictions c = 0 for line in pFile: line = line.rstrip() items = line.split() if 'e' in items[0]: #too small items[0] = '0.0' if 'e' in items[1]: items[1] = '0.0' items[0] = float(items[0]) items[1] = float(items[1]) if items[0] == items[1]: pos = 0.0 neg = -0.0 outFile.write('0.0 -0.0\n') c += 1 continue if cLines[c] == '1\n': #means the biggest is positive pos = max(items) neg = min(items) * -1 outFile.write(str(pos) + ' ' + str(neg) + '\n') c += 1 continue elif cLines[c] == '0\n': #means the biggest is negative pos = min(items) neg = max(items) * -1 outFile.write(str(pos) + ' ' + str(neg) + '\n') c += 1 continue