2
|
1 <tool id="samtools_sort" name="Samtools Sort" version="2.0.5" profile="@PROFILE@">
|
1
|
2 <description>Sort Alignment Files (SAM/BAM)</description>
|
0
|
3 <macros>
|
|
4 <import>macros.xml</import>
|
|
5 </macros>
|
|
6 <expand macro="requirements"/>
|
|
7 <expand macro="stdio"/>
|
|
8 <expand macro="version_command"/>
|
|
9 <command><![CDATA[
|
|
10 samtools sort
|
|
11 ###if str(compression):
|
|
12 ## -l '$compression'
|
|
13 ###end if
|
|
14 $prim_key_cond.prim_key_select
|
|
15 #if $prim_key_cond.prim_key_select == '-t':
|
|
16 $prim_key_cond.tag
|
|
17 $prim_key_cond.sec_key_select
|
|
18 #end if
|
|
19 $minhash
|
|
20 -O bam
|
|
21 -T "\${TMPDIR:-.}"
|
|
22 '${input1}'
|
|
23 > '${output1}'
|
|
24 ]]></command>
|
|
25 <inputs>
|
|
26 <param name="input1" type="data" format="sam,unsorted.bam,cram" label="BAM File" />
|
|
27 <conditional name="prim_key_cond">
|
|
28 <param name="prim_key_select" type="select" label="Primary sort key">
|
|
29 <option value="" selected="True">coordinate</option>
|
|
30 <option value="-n">name (-n)</option>
|
|
31 <option value="-t">tag (-t)</option>
|
|
32 </param>
|
|
33 <when value=""/>
|
|
34 <when value="-n"/>
|
|
35 <when value="-t">
|
|
36 <param name="tag" type="text" optional="false" argument="-t" label="Alignment tag"/>
|
|
37 <param name="sec_key_select" type="select" label="Secondary sort key">
|
|
38 <option value="">coordinate</option>
|
|
39 <option value="-n">name (-n)</option>
|
|
40 </param>
|
|
41 </when>
|
|
42 </conditional>
|
|
43 <param name="minhash" type="boolean" argument="-M" truevalue="-M" falsevalue="" checked="false" label="Minhash collation" help="Use minimiser for clustering unaligned/unplaced reads."/>
|
|
44 <!--<param name="compression" type="integer" argument="-l" optional="True" min="0" max="9" label="compression level" help="0 (uncompressed) to 9 (best)"/>-->
|
|
45 </inputs>
|
|
46 <outputs>
|
|
47 <data name="output1" format="bam">
|
|
48 <change_format>
|
|
49 <when input="prim_key_cond.prim_key_select" value="" format="bam" />
|
|
50 <when input="prim_key_cond.prim_key_select" value="-n" format="qname_sorted.bam" />
|
|
51 <when input="prim_key_cond.prim_key_select" value="-t" format="unsorted.bam" />
|
|
52 </change_format>
|
|
53 </data>
|
|
54 </outputs>
|
|
55 <tests>
|
|
56 <!-- tests from https://github.com/samtools/samtools/blob/9ce8c64493f7ea3fa69bc5c1ac980b1a8e3dcf1f/test/test.pl#L2464 -->
|
|
57 <!-- 1) # Pos sort -->
|
|
58 <test>
|
|
59 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
60 <output name="output1" file="pos.sort.expected.bam" ftype="bam" lines_diff="4" />
|
|
61 </test>
|
|
62 <!-- 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 -"); -->
|
|
63 <!-- 2) # Name sort -->
|
|
64 <test>
|
|
65 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
66 <conditional name="prim_key_cond">
|
|
67 <param name="prim_key_select" value="-n"/>
|
|
68 </conditional>
|
|
69 <output name="output1" file="name.sort.expected.bam" ftype="qname_sorted.bam" lines_diff="4"/>
|
|
70 </test>
|
|
71 <!-- 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 -");-->
|
|
72 <!-- 3) # Tag sort (RG) (considers output and name sorted) -->
|
|
73 <test>
|
|
74 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
75 <conditional name="prim_key_cond">
|
|
76 <param name="prim_key_select" value="-t"/>
|
|
77 <param name="tag" value="RG"/>
|
|
78 </conditional>
|
|
79 <output name="output1" file="tag.rg.sort.expected.bam" ftype="unsorted.bam" lines_diff="4"/>
|
|
80 </test>
|
|
81 <!--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 -");-->
|
|
82 <!-- 4) # Tag sort (RG); secondary by name -->
|
|
83 <test>
|
|
84 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
85 <conditional name="prim_key_cond">
|
|
86 <param name="prim_key_select" value="-t"/>
|
|
87 <param name="tag" value="RG"/>
|
|
88 <param name="sec_key_select" value="-n"/>
|
|
89 </conditional>
|
|
90 <output name="output1" file="tag.rg.n.sort.expected.bam" ftype="unsorted.bam" lines_diff="4"/>
|
|
91 </test>
|
|
92 <!--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 -");-->
|
|
93 <!-- 5) # Tag sort (AS) -->
|
|
94 <test>
|
|
95 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
96 <conditional name="prim_key_cond">
|
|
97 <param name="prim_key_select" value="-t"/>
|
|
98 <param name="tag" value="AS"/>
|
|
99 <param name="sec_key_select" value=""/>
|
|
100 </conditional>
|
|
101 <output name="output1" file="tag.as.sort.expected.bam" ftype="unsorted.bam" lines_diff="4"/>
|
|
102 </test>
|
|
103 <!--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 -");-->
|
|
104 <!-- 6) # Tag sort (FI) -->
|
|
105 <test>
|
|
106 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
107 <conditional name="prim_key_cond">
|
|
108 <param name="prim_key_select" value="-t"/>
|
|
109 <param name="tag" value="FI"/>
|
|
110 </conditional>
|
|
111 <output name="output1" file="tag.fi.sort.expected.bam" ftype="unsorted.bam" lines_diff="4"/>
|
|
112 </test>
|
|
113 <!--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 -");-->
|
|
114 <!-- 7) tests from old version -->
|
|
115 <test>
|
|
116 <param name="input1" value="1.bam" ftype="bam" />
|
|
117 <output name="output1" file="1_sort.bam" ftype="bam" sort="True" lines_diff="4"/>
|
|
118 </test>
|
|
119 <test>
|
|
120 <param name="input1" value="1.bam" ftype="bam" />
|
|
121 <conditional name="prim_key_cond">
|
|
122 <param name="prim_key_select" value="-n"/>
|
|
123 </conditional>
|
|
124 <output name="output1" file="1_sort_read_names.bam" ftype="qname_sorted.bam" lines_diff="4"/>
|
|
125 </test>
|
|
126 <!-- 8) test minhash sorting -->
|
|
127 <test>
|
|
128 <param name="input1" value="test_input_1_a.bam" ftype="bam" />
|
|
129 <param name="minhash" value="true" />
|
|
130 <output name="output1" file="minhash.expected.bam" ftype="bam" lines_diff="4" />
|
|
131 </test>
|
|
132 </tests>
|
|
133 <help>
|
|
134 **What it does**
|
|
135
|
|
136 Sort alignments by leftmost coordinates, or by read name when -n is used.
|
|
137 An appropriate @HD-SO sort order header tag will be added or an existing
|
|
138 one updated if necessary.
|
|
139
|
|
140 **Ordering Rules**
|
|
141
|
|
142 The following rules are used for ordering records.
|
|
143
|
|
144 If option -t is in use, records are first sorted by the value of the given
|
|
145 alignment tag, and then by position or name (if using -n). For example, “-t RG”
|
|
146 will make read group the primary sort key. The rules for ordering by tag are:
|
|
147
|
|
148 - Records that do not have the tag are sorted before ones that do.
|
|
149 - If the types of the tags are different, they will be sorted so that single
|
|
150 character tags (type A) come before array tags (type B), then string tags
|
|
151 (types H and Z), then numeric tags (types f and i).
|
|
152 - Numeric tags (types f and i) are compared by value. Note that comparisons of
|
|
153 floating-point values are subject to issues of rounding and precision.
|
|
154 - String tags (types H and Z) are compared based on the binary contents of the
|
|
155 tag using the C strcmp(3) function.
|
|
156 - Character tags (type A) are compared by binary character value.
|
|
157 - No attempt is made to compare tags of other types — notably type B array values will not be compared.
|
|
158
|
|
159 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).
|
|
160
|
|
161 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.
|
|
162
|
|
163 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.
|
|
164
|
|
165 When the -M (minash collation) option is present, then samtools sort groups unmapped reads with similar sequence together. This can sometimes significantly reduce the file size.
|
|
166
|
|
167 </help>
|
|
168 <expand macro="citations"/>
|
|
169 </tool>
|