Repository 'samtools_view'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/samtools_view

Changeset 8:bf328cec6a42 (2020-09-02)
Previous changeset 7:b01db2684fa5 (2020-01-21) Next changeset 9:b72793637686 (2021-01-04)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/samtools/samtools_view commit e73e642259254253f71335ed1cbd738bb06d3346"
modified:
samtools_view.xml
added:
test-data/no_reads.bam
test-data/no_reads.sam
b
diff -r b01db2684fa5 -r bf328cec6a42 samtools_view.xml
--- a/samtools_view.xml Tue Jan 21 07:40:18 2020 -0500
+++ b/samtools_view.xml Wed Sep 02 15:29:22 2020 -0400
b
b'@@ -1,4 +1,4 @@\n-<tool id="samtools_view" name="Samtools view" version="@TOOL_VERSION@+galaxy1">\n+<tool id="samtools_view" name="Samtools view" version="@TOOL_VERSION@+galaxy2">\n     <description>- reformat, filter, or subsample SAM, BAM or CRAM</description>\n     <macros>\n         <import>macros.xml</import>\n@@ -20,21 +20,19 @@\n         </xml>\n         <xml name="output_format_selector">\n             <conditional name="output_format">\n-                <param name="oformat" type="select" label="Output format">\n+                <param name="oformat" type="select" label="Output format"\n+                help="Note on BAM output format: The tool will generate coordinate-sorted BAM, i.e., may change the order of reads compared to the input. For BAM input, select \'Same as input\' to produce BAM output with the read order retained.">\n+                    <option value="input">Same as input</option>\n                     <option value="sam">SAM</option>\n                     <option value="bam" selected="True">BAM (-b)</option>\n                     <option value="cram">CRAM (-C)</option>\n                 </param>\n+                <when value="input" />\n                 <when value="sam">\n                     <yield />\n-                    <param name="fmtopt" type="hidden" value="" />\n                 </when>\n-                <when value="bam">\n-                    <param name="fmtopt" type="hidden" value="-b" />\n-                </when>\n-                <when value="cram">\n-                    <param name="fmtopt" type="hidden" value="-C" />\n-                </when>\n+                <when value="bam" />\n+                <when value="cram" />\n             </conditional>\n         </xml>\n     </macros>\n@@ -49,10 +47,35 @@\n         @PREPARE_FASTA_IDX@\n         @PREPARE_IDX@\n \n+        ## determine the output format flag to pass to samtools view\n+        ## -c for count mode\n+        ## -b to produce BAM-formatted output\n+        ## -C to produce CRAM-formatted output\n+        ## SAM is the default ouput format\n+        #set $fmtopt = \'\'\n+        #if str($mode.output_options.reads_report_type) == \'count\':\n+            #set $fmtopt = \'-c\'\n+        #else:\n+            #if str($mode.output_options.output_format.oformat) == \'bam\':\n+                #set $fmtopt = \'-b\'\n+            #elif str($mode.output_options.output_format.oformat) == \'cram\':\n+                #set $fmtopt = \'-C\'\n+            #elif str($mode.output_options.output_format.oformat) == \'input\':\n+                #if $input.is_of_type(\'bam\'):\n+                    #set $fmtopt = \'-b\'\n+                #elif $input.is_of_type(\'cram\'):\n+                    #set $fmtopt = \'-C\'\n+                #else:\n+                    ## input in SAM format, make sure to keep header if present\n+                    #set $fmtopt = \'-h\'\n+                #end if\n+            #end if\n+        #end if\n+\n         #if str($mode.outtype) == \'header\':\n             ## call samtools view and be done\n             samtools view\n-            -H ${mode.output_options.output_format.fmtopt} -o outfile\n+            -H $fmtopt -o outfile\n             @REF_DATA@\n             infile\n         #else:\n@@ -130,11 +153,11 @@\n                         ## not dealing with all of the reads in the indexed\n                         ## file. We have to do an extra pass over the input to\n                         ## count the reads to subsample.\n-                        sample_fragment=`samtools view -c $std_filters infile $reg_filters | awk \'{s=\\$1} END {frac=${mode.subsample_config.subsampling_mode.target}/s; print(frac < 1 ? $seed+frac : ".0")}\'` &&\n+                        sample_fragment=`samtools view -c $std_filters infile $reg_filters | awk \'{s=\\$1} END {frac=s/${mode.subsample_config.subsampling_mode.target}; print(frac > 1 ? $seed+1/frac : ".0")}\'` &&\n                     #else:\n                         ## We can get the count of reads to subsample using\n                         ## an inexpensive call to idxstats.\n-             '..b'ile="test.sam" ftype="sam" />\n         </test>\n         <test>\n+            <!-- subsampling SAM input without reads -->\n+            <param name="input" value="no_reads.sam" ftype="sam" />\n+            <conditional name="mode">\n+                <param name="outtype" value="selected_reads" />\n+                <section name="subsample_config">\n+                    <conditional name="subsampling_mode">\n+                        <param name="select_subsample" value="target" />\n+                        <param name="target" value="20" />\n+                    </conditional>\n+                </section>\n+                <conditional name="output_options">\n+                    <conditional name="output_format">\n+                        <param name="oformat" value="input" />\n+                    </conditional>\n+                </conditional>\n+            </conditional>\n+            <output name="outputsam" file="no_reads.sam" ftype="sam" />\n+        </test>\n+        <test>\n+            <!-- subsampling BAM input without reads -->\n+            <param name="input" value="no_reads.bam" ftype="bam" />\n+            <conditional name="mode">\n+                <param name="outtype" value="selected_reads" />\n+                <section name="subsample_config">\n+                    <conditional name="subsampling_mode">\n+                        <param name="select_subsample" value="target" />\n+                        <param name="target" value="20" />\n+                    </conditional>\n+                </section>\n+                <conditional name="output_options">\n+                    <conditional name="output_format">\n+                        <param name="oformat" value="input" />\n+                    </conditional>\n+                </conditional>\n+            </conditional>\n+            <output name="outputsam" file="no_reads.bam" ftype="bam" />\n+        </test>\n+        <test>\n             <param name="input" value="test.sam" ftype="sam" />\n             <conditional name="mode">\n                 <param name="outtype" value="selected_reads" />\n@@ -653,7 +785,7 @@\n                 </section>\n                 <conditional name="output_options">\n                     <conditional name="output_format">\n-                        <param name="oformat" value="sam" />\n+                        <param name="oformat" value="input" />\n                     </conditional>\n                 </conditional>\n             </conditional>\n@@ -672,7 +804,7 @@\n                 </section>\n                 <conditional name="output_options">\n                     <conditional name="output_format">\n-                        <param name="oformat" value="bam" />\n+                        <param name="oformat" value="input" />\n                     </conditional>\n                 </conditional>\n             </conditional>\n@@ -691,7 +823,7 @@\n                 </section>\n                 <conditional name="output_options">\n                     <conditional name="output_format">\n-                        <param name="oformat" value="bam" />\n+                        <param name="oformat" value="input" />\n                     </conditional>\n                 </conditional>\n             </conditional>\n@@ -710,7 +842,7 @@\n                 </section>\n                 <conditional name="output_options">\n                     <conditional name="output_format">\n-                        <param name="oformat" value="bam" />\n+                        <param name="oformat" value="input" />\n                     </conditional>\n                 </conditional>\n             </conditional>\n@@ -730,7 +862,7 @@\n                 <conditional name="output_options">\n                     <param name="reads_report_type" value="dropped" />\n                     <conditional name="output_format">\n-                        <param name="oformat" value="bam" />\n+                        <param name="oformat" value="input" />\n                     </conditional>\n                 </conditional>\n             </conditional>\n'
b
diff -r b01db2684fa5 -r bf328cec6a42 test-data/no_reads.bam
b
Binary file test-data/no_reads.bam has changed
b
diff -r b01db2684fa5 -r bf328cec6a42 test-data/no_reads.sam
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/no_reads.sam Wed Sep 02 15:29:22 2020 -0400
b
@@ -0,0 +1,5 @@
+@HD VN:1.4 SO:unsorted
+@SQ SN:CHROMOSOME_I LN:100
+@RG ID:UNKNOWN SM:UNKNOWN
+@PG ID:bowtie2 PN:bowtie2 VN:2.0.0-beta5
+@PG ID:0 CL:aaaaa/aaa/aaaaa/aaaaaa/aaaaaaaaa/aaa/iuc/package_aaaaaaaaa_x_y/aaaaaaaaaaaa/bin/aaaaaaaaaaaaaaaaa aaaaaaaaaa /aaaa/aaaaa/aaa/aaaaaaaaaaaaaaaaaaa/tools/aaaaaaaaa/test-data/test.cram aa /aaaa/aaaaa/aaa/aaaaaaaaaaaaaaaaaaa/tools/aaaaaaaaa/test-data/test.fa -O test PN:samtools VN:1.2