Mercurial > repos > devteam > picard1106
changeset 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 | 844fa42ad305 |
children | db8e6c53acf5 767bcb0a06df |
files | picard_DownsampleSam.xml picard_wrapper.py |
diffstat | 2 files changed, 23 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/picard_DownsampleSam.xml Thu Feb 27 13:15:52 2014 -0500 +++ b/picard_DownsampleSam.xml Mon Jun 16 17:38:15 2014 -0400 @@ -1,30 +1,37 @@ -<tool name="Downsample SAM" id="picard_DownsampleSam" version="1.106.0"> +<tool name="Downsample SAM/BAM" id="picard_DownsampleSam" version="1.106.0"> <!-- found on https://bitbucket.org/bwlang/galaxy-dist/src/ca5ded2e18a9ef802c31429e3cb861e8775b24d0/tools/picard/picard_DownsampleSam.xml --> <description>Down-sample a file to retain a subset of the reads</description> <requirements><requirement type="package" version="1.106.0">picard</requirement></requirements> <command interpreter="python"> picard_wrapper.py - --input=$inputFile - --output=$outFile + --input "$inputFile" + --output "$outFile" --probability=$probability + --output-format $outputFormat --seed=$seed -j "\$JAVA_JAR_PATH/DownsampleSam.jar" </command> <inputs> - <param format="sam" name="inputFile" type="data" label="SAM dataset to be downsampled" - help="If empty, upload or import a SAM dataset." /> + <param format="sam,bam" name="inputFile" type="data" label="SAM/BAM dataset to be downsampled" + help="If empty, upload or import a SAM or BAM dataset." /> <param name="probability" type="float" size="5" label="Probability (between 0 and 1) that any given read will be kept" help="specify 1 to keep all reads, 0.1 to keep 10% of the reads" value="1" /> <param name="seed" type="integer" size="5" label="Random seed value" help="(same seed + same probability = same set of reads kept)" value="1" /> + <param name="outputFormat" type="boolean" checked="True" truevalue="bam" falsevalue="sam" label="Output BAM instead of SAM" help="Uncheck for SAM output" /> </inputs> <outputs> - <data name="outFile" format="sam" label="${tool.name} on ${on_string}"> + <data name="outFile" format="bam" label="${tool.name} on ${on_string}: downsampled ${outputFormat}"> + <change_format> + <when input="outputFormat" value="sam" format="sam" /> + </change_format> </data> </outputs> + <tests> <test> - <param name="inputFile" value="cleansamtestinput.sam" /> + <param name="inputFile" value="cleansamtestinput.sam" ftype="sam" /> <param name="probability" value="0.1" /> <param name="seed" value="2" /> + <param name="outputFormat" value="False" /> <output name="outFile" file="downsamplesamoutput.sam" ftype="sam" /> </test> </tests> @@ -54,4 +61,4 @@ </help> -</tool> \ No newline at end of file +</tool>
--- 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'