diff picard_wrapper.py @ 143:b2ca2d181fb4 draft

fixed downsample sam in picard1106 (accept bam)
author Rayan Chikhi <chikhi@psu.edu>
date Mon, 16 Jun 2014 17:38:15 -0400
parents 1790970e47fe
children 767bcb0a06df
line wrap: on
line diff
--- a/picard_wrapper.py	Thu Feb 27 13:15:52 2014 -0500
+++ b/picard_wrapper.py	Mon Jun 16 17:38:15 2014 -0400
@@ -800,18 +800,21 @@
         cl.append('OUTPUT=%s' % tempout)
         pic.runPic(opts.jar, cl)
         haveTempout = True
+
     elif pic.picname == "DownsampleSam":
         cl.append('I=%s' % opts.input)
-        mystring = opts.output
-        mystringsam = mystring + ".sam"
-        cl.append('O=%s' % mystringsam)
+        output_string = opts.output
+        if opts.datatype == 'sam':
+            output_string = output_string + ".sam"
+        cl.append('O=%s' % output_string)
         if float(opts.probability) > 0:
             cl.append('PROBABILITY=%s' % opts.probability)
         if float(opts.seed) > 0:
             cl.append('RANDOM_SEED=%s' % opts.seed)
         stdouts,rval = pic.runPic(opts.jar, cl)
-        myoutput = mystringsam.replace(".sam", "")
-        os.rename(mystringsam,myoutput)
+        if opts.input.endswith(".sam"):
+            renamed_output = output_string.replace(".sam", "")
+            os.rename(output_string,renamed_output)
 
     elif pic.picname == 'MeanQualityByCycle':
         isPDF = 'MeanQualityByCycle.pdf'