view sam_to_bam.xml @ 6:d04d9f1c6791 draft

Uploaded
author devteam
date Tue, 21 Apr 2015 14:52:20 -0400
parents c73bf16b45df
children 881e16ad05c6
line wrap: on
line source

<tool id="sam_to_bam" name="SAM-to-BAM" version="2.0">
  <description>convert SAM to BAM</description>
  <macros>
    <import>macros.xml</import>
  </macros>
  <expand macro="requirements"></expand>
  <expand macro="version_command"></expand>
  <expand macro="stdio"></expand>
  <command>
    <![CDATA[
        samtools sort -O bam -@ \${GALAXY_SLOTS:-1} -o sorted_input.bam -T temp "$input1" && 
          #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 -@ \${GALAXY_SLOTS:-1} -b -h -o $output1 -T input.fa sorted_input.bam
    ]]>
    </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>
    </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>
    </tests>
    <help>
<![CDATA[
**What it does**

Converts SAM dataset into its binary, BAM, representation using ``samtools sort`` and ``view`` commands::

  samtools sort -O bam -o sorted_input.bam [INPUT SAM] 
  samtools view -b -h -o -T [REFERENCE GENOME] [OUTPUT BAM] sorted_input.bam

]]>
  </help>
  <expand macro="citations"></expand>
</tool>