#performs sda predictions for multiple targets using only one .mod model file import os import sys import subprocess targetDir = sys.argv[1] #holds the .onlyx files that will be the prediction targetDir modDir = sys.argv[2] #contains the .mod (model) and conf.txt (confidence file) outputDir = sys.argv[3] #will hold the output .class and .pred files (prediction class and prediction value) suffix = '_sep24' #change this for changing the name of the output files if not targetDir.endswith('/'): targetDir = targetDir + '/' if not modDir.endswith('/'): modDir = modDir + '/' if not outputDir.endswith('/'): outputDir = outputDir + '/' sda = 'SdA_predict_release_p4' #the full path to the sda script(including the script itself) #find conf and mod files mod = None conf = None for file in os.listdir(modDir): if file.endswith('.mod'): mod = modDir + file if file == 'conf.txt': conf = modDir + file #run SdA on every target in the targetDir (must be .onlyx extension) #filename of onlyx files must start with the targetname (targetname_etc.onlyx). this will be the name of the output too for file in os.listdir(targetDir): if not file.endswith('.onlyx'): continue name = file[:file.find('_')] #the target name outClass = outputDir + name + suffix + '.class' outPred = outputDir + name + suffix + '.pred' file = targetDir + file cmd = ['./' + sda, 'cpu', file, conf, mod, outClass, outPred] subprocess.call(cmd)