view samtools_sort.xml @ 3:e613c1ad4c4c draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/samtools/samtools_sort commit 64305ae905dc79e44b478203000add73598bcca1
author iuc
date Sat, 06 Apr 2019 06:37:47 -0400
parents f56bdb93ae58
children 6c2c1836728b
line wrap: on
line source

<tool id="samtools_sort" name="Samtools sort" profile="18.01" version="2.0.3">
    <description>order of storing aligned sequences</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="stdio"/>
    <expand macro="version_command"/>
    <command><![CDATA[
        @ADDTHREADS@
	@ADDMEMORY@
        samtools sort
            -@ \$addthreads
            -m \$addmemory"M"
            ###if str(compression):
            ##    -l '$compression'
            ###end if
            $prim_key_cond.prim_key_select
            #if $prim_key_cond.prim_key_select == '-t':
                $prim_key_cond.tag
                $prim_key_cond.sec_key_select
            #end if
            -O bam
            -T sorttmp
            '${input1}'
             > '${output1}'
    ]]></command>
    <inputs>
        <param name="input1" type="data" format="sam,unsorted.bam,cram" label="BAM File" />
        <conditional name="prim_key_cond">
            <param name="prim_key_select" type="select" label="Primary sort key">
                <option value="">coordinate</option>
                <option value="-n">name (-n)</option>
                <option value="-t">tag (-t)</option>
            </param>
            <when value=""/>
            <when value="-n"/>
            <when value="-t">
                <param name="tag" type="text" optional="false" argument="-t" label="Alignment tag"/>
                <param name="sec_key_select" type="select" label="Secondary sort key">
                    <option value="">coordinate</option>
                    <option value="-n">name (-n)</option>
                </param>
           </when>
        </conditional>
        <!--<param name="compression" type="integer" argument="-l" optional="True" min="0" max="9" label="compression level" help="0 (uncompressed) to 9 (best)"/>-->
    </inputs>
    <outputs>
       <data name="output1" format="bam">
            <change_format>
                <when input="prim_key_cond.prim_key_select" value="" format="bam" />
                <when input="prim_key_cond.prim_key_select" value="-n" format="qname_sorted.bam" />
                <when input="prim_key_cond.prim_key_select" value="-t" format="unsorted.bam" />
            </change_format>
        </data>
    </outputs>
    <tests>
        <!-- tests from https://github.com/samtools/samtools/blob/9ce8c64493f7ea3fa69bc5c1ac980b1a8e3dcf1f/test/test.pl#L2464 -->
        <!-- # Pos sort -->
        <test>
            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
            <output name="output1" file="pos.sort.expected.bam" ftype="bam"/>
        </test>
    	<!-- test_cmd($opts, out=>"sort/pos.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads}  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -"); -->

        <!-- # Name sort -->
        <test>
            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
            <conditional name="prim_key_cond">
                <param name="prim_key_select" value="-n"/>
            </conditional>
            <output name="output1" file="name.sort.expected.bam" ftype="qname_sorted.bam"/>
        </test>
	<!--    test_cmd($opts, out=>"sort/name.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -n  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -");-->

        <!-- # Tag sort (RG) (considers output and name sorted) -->
        <test>
            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
            <conditional name="prim_key_cond">
                <param name="prim_key_select" value="-t"/>
                <param name="tag" value="RG"/>
            </conditional>
            <output name="output1" file="tag.rg.sort.expected.bam" ftype="unsorted.bam"/>
        </test>
    <!--test_cmd($opts, out=>"sort/tag.rg.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -t RG  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -");-->

        <!-- # Tag sort (RG); secondary by name -->
        <test>
            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
            <conditional name="prim_key_cond">
                <param name="prim_key_select" value="-t"/>
                <param name="tag" value="RG"/>
                <param name="sec_key_select" value="-n"/>
            </conditional>
            <output name="output1" file="tag.rg.n.sort.expected.bam" ftype="unsorted.bam"/>
        </test>
    <!--test_cmd($opts, out=>"sort/tag.rg.n.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -n -t RG  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -");-->

        <!-- # Tag sort (AS) -->
        <test>
            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
            <conditional name="prim_key_cond">
                <param name="prim_key_select" value="-t"/>
                <param name="tag" value="AS"/>
                <param name="sec_key_select" value=""/>
            </conditional>
            <output name="output1" file="tag.as.sort.expected.bam" ftype="unsorted.bam"/>
        </test>
    <!--test_cmd($opts, out=>"sort/tag.as.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -t AS $$opts{path}/dat/test_input_1_d.sam -O SAM -o -");-->

        <!-- # Tag sort (FI) -->
        <test>
            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
            <conditional name="prim_key_cond">
                <param name="prim_key_select" value="-t"/>
                <param name="tag" value="FI"/>
            </conditional>
            <output name="output1" file="tag.fi.sort.expected.bam" ftype="unsorted.bam"/>
        </test>
    <!--test_cmd($opts, out=>"sort/tag.fi.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -t FI $$opts{path}/dat/test_input_1_d.sam -O SAM -o -");-->

        <!-- tests from old version -->
        <test>
            <param name="input1" value="1.bam" ftype="bam" />
            <output name="output1" file="1_sort.bam" ftype="bam" sort="True"/>
        </test>
        <test>
            <param name="input1" value="1.bam" ftype="bam" />
            <conditional name="prim_key_cond">
                <param name="prim_key_select" value="-n"/>
            </conditional>
            <output name="output1" file="1_sort_read_names.bam" ftype="qname_sorted.bam"/>
        </test>
    </tests>
    <help>
**What it does**

Sort alignments by leftmost coordinates, or by read name when -n is used. 
An appropriate @HD-SO sort order header tag will be added or an existing 
one updated if necessary. 

**Ordering Rules**

The following rules are used for ordering records.

If option -t is in use, records are first sorted by the value of the given
alignment tag, and then by position or name (if using -n). For example, “-t RG”
will make read group the primary sort key. The rules for ordering by tag are:

- Records that do not have the tag are sorted before ones that do.
- If the types of the tags are different, they will be sorted so that single
  character tags (type A) come before array tags (type B), then string tags
  (types H and Z), then numeric tags (types f and i).
- Numeric tags (types f and i) are compared by value. Note that comparisons of
  floating-point values are subject to issues of rounding and precision.
- String tags (types H and Z) are compared based on the binary contents of the
  tag using the C strcmp(3) function.
- Character tags (type A) are compared by binary character value.
- No attempt is made to compare tags of other types — notably type B array values will not be compared. 

When the -n option is present, records are sorted by name. Names are compared so as to give a “natural” ordering — i.e. sections consisting of digits are compared numerically while all other sections are compared based on their binary representation. This means “a1” will come before “b1” and “a9” will come before “a10”. Records with the same name will be ordered according to the values of the READ1 and READ2 flags (see flags).

When the -n option is not present, reads are sorted by reference (according to the order of the @SQ header records), then by position in the reference, and then by the REVERSE flag.

This has now been removed. The previous out.prefix argument (and -f option, if any) should be changed to an appropriate combination of -T PREFIX and -o FILE. The previous -o option should be removed, as output defaults to standard output. 

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