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