comparison strelka_wrapper.py @ 22:1c8dcda28be7

version 27/11/2014, corrected extra arguments bug
author mini
date Thu, 27 Nov 2014 10:31:58 +0100
parents 3c10d88b55ad
children
comparison
equal deleted inserted replaced
21:f785839fb395 22:1c8dcda28be7
18 shutil.rmtree( tmp_dir ) 18 shutil.rmtree( tmp_dir )
19 19
20 def _create_config(args, config_path): 20 def _create_config(args, config_path):
21 conf_file = open(config_path, "w") 21 conf_file = open(config_path, "w")
22 conf_file.write("[user]\n") 22 conf_file.write("[user]\n")
23 for option in args: 23 args2 = vars(args)
24 if not option in ["tumorBam", "normalBam", "refFile", "configFile", "scriptPath"] and args[option]!=None: 24 for option in args2:
25 conf_file.write("%s=%s\n" % (option, args[option])) 25 if not option in ["tumorBam", "normalBam", "refFile", "configFile", "scriptPath", "a", "b", "c", "d", "e", "extraStrelkaArguments"] and args2[option]!=None:
26 conf_file.write("%s=%s\n" % (option, args2[option]))
27 if args.extraStrelkaArguments == "yes":
28 conf_file.write("extraStrelkaArguments=")
29 if args.a:
30 conf_file.write("--ignore-conflicting-read-names ")
31 if args.b != None:
32 conf_file.write("-used-allele-count-min-qscore %s " % (args.b))
33 if args.c != None:
34 conf_file.write("--candidate-indel-input-vcf %s " % (args.c))
35 if args.d != None:
36 conf_file.write("--force-output-vcf %s " % (args.d))
37 if args.e != None:
38 conf_file.write("-min-small-candidate-indel-read-frac %s " % (args.e))
39 conf_file.write("\n")
26 conf_file.close() 40 conf_file.close()
27 41
28 def my_Popen(cmd, prefix_for_stderr_name, tmp_dir, msg_error): 42 def my_Popen(cmd, prefix_for_stderr_name, tmp_dir, msg_error):
29 stderr_name = tempfile.NamedTemporaryFile( prefix = prefix_for_stderr_name ).name 43 stderr_name = tempfile.NamedTemporaryFile( prefix = prefix_for_stderr_name ).name
30 proc = subprocess.Popen( args=cmd, shell=True, stderr=open( stderr_name, 'wb' ) ) 44 proc = subprocess.Popen( args=cmd, shell=True, stderr=open( stderr_name, 'wb' ) )
58 72
59 def __main__(): 73 def __main__():
60 #Manage options 74 #Manage options
61 print(os.environ['PATH']) 75 print(os.environ['PATH'])
62 parser = argparse.ArgumentParser() 76 parser = argparse.ArgumentParser()
63 parser.add_argument( '-t', '--tumorBam', help='path to tumor bam file', required = False ) 77 parser.add_argument( '--tumorBam', help='path to tumor bam file', required = False )
64 parser.add_argument( '-n', '--normalBam', help='', required = False ) 78 parser.add_argument( '--normalBam', help='', required = False )
65 parser.add_argument( '-r', '--refFile', help='', required = False ) 79 parser.add_argument( '--refFile', help='', required = False )
66 parser.add_argument( '-c', '--configFile', help='', required = False ) 80 parser.add_argument( '--configFile', help='', required = False )
67 parser.add_argument( '--depthFilterMultiple', help='', required = False ) 81 parser.add_argument( '--depthFilterMultiple', help='', required = False )
68 parser.add_argument( '--snvMaxFilteredBasecallFrac', help='', required = False ) 82 parser.add_argument( '--snvMaxFilteredBasecallFrac', help='', required = False )
69 parser.add_argument( '--snvMaxSpanningDeletionFrac', help='', required = False ) 83 parser.add_argument( '--snvMaxSpanningDeletionFrac', help='', required = False )
70 parser.add_argument( '--indelMaxRefRepeat', help='', required = False ) 84 parser.add_argument( '--indelMaxRefRepeat', help='', required = False )
71 parser.add_argument( '--indelMaxWindowFilteredBasecallFrac', help='', required = False ) 85 parser.add_argument( '--indelMaxWindowFilteredBasecallFrac', help='', required = False )
83 parser.add_argument( '--binSize', help='path to tumor bam file', required = False ) 97 parser.add_argument( '--binSize', help='path to tumor bam file', required = False )
84 parser.add_argument( '--extraStrelkaArguments', help='', required = False ) 98 parser.add_argument( '--extraStrelkaArguments', help='', required = False )
85 parser.add_argument( '--isSkipDepthFilters', help='', required = False ) 99 parser.add_argument( '--isSkipDepthFilters', help='', required = False )
86 parser.add_argument( '--maxInputDepth', help='', required = False ) 100 parser.add_argument( '--maxInputDepth', help='', required = False )
87 parser.add_argument( '--scriptPath', help='', required = False ) 101 parser.add_argument( '--scriptPath', help='', required = False )
102 parser.add_argument( '-a', action="store_true", help='', required = False )
103 parser.add_argument( '-b', help='', required = False )
104 parser.add_argument( '-c', help='', required = False )
105 parser.add_argument( '-d', help='', required = False )
106 parser.add_argument( '-e', help='', required = False )
88 args = parser.parse_args() 107 args = parser.parse_args()
89 108
90 root_dir= args.scriptPath 109 root_dir= args.scriptPath
91 expected_dir="for_tests" 110 expected_dir="for_tests"
92 job_dir=os.getcwd() 111 job_dir=os.getcwd()
112 fasta_files = [ args.refFile ] 131 fasta_files = [ args.refFile ]
113 index_fasta_files( fasta_files, tmp_dir ) 132 index_fasta_files( fasta_files, tmp_dir )
114 133
115 #creating config file if needed 134 #creating config file if needed
116 if args.configFile == "Custom": 135 if args.configFile == "Custom":
117 _create_config(vars(args), config_ini) 136 _create_config(args, config_ini)
118 elif args.configFile in ["strelka_config_bwa_default.ini", "strelka_config_isaac_default.ini", "strelka_config_eland_default.ini"]: 137 elif args.configFile in ["strelka_config_bwa_default.ini", "strelka_config_isaac_default.ini", "strelka_config_eland_default.ini"]:
119 cmdbash="cp %s %s" % (root_dir + "/lib/" + args.configFile, config_ini) 138 cmdbash="cp %s %s" % (root_dir + "/lib/" + args.configFile, config_ini)
120 my_Popen(cmdbash, "copy_default_file_err", tmp_dir, "Error during the copy of default config file, maybe it was removed") 139 my_Popen(cmdbash, "copy_default_file_err", tmp_dir, "Error during the copy of default config file, maybe it was removed")
121 else: 140 else:
122 if not os.path.exists(args.configFile): 141 if not os.path.exists(args.configFile):