From 9c06b1763f222d7ff8cce4ea869f17efe8bb42cf Mon Sep 17 00:00:00 2001 From: Michael Doron Date: Wed, 27 May 2015 08:27:28 +0300 Subject: [PATCH] removed click, added parameter check --- CODE/feat_extract/pipeline.py | 63 +++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/CODE/feat_extract/pipeline.py b/CODE/feat_extract/pipeline.py index da3a206..5622b9d 100644 --- a/CODE/feat_extract/pipeline.py +++ b/CODE/feat_extract/pipeline.py @@ -27,21 +27,58 @@ profiler = None # -r r'.\Chap\train' -s r'.\Chap\test' -rs r'.\Chap' --testFeatures True --trainFeatures True -# -r r'E:\Dropbox\Dropbox\bioInf_lab\AA_info\CODE\feat_extract\Chap\train' -s r'E:\Dropbox\Dropbox\bioInf_lab\AA_info\CODE\feat_extract\Chap\test' -rs r'E:\Dropbox\Dropbox\bioInf_lab\AA_info\CODE\feat_extract\Chap' --testFeatures True --trainFeatures True - +# -r r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\train' -s r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\test' -rs r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\results' --testFeatures True --trainFeatures True +# -r 'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\train' -s 'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\test' -rs 'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\results' --testFeatures True --trainFeatures True +# -r 'C:\\Users\\Michael\\Desktop\\Feature_Extract\\test_seq\\Chap\\train' -s 'C:\\Users\\Michael\\Desktop\\Feature_Extract\\test_seq\\Chap\\test' -rs 'C:\\Users\\Michael\\Desktop\\Feature_Extract\\test_seq\\Chap\\results' --testFeatures True --trainFeatures True +# -r C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\train -s C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\test -rs C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\results --testFeatures True --trainFeatures True ##ADD OPT for classifier type , and if to use classifier tuning -@click.command() -@click.option('--trainingSetDir','-r','trainingDir',default=r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\train', - help='The path to the training set fasta files', type = str) -@click.option('--testingSetDir','-s','testingDir',default=r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\test', - help='The path to the testing set fasta files', type = str) -@click.option('--resultsDir','-rs','resultsDir',default=r'.\results', - help='The path to directory to write the results files', type = str) -@click.option('--trainFeatures','-rf','GetTrainingFeatures',default=True,help='Whether to extract the training set features', type = bool) -@click.option('--testFeatures','-sf','GetTestFeatures',default=False,help='Whether to get the testing set features', type = bool) -@click.option('--classType','-ct','classType',default='file',help="Defines the classname of each protein, by \'dir\', \'file\', or \'id\'.", type = str) -def pipeline(trainingDir,testingDir,resultsDir, GetTrainingFeatures,GetTestFeatures, classType): +import argparse + +parser = argparse.ArgumentParser() +# @click.option('--trainingSetDir','-r','trainingDir',default=r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\train', +# help='The path to the training set fasta files', type = str) +# @click.option('--testingSetDir','-s','testingDir',default=r'C:\Users\Michael\Desktop\Feature_Extract\test_seq\Chap\test', +# help='The path to the testing set fasta files', type = str) +# @click.option('--resultsDir','-rs','resultsDir',default=r'.\results', +# help='The path to directory to write the results files', type = str) +# @click.option('--trainFeatures','-rf','GetTrainingFeatures',default=True,help='Whether to extract the training set features', type = bool) +# @click.option('--testFeatures','-sf','GetTestFeatures',default=False,help='Whether to get the testing set features', type = bool) +# @click.option('--classType','-ct','classType',default='file',help="Defines the classname of each protein, by \'dir\', \'file\', or \'id\'.", type = str) + +parser.add_argument('--trainingSetDir','-r',dest='trainingDir', type = str,help='The path to the training set fasta files') +parser.add_argument('--testingSetDir','-s',dest='testingDir', type = str,help='The path to the testing set fasta files') +parser.add_argument('--resultsDir','-rs',dest='resultsDir', type = str,help='The path to directory to write the results files') +parser.add_argument('--trainFeatures','-rf',dest='GetTrainingFeatures', type = bool,help='Whether to extract the training set features') +parser.add_argument('--testFeatures','-sf',dest='GetTestFeatures', type = bool,help='Whether to get the testing set features') +parser.add_argument('--classType','-ct',dest='classType', type = str,help='Defines the classname of each protein, by \'dir\', \'file\', or \'id\'."') + +def pipeline(): + results = parser.parse_args() + trainingDir=results.trainingDir + testingDir=results.testingDir + resultsDir=results.resultsDir + GetTrainingFeatures=results.GetTrainingFeatures + GetTestFeatures=results.GetTestFeatures + classType=results.classType + if (not os.path.exists(trainingDir)): + print('training dir doesn\'t exist') + exit() + if (not os.path.exists(testingDir)): + print('testing dir doesn\'t exist') + exit() + if (not os.path.exists(resultsDir)): + print('results dir doesn\'t exist') + exit() + if not (os.access(trainingDir, os.R_OK) and os.access(trainingDir, os.X_OK) and os.access(trainingDir, os.W_OK)): + print('don\' have permission to access training dir') + exit() + if not (os.access(testingDir, os.R_OK) and os.access(testingDir, os.X_OK) and os.access(testingDir, os.W_OK)): + print('don\' have permission to access testing dir') + exit() + if not (os.access(resultsDir, os.R_OK) and os.access(resultsDir, os.X_OK) and os.access(resultsDir, os.W_OK)): + print('don\' have permission to access results dir') + exit() print(profiler) # change here to the training data folder # trainingDir = r'E:\Dropbox\Dropbox\BioInformatics Lab\AA_Information\CODE\Feature_Extract\test_seq\Chap'