annotate strelka_wrapper.py @ 8:2cee4ed50058

nothing relevant
author mini
date Fri, 26 Sep 2014 14:33:07 +0200
parents 3e8541ece3c7
children 0e8e6011082b f66f23fcc83a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
1 #!/usr/bin/env python
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
2 #Dan Blankenberg
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
3
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
4 """
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
5 A wrapper script for running the GenomeAnalysisTK.jar commands.
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
6 """
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
7
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
8 from __future__ import print_function
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
9 import sys, argparse, os, tempfile, subprocess, shutil
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
10 from binascii import unhexlify
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
11 from string import Template
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
12 from galaxy import eggs
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
13 #import pkg_resources; pkg_resources.require( "bx-python" )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
14
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
15 #GALAXY_EXT_TO_GATK_EXT = { 'gatk_interval':'intervals', 'bam_index':'bam.bai', 'gatk_dbsnp':'dbSNP', 'picard_interval_list':'interval_list' } #items not listed here will use the galaxy extension as-is
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
16 #GALAXY_EXT_TO_GATK_FILE_TYPE = GALAXY_EXT_TO_GATK_EXT #for now, these are the same, but could be different if needed
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
17 #DEFAULT_GATK_PREFIX = "gatk_file"
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
18 #CHUNK_SIZE = 2**20 #1mb
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
19 #
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
20 #
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
21 def cleanup_before_exit( tmp_dir ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
22 if tmp_dir and os.path.exists( tmp_dir ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
23 shutil.rmtree( tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
24
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
25 def _create_config(args, config_path):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
26 conf_file = open(config_path, "w")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
27 conf_file.write("[user]\n")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
28 for option in args:
7
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
29 if not option in ["tumorBam", "normalBam", "refFile", "configFile", "scriptPath"] and args[option]!=None:
6
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
30 conf_file.write("%s=%s\n" % (option, args[option]))
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
31 conf_file.close()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
32
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
33 def my_Popen(cmd, prefix_for_stderr_name, tmp_dir, msg_error):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
34 stderr_name = tempfile.NamedTemporaryFile( prefix = prefix_for_stderr_name ).name
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
35 proc = subprocess.Popen( args=cmd, shell=True, stderr=open( stderr_name, 'wb' ) )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
36 return_code = proc.wait()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
37 if return_code:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
38 for line in open( stderr_name ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
39 print(line, file=sys.stderr)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
40 os.unlink( stderr_name ) #clean up
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
41 cleanup_before_exit( tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
42 raise Exception( msg_error )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
43 else:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
44 os.unlink( stderr_name )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
45
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
46 def index_bam_files( bam_filenames, tmp_dir ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
47 for bam_filename in bam_filenames:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
48 bam_index_filename = "%s.bai" % bam_filename
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
49 print("bam_filename is: " + bam_filename + " bam_index_filename is: " + bam_index_filename + " test is: %s" % os.path.exists(bam_index_filename))
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
50 if not os.path.exists( bam_index_filename ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
51 #need to index this bam file
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
52 command = 'samtools index %s %s' % ( bam_filename, bam_index_filename )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
53 my_Popen( command, "bam_index_stderr", tmp_dir, "Error during indexation of fasta file :" + bam_filename)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
54
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
55 def index_fasta_files( fasta_filenames, tmp_dir ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
56 for fasta_filename in fasta_filenames:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
57 fasta_index_filename = "%s.fai" % fasta_filename
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
58 print("fasta_filename is: " + fasta_filename + " fasta_index_filename is: " + fasta_index_filename + " test is: %s" % os.path.exists(fasta_index_filename))
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
59 if not os.path.exists( fasta_index_filename ):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
60 #need to index this bam file
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
61 command = 'samtools faidx %s %s' % ( fasta_filename, fasta_index_filename )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
62 my_Popen( command, "fasta_index_stderr", tmp_dir, "Error during indexation of fasta file :" + fasta_filename)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
63
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
64 def __main__():
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
65 #Parse Command Line OPTPARSE DEPRECIATED USE ARGPARSE INSTEAD
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
66 #MKTEMP DEPRECIATED USE MKDTlizations#EMP INSTEAD
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
67 #manage parsing
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
68 parser = argparse.ArgumentParser()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
69 parser.add_argument( '-t', '--tumorBam', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
70 parser.add_argument( '-n', '--normalBam', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
71 parser.add_argument( '-r', '--refFile', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
72 parser.add_argument( '-c', '--configFile', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
73 parser.add_argument( '--depthFilterMultiple', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
74 parser.add_argument( '--snvMaxFilteredBasecallFrac', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
75 parser.add_argument( '--snvMaxSpanningDeletionFrac', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
76 parser.add_argument( '--indelMaxRefRepeat', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
77 parser.add_argument( '--indelMaxWindowFilteredBasecallFrac', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
78 parser.add_argument( '--indelMaxIntHpolLength', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
79 parser.add_argument( '--ssnvPrior', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
80 parser.add_argument( '--sindelPrior', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
81 parser.add_argument( '--ssnvNoise', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
82 parser.add_argument( '--sindelNoise', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
83 parser.add_argument( '--ssnvNoiseStrandBiasFrac', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
84 parser.add_argument( '--minTier1Mapq', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
85 parser.add_argument( '--minTier2Mapq', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
86 parser.add_argument( '--ssnvQuality_LowerBound', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
87 parser.add_argument( '--sindelQuality_LowerBound', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
88 parser.add_argument( '--isWriteRealignedBam', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
89 parser.add_argument( '--binSize', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
90 parser.add_argument( '--extraStrelkaArguments', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
91 parser.add_argument( '--isSkipDepthFilters', help='path to tumor bam file', required = False )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
92 parser.add_argument( '--maxInputDepth', help='path to tumor bam file', required = False )
7
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
93 parser.add_argument( '--scriptPath', help='path to tumor bam file', required = False )
6
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
94 args = parser.parse_args()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
95
8
2cee4ed50058 nothing relevant
mini
parents: 7
diff changeset
96 root_dir= args.scriptPath
7
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
97 expected_dir="for_tests"
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
98 job_dir=os.getcwd()
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
99 analysis_dir=job_dir + "/StrelkaAnalysis"
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
100 config_script=root_dir + "/configureStrelkaWorkflow.pl"
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
101 tmp_dir = "tmp" #tempfile.mkdtemp( prefix='tmp-strelkaAnalysis-' )
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
102 config_ini = "%s/config.ini" % (tmp_dir)
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
103
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
104 print("root_dir: " + root_dir + "\njob_dir :" + job_dir + "\nanalysis_dir :" + analysis_dir + "\nconfig_script :" + config_script + "\ntmp_dir :" + tmp_dir + "\nconfig_ini :" + config_ini)
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
105
3e8541ece3c7 trying to fix environment variable 0.0.1
mini
parents: 6
diff changeset
106
6
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
107 #verifying eveything's ok
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
108 if not os.path.isfile(config_script):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
109 sys.exit("ERROR: The strelka workflow must be built prior to running. See installation instructions in '$root_dir/README'")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
110 print("configuring...", file=sys.stdout)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
111 if os.path.exists(analysis_dir):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
112 sys.exit("'" + analysis_dir + "' already exist, if you are executing this tool from galaxy it should not happen")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
113
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
114
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
115 # creating index if needed
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
116 os.environ['PATH']= root_dir + "/opt/samtools:" + os.environ['PATH']
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
117 bam_filenames = [ args.tumorBam, args.normalBam ]
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
118 index_bam_files( bam_filenames, tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
119 fasta_files = [ args.refFile ]
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
120 index_fasta_files( fasta_files, tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
121
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
122 #creating config file if needed
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
123 if args.configFile == "Custom":
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
124 _create_config(vars(args), config_ini)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
125 elif args.configFile == "Default":
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
126 cmdbash="cp %s %s" % (root_dir + "/strelka_config.sample", config_ini)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
127 my_Popen(cmdbash, "copy_default_file_err", tmp_dir, "Error during the copy of default config file, maybe it was removed")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
128 else:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
129 if not os.path.exists(args.configFile):
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
130 print( "The path to your configuration File seems to be wrong, use another one or custom option", file=sys.stderr)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
131 cmdbash="cp %s %s" % (args.configFile, config_ini)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
132 my_Popen(cmdbash, "copy_default_file_err", tmp_dir, "Error during the copy of default config file, maybe it was removed")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
133
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
134
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
135
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
136
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
137 #configuration of workflow
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
138 cmd="%s --tumor=%s --normal=%s --ref=%s --config=%s --output-dir=%s" % (config_script, args.tumorBam, args.normalBam, args.refFile, config_ini, analysis_dir)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
139 print( "**** Starting configuration.")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
140 print( "**** Configuration cmd: '" + cmd + "'")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
141 my_Popen( cmd, "cinfugation_stderr", tmp_dir, "Error during configuration !")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
142 print("completed configuration")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
143
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
144 #run the workflow !
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
145 cmd="make -C " + analysis_dir
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
146 print("**** starting workflow.")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
147 print("**** workflow cmd: '" + cmd + "'")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
148 my_Popen( cmd, "workflow_stderr", tmp_dir, "Error during workflow execution !")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
149 print("**** completed workflow execution")
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
150
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
151
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
152
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
153
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
154
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
155
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
156
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
157
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
158
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
159
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
160
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
161
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
162
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
163
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
164 #bam_filenames = []
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
165 # if options.datasets:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
166 # for ( dataset_arg, filename, galaxy_ext, prefix ) in options.datasets:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
167 # gatk_filename = filename_from_galaxy( filename, galaxy_ext, target_dir = tmp_dir, prefix = prefix )#return the link to the dataset that has been created in the function
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
168 # if dataset_arg:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
169 # cmd = '%s %s "%s"' % ( cmd, gatk_filetype_argument_substitution( dataset_arg, galaxy_ext ), gatk_filename )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
170 # if galaxy_ext == "bam":
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
171 # bam_filenames.append( gatk_filename )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
172 # #set up stdout and stderr output options
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
173 # stdout = open_file_from_option( options.stdout, mode = 'wb' )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
174 # stderr = open_file_from_option( options.stderr, mode = 'wb' )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
175 # #if no stderr file is specified, we'll use our own
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
176 # if stderr is None:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
177 # stderr = tempfile.NamedTemporaryFile( prefix="strelka-stderr-", dir=tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
178 #
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
179 # proc = subprocess.Popen( args=cmd, stdout=stdout, stderr=stderr, shell=True, cwd=tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
180 # return_code = proc.wait()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
181 #
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
182 # if return_code:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
183 # stderr_target = sys.stderr
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
184 # else:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
185 # stderr_target = sys.stdout
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
186 # stderr.flush()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
187 # stderr.seek(0)
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
188 # while True:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
189 # chunk = stderr.read( CHUNK_SIZE )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
190 # if chunk:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
191 # stderr_target.write( chunk )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
192 # else:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
193 # break
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
194 # stderr.close()
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
195 # #generate html reports
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
196 # if options.html_report_from_directory:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
197 # for ( html_filename, html_dir ) in options.html_report_from_directory:
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
198 # html_report_from_directory( open( html_filename, 'wb' ), html_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
199 #
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
200 # cleanup_before_exit( tmp_dir )
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
201
87568e5a7d4f Testing strelka version 0.0.1
mini
parents:
diff changeset
202 if __name__=="__main__": __main__()