diff sam_to_bam.xml @ 2:5a5f92086188 draft

planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
author devteam
date Tue, 13 Oct 2015 12:53:53 -0400
parents 7095d651c95f
children 4afb4a5f0924
line wrap: on
line diff
--- a/sam_to_bam.xml	Thu Mar 27 14:04:25 2014 -0400
+++ b/sam_to_bam.xml	Tue Oct 13 12:53:53 2015 -0400
@@ -1,97 +1,89 @@
-<tool id="sam_to_bam" name="SAM-to-BAM" version="1.1.3">
-  <description>converts SAM format to BAM format</description>
-  <requirements>
-    <requirement type="package" version="0.1.19">samtools</requirement>
-  </requirements>
-  <command interpreter="python">
-    sam_to_bam.py
-      --input1=$source.input1
-      #if $source.index_source == "history":
-        --dbkey=${ref_file.metadata.dbkey} 
-        --ref_file=$source.ref_file
-      #else
-        --dbkey=${input1.metadata.dbkey} 
-      #end if
-      --output1=$output1
-      --index_dir=${GALAXY_DATA_INDEX_DIR}
-  </command>
-  <inputs>
-    <conditional name="source">
-      <param name="index_source" type="select" label="Choose the source for the reference list">
-        <option value="cached">Locally cached</option>
-        <option value="history">History</option>
-      </param>
-      <when value="cached">
-        <param name="input1" type="data" format="sam" metadata_name="dbkey" label="SAM File to Convert">
-           <validator type="unspecified_build" />
-           <validator type="dataset_metadata_in_file" filename="sam_fa_indices.loc" metadata_name="dbkey" metadata_column="1" message="Sequences are not currently available for the specified build." line_startswith="index" />
-        </param>
-      </when>
-      <when value="history">
-        <param name="input1" type="data" format="sam" label="Convert SAM file" />
-        <param name="ref_file" type="data" format="fasta" metadata_name="dbkey" label="Using reference file" />
-      </when>
-    </conditional>
-  </inputs>
-  <outputs>
-    <data format="bam" name="output1" label="${tool.name} on ${on_string}: converted BAM">
-      <actions>
-        <conditional name="source.index_source">
-          <when value="cached">
-            <action type="metadata" name="dbkey">
-              <option type="from_param" name="source.input1" param_attribute="dbkey" />
-            </action>
-          </when>
-          <when value="history">
-            <action type="metadata" name="dbkey">
-              <option type="from_param" name="source.ref_file" param_attribute="dbkey" />
-            </action>
-          </when>
+<tool id="sam_to_bam" name="SAM-to-BAM" version="2.1">
+  <description>convert SAM to BAM</description>
+  <macros>
+    <import>macros.xml</import>
+  </macros>
+  <expand macro="requirements"></expand>
+  <expand macro="stdio"></expand>
+  <expand macro="version_command"></expand>
+  <command>
+    <![CDATA[
+        #if $source.index_source == "history":
+          ln -s $source.ref_file input.fa &&
+          samtools faidx input.fa &&
+        #else
+          ln -s ${source.index.fields.path} input.fa &&
+          ln -s ${source.index.fields.path}.fai input.fa.fai &&
+        #end if
+        samtools view -b -@ \${GALAXY_SLOTS:-1} -t input.fa.fai "$input1" | samtools sort -O bam -@ \${GALAXY_SLOTS:-1} -o "$output1" -T temp
+    ]]>
+    </command>
+    <inputs>
+        <conditional name="source">
+            <param label="Choose the source for the reference genome" name="index_source" type="select">
+                <option value="cached">Use a built-in genome</option>
+                <option value="history">Use a genome from the history</option>
+            </param>
+            <when value="cached">
+                <param format="sam" label="SAM file to convert" metadata_name="dbkey" name="input1" type="data">
+                    <validator type="unspecified_build" />
+                    <validator message="Sequences are not currently available for the specified build." metadata_column="1" metadata_name="dbkey" table_name="fasta_indexes" type="dataset_metadata_in_data_table" />
+                </param>
+                <param label="Using reference genome" name="index" type="select">
+                    <options from_data_table="fasta_indexes">
+                        <filter column="1" key="dbkey" ref="input1" type="data_meta" />
+                        <validator message="No reference genome is available for the build associated with the selected input dataset" type="no_options" />
+                    </options>
+                </param>
+            </when>
+            <when value="history">
+                <param format="sam" label="SAM file to convert" name="input1" type="data" />
+                <param format="fasta" label="Using reference file" metadata_name="dbkey" name="ref_file" type="data" />
+            </when>
         </conditional>
-      </actions>
-    </data>
-  </outputs>
-  <tests>
-    <test>
-      <!--
-      Sam-to-Bam command:
-      cp test-data/chr_m.fasta .
-      samtools faidx chr_m.fasta
-      samtools view -hbt chr_m.fasta.fai -o unsorted.bam test-data/sam_to_bam_in1.sam
-      samtools sort unsorted.bam sam_to_bam_out1
-      chr_m.fasta is the reference file (chrM from equCab2)
-      -->
-      <param name="index_source" value="history" /> 
-      <param name="input1" value="sam_to_bam_in1.sam" ftype="sam" />
-      <param name="ref_file" value="chr_m.fasta" ftype="fasta" dbkey="equCab2" />
-      <output name="output1" file="sam_to_bam_out1.bam" ftype="bam" />
-    </test>
-    <test>
-      <!--
-      Sam-to-Bam command:
-      samtools view -hbt chr_m.fasta.fai -o unsorted.bam test-data/sam_to_bam_in1.sam
-      samtools sort unsorted.bam sam_to_bam_out2
-      chr_m.fasta is the reference file and the index chr_m.fasta.fai 
-      these should be in the same directory, and chrM is from equCab2
-      -->
-      <param name="index_source" value="cached" />
-      <param name="input1" value="sam_to_bam_in1.sam" ftype="sam" dbkey="chrM" />
-      <output name="output1" file="sam_to_bam_out2.bam" ftype="bam" />
-    </test>
-  </tests>
-  <help>
-
+    </inputs>
+    <outputs>
+        <data format="bam" label="${tool.name} on ${on_string}: converted BAM" name="output1">
+            <actions>
+                <conditional name="source.index_source">
+                    <when value="cached">
+                        <action name="dbkey" type="metadata">
+                            <option name="source.input1" param_attribute="dbkey" type="from_param" />
+                        </action>
+                    </when>
+                    <when value="history">
+                        <action name="dbkey" type="metadata">
+                            <option name="source.ref_file" param_attribute="dbkey" type="from_param" />
+                        </action>
+                    </when>
+                </conditional>
+            </actions>
+        </data>
+    </outputs>
+    <tests>
+        <test>
+            <param name="index_source" value="history" />
+            <param name="input1" ftype="sam" value="sam_to_bam_in1.sam" />
+            <param dbkey="equCab2" ftype="fasta" name="ref_file" value="chr_m.fasta" />
+            <output file="sam_to_bam_out1.bam" ftype="bam" name="output1" />
+        </test>
+        <test>
+            <param name="index_source" value="history" />
+            <param name="input1" ftype="sam" value="sam_to_bam_noheader_in2.sam" />
+            <param dbkey="equCab2" ftype="fasta" name="ref_file" value="chr_m.fasta" />
+            <output file="sam_to_bam_out3.bam" ftype="bam" name="output1" />
+        </test>
+    </tests>
+    <help>
+<![CDATA[
 **What it does**
 
-This tool uses the SAMTools_ toolkit to produce an indexed BAM file based on a sorted input SAM file.
+Converts SAM dataset into its binary, BAM, representation using ``samtools sort`` and ``view`` commands::
 
-.. _SAMTools: http://samtools.sourceforge.net/samtools.shtml
-
-------
+  samtools sort -O bam -o sorted_input.bam [INPUT SAM] 
+  samtools view -b -h -o -T [REFERENCE GENOME] [OUTPUT BAM] sorted_input.bam
 
-**Citation**
-
-For the underlying tool, please cite `Li H, Handsaker B, Wysoker A, Fennell T, Ruan J, Homer N, Marth G, Abecasis G, Durbin R; 1000 Genome Project Data Processing Subgroup. The Sequence Alignment/Map format and SAMtools. Bioinformatics. 2009 Aug 15;25(16):2078-9. &lt;http://www.ncbi.nlm.nih.gov/pubmed/19505943&gt;`_
-
+]]>
   </help>
+  <expand macro="citations"></expand>
 </tool>