Mercurial > repos > jjohnson > shear
comparison shear_wrapper.py @ 6:0158f7356ffd
Add new outputs and params to shear_sv.xml for version 2.3
author | Jim Johnson <jj@umn.edu> |
---|---|
date | Mon, 21 Oct 2013 08:54:58 -0500 |
parents | a82400332451 |
children | 8fac6c7d32fd |
comparison
equal
deleted
inserted
replaced
5:aaaa5a071ff0 | 6:0158f7356ffd |
---|---|
16 parser.add_option( '-B', '--bai', dest='bai', help='BAM index file (.bai)' ) | 16 parser.add_option( '-B', '--bai', dest='bai', help='BAM index file (.bai)' ) |
17 parser.add_option( '-f', '--fasta_reference', dest='fasta', help='The reference sequence fasta file' ) | 17 parser.add_option( '-f', '--fasta_reference', dest='fasta', help='The reference sequence fasta file' ) |
18 parser.add_option( '-F', '--fasta_index', dest='fai', help='The .fai index file for the reference sequence fasta' ) | 18 parser.add_option( '-F', '--fasta_index', dest='fai', help='The .fai index file for the reference sequence fasta' ) |
19 parser.add_option( '-t', '--twobit', dest='twobit', help='The .2bit encoding of the reference sequence fasta generated by faToTwoBit' ) | 19 parser.add_option( '-t', '--twobit', dest='twobit', help='The .2bit encoding of the reference sequence fasta generated by faToTwoBit' ) |
20 parser.add_option( '-i', '--bwa_index', dest='bwa_index', help='The bwa index of the reference sequence' ) | 20 parser.add_option( '-i', '--bwa_index', dest='bwa_index', help='The bwa index of the reference sequence' ) |
21 parser.add_option( '-r', '--report', dest='report', help='The SHEAR output report' ) | 21 parser.add_option( '-R', '--report', dest='report', help='The SHEAR output report' ) |
22 parser.add_option( '-s', '--sdi', dest='sdi', help='The SHEAR sdi input from the SHEAR sv command' ) | 22 parser.add_option( '-s', '--sdi', dest='sdi', help='The SHEAR sdi input from the SHEAR sv command' ) |
23 parser.add_option( '-o', '--output', dest='output', help='The SHEAR output assembly fasta file' ) | 23 parser.add_option( '-o', '--output', dest='output', help='The SHEAR output assembly fasta file' ) |
24 parser.add_option( '-D', '--svidx_dir', dest='svidx_dir', help='The SHEAR output assembly fasta file' ) | 24 parser.add_option( '-D', '--svidx_dir', dest='svidx_dir', help='The SHEAR output assembly fasta file' ) |
25 parser.add_option( '-S', '--sv-only', dest='sv_only', action="store_true", help='SV Only prediction mode.' ) | |
26 parser.add_option( '-r', '--region', dest='region', help='Region of the input alignment to analyze' ) | |
25 (options, args) = parser.parse_args() | 27 (options, args) = parser.parse_args() |
26 | 28 |
27 def make_ref(src, dest, copy=False): | 29 def make_ref(src, dest, copy=False): |
28 if copy: | 30 if copy: |
29 shutil.copy( src, dest ) | 31 shutil.copy( src, dest ) |
48 copy_ref = False | 50 copy_ref = False |
49 prefix = options.prefix if options.prefix and len(options.prefix) > 0 else 'ref' | 51 prefix = options.prefix if options.prefix and len(options.prefix) > 0 else 'ref' |
50 if command in ['sv']: | 52 if command in ['sv']: |
51 args.append( '-p' ) | 53 args.append( '-p' ) |
52 args.append( prefix ) | 54 args.append( prefix ) |
55 if options.sv_only: | |
56 args.append('--sv-only') | |
57 if options.region: | |
58 args.append('-r') | |
59 args.append(options.region) | |
53 if options.svidx_dir and command in ['sv']: | 60 if options.svidx_dir and command in ['sv']: |
54 if not os.path.isdir(options.svidx_dir): | 61 if not os.path.isdir(options.svidx_dir): |
55 os.makedirs(options.svidx_dir) | 62 os.makedirs(options.svidx_dir) |
56 ref_prefix = os.path.join(options.svidx_dir,prefix) | 63 ref_prefix = os.path.join(options.svidx_dir,prefix) |
57 copy_ref = True | 64 copy_ref = True |
218 try: | 225 try: |
219 proc = subprocess.Popen( args=args, shell=False ) | 226 proc = subprocess.Popen( args=args, shell=False ) |
220 returncode = proc.wait() | 227 returncode = proc.wait() |
221 if returncode != 0: | 228 if returncode != 0: |
222 stop_err( 'Error running SHEAR ' + command, returncode ) | 229 stop_err( 'Error running SHEAR ' + command, returncode ) |
223 if command in ['sv']: | |
224 report_path = os.path.join(os.getcwd(),prefix + '.report') | |
225 if os.path.exists(report_path): | |
226 if options.report: | |
227 shutil.copy(report_path,options.report) | |
228 else: | |
229 raise Exception, 'no report file' | |
230 sdi_path = os.path.join(os.getcwd(),prefix + '.sdi') | |
231 if os.path.exists(sdi_path): | |
232 if options.sdi: | |
233 shutil.copy(sdi_path,options.sdi) | |
234 else: | |
235 raise Exception, 'no sdi file' | |
236 except Exception, e: | 230 except Exception, e: |
237 # clean up temp dirs | 231 # clean up temp dirs |
238 stop_err( 'Error running SHEAR %s %s' % (command,str(e)),9 ) | 232 stop_err( 'Error running SHEAR %s %s' % (command,str(e)),9 ) |
239 | 233 |
240 if __name__=="__main__": __main__() | 234 if __name__=="__main__": __main__() |