@@ -46,7 +46,7 @@ def main():
4646 parser .add_argument ("-n" , "--cpus" , dest = 'cpus' , type = int , default = cpu_count ())
4747 parser .add_argument ("-d" , "--mdup" , dest = 'mdup' , action = 'store_true' )
4848 parser .add_argument ("-l" , "--lossy" , dest = 'lossy' , action = 'store_true' )
49- parser .add_argument ("-o" , "--output-format" , dest = 'output_format' , choices = [ 'bam' , ' cram'], default = ['cram' ], nargs = '+' )
49+ parser .add_argument ("-o" , "--output-format" , dest = 'output_format' , default = ' cram', choices = ['bam' , 'cram' ] )
5050
5151 args = parser .parse_args ()
5252
@@ -66,21 +66,14 @@ def main():
6666 else :
6767 cram = 'samtools view -C -T %s -@ %s --write-index /dev/stdin -o %s ' % (args .reference , args .cpus , args .output_base + ".cram" )
6868
69- tee = 'tee %s ' % (args .output_base + ".bam" )
70- bai = 'samtools index -@ %s /dev/stdin %s' % (args .cpus , args .output_base + ".bam.bai" )
71- bai1 = 'samtools index -@ %s %s %s ' % (args .cpus , args .output_base + ".bam" , args .output_base + ".bam.bai" )
69+ bam = 'samtools view -b -h -@ %s --write-index /dev/stdin -o %s##idx##%s ' % (args .cpus , args .output_base + ".bam" , args .output_base + ".bam.bai" )
7270 crai1 = 'samtools index -@ %s %s %s ' % (args .cpus , args .output_base + ".cram" , args .output_base + ".cram.crai" )
7371
7472 # build command
75- if "bam" in args .output_format and "cram" in args .output_format :
76- cmd .append ('|' .join ([merge , tee , cram ]))
77- cmd .append (bai1 )
78- if args .lossy : cmd .append (crai1 )
79-
80- elif "bam" in args .output_format and not "cram" in args .output_format :
81- cmd .append ('|' .join ([merge , tee , bai ]))
73+ if args .output_format == 'bam' :
74+ cmd .append ('|' .join ([merge , bam ]))
8275
83- elif not "bam" in args .output_format and " cram" in args . output_format :
76+ elif args .output_format == ' cram' :
8477 cmd .append ('|' .join ([merge , cram ]))
8578 if args .lossy : cmd .append (crai1 )
8679 else :
0 commit comments