0
|
1 <?xml version="1.0"?>
|
|
2 <tool id="bamtools" name="Convert, Merge, Randomize" version="0.0.1">
|
|
3 <description>BAM datasets and perform other transformations</description>
|
|
4 <requirements>
|
|
5 <requirement type="package" version="2.3.0_2d7685d2ae">bamtools</requirement>
|
|
6 <requirement type="package" version="0.1.18">samtools</requirement>
|
|
7 </requirements>
|
|
8
|
|
9 <command>
|
|
10 ##set up input files
|
|
11
|
|
12 #for $bam_count, $input_bam in enumerate( $input_bams ):
|
|
13 ln -s "${input_bam.input_bam}" "localbam_${bam_count}.bam" &&
|
|
14 ln -s "${input_bam.input_bam.metadata.bam_index}" "localbam_${bam_count}.bam.bai" &&
|
|
15 #end for
|
|
16
|
|
17 #if str( $analysis_type.analysis_type_selector ) == "convert":
|
|
18 #if str( $analysis_type.format_type.format_type_selector ) == "pileup":
|
|
19 #set $reference_fasta_filename = "localref.fa"
|
|
20 #if str( $analysis_type.format_type.reference_source.reference_source_selector ) == "history":
|
|
21 ln -s "${analysis_type.format_type.reference_source.ref_file}" "${reference_fasta_filename}" &&
|
|
22 samtools faidx "${reference_fasta_filename}" 2>&1 || echo "Error running samtools faidx for bamtools convert" >&2 &&
|
|
23 #else:
|
|
24 #set $reference_fasta_filename = str( $analysis_type.format_type.reference_source.ref_file.fields.path )
|
|
25 #end if
|
|
26 #end if
|
|
27 #end if
|
|
28
|
|
29 ##finished setting up inputs
|
|
30
|
|
31 ##start bamtools commandline
|
|
32
|
|
33 bamtools
|
|
34
|
|
35 #if str( $analysis_type.analysis_type_selector ) == "convert":
|
|
36
|
|
37 convert
|
|
38
|
|
39 -format ${analysis_type.format_type.format_type_selector}
|
|
40
|
|
41 #if str( $analysis_type.format_type.format_type_selector ) == "pileup":
|
|
42
|
|
43 ${analysis_type.format_type.mapqual}
|
|
44 -fasta "${reference_fasta_filename}"
|
|
45
|
|
46 #elif str( $analysis_type.format_type.format_type_selector ) == "sam":
|
|
47
|
|
48 ${analysis_type.format_type.noheader}
|
|
49
|
|
50 #end if
|
|
51
|
|
52 -out $out_file1
|
|
53
|
|
54 #elif str( $analysis_type.analysis_type_selector ) == "count":
|
|
55
|
|
56 count
|
|
57 > $out_file1
|
|
58
|
|
59 #elif str( $analysis_type.analysis_type_selector ) == "coverage":
|
|
60
|
|
61 coverage
|
|
62 -out $out_file1
|
|
63
|
|
64 #elif str( $analysis_type.analysis_type_selector ) == "header":
|
|
65
|
|
66 header
|
|
67 > $out_file1
|
|
68
|
|
69 #elif str( $analysis_type.analysis_type_selector ) == "merge":
|
|
70
|
|
71 merge
|
|
72 -out $out_file1
|
|
73
|
|
74 #elif str( $analysis_type.analysis_type_selector ) == "random":
|
|
75
|
|
76 random
|
|
77 -n ${analysis_type.count}
|
|
78 -seed ${analysis_type.seed}
|
|
79 -out $out_file1
|
|
80
|
|
81 #elif str( $analysis_type.analysis_type_selector ) == "revert":
|
|
82
|
|
83 revert
|
|
84 ${analysis_type.keepDuplicate}
|
|
85 ${analysis_type.keepQualities}
|
|
86 -out $out_file1
|
|
87
|
|
88 #elif str( $analysis_type.analysis_type_selector ) == "sort":
|
|
89
|
|
90 sort
|
|
91 ${analysis_type.byname}
|
|
92 -out $out_file1
|
|
93
|
|
94 #end if
|
|
95
|
|
96 #for $bam_count, $input_bam in enumerate( $input_bams ):
|
|
97 -in "localbam_${bam_count}.bam"
|
|
98 #end for
|
|
99
|
|
100
|
|
101 </command>
|
|
102 <inputs>
|
|
103
|
|
104 <repeat name="input_bams" title="BAM dataset(s) to filter" min="1">
|
|
105 <param name="input_bam" type="data" format="bam" label="BAM dataset" />
|
|
106 </repeat>
|
|
107
|
|
108 <conditional name="analysis_type">
|
|
109 <param name="analysis_type_selector" type="select" label="Select BAM manipulation" help="See help below for detailed description of each tool">
|
|
110 <option value="convert">Convert</option>
|
|
111 <option value="count">Count</option>
|
|
112 <option value="coverage">Coverage</option>
|
|
113 <option value="header">Header</option>
|
|
114 <option value="merge">Merge</option>
|
|
115 <option value="random">Random</option>
|
|
116 <option value="revert">Revert</option>
|
|
117 <!-- The sort option below is commented out as BAM files in Galaxy are reference sorted by dafault. -->
|
|
118 <!-- Allowing users for sort files may break donstream functionality. -->
|
|
119 <!-- To enable sort option simply uncomment the line below: -->
|
|
120 <!-- <option value="sort">Sort</option> -->
|
|
121 </param>
|
|
122 <when value="convert">
|
|
123 <conditional name="format_type">
|
|
124 <param name="format_type_selector" type="select" help="Select what to convert your BAM to">
|
|
125 <option value="bed">BED</option>
|
|
126 <option value="fasta">FASTA</option>
|
|
127 <option value="fastq">FASTQ</option>
|
|
128 <option value="json">JSON</option>
|
|
129 <option value="pileup">Pileup</option>
|
|
130 <option value="sam">SAM</option>
|
|
131 <option value="yaml">YAML</option>
|
|
132 </param>
|
|
133 <when value="pileup">
|
|
134 <conditional name="reference_source">
|
|
135 <param name="reference_source_selector" type="select" label="Choose the source for the reference list">
|
|
136 <option value="cached">Locally cached</option>
|
|
137 <option value="history">History</option>
|
|
138 </param>
|
|
139 <when value="cached">
|
|
140 <param name="ref_file" type="select" label="Using reference genome">
|
|
141 <options from_data_table="sam_fa_indexes">
|
|
142 <!--<filter type="data_meta" key="dbkey" ref="input_bam" column="value"/>-->
|
|
143 </options>
|
|
144 <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
|
|
145 </param>
|
|
146 </when>
|
|
147 <when value="history"> <!-- FIX ME!!!! -->
|
|
148 <param name="ref_file" type="data" format="fasta" label="Using reference file" />
|
|
149 </when>
|
|
150 </conditional>
|
|
151 <param name="mapqual" type="boolean" truevalue="-mapqual" falsevalue="" label="Print quality scores?" />
|
|
152 </when>
|
|
153 <when value="sam">
|
|
154 <param name="noheader" type="boolean" truevalue="-noheader" falsevalue="" label="Do not print header" />
|
|
155 </when>
|
|
156 </conditional>
|
|
157 </when>
|
|
158 <when value="count">
|
|
159 <!-- Nothing to be done with count -> just count alignments in the input bam(s) -->
|
|
160 </when>
|
|
161 <when value="coverage">
|
|
162 <!-- Nothing to be done with count -> just count alignments in the input bam(s) -->
|
|
163 </when>
|
|
164 <when value="header">
|
|
165 <!-- Nothing to be done with count -> just count alignments in the input bam(s) -->
|
|
166 </when>
|
|
167 <when value="merge">
|
|
168 <!-- Nothing to be done with count -> just count alignments in the input bam(s) -->
|
|
169 </when>
|
|
170 <when value="random">
|
|
171 <param name="count" type="integer" value="10000" label="Number of random alignments to grab" help="No duplicate checking is perfomed" />
|
|
172 <param name="seed" type="integer" value="1024" label="Random number generator seed" help="Use the same seed for reproducible results" />
|
|
173 </when>
|
|
174 <when value="revert">
|
|
175 <param name="keepDuplicate" type="boolean" truevalue="-keepDuplicate" falsevalue="" label="Keep duplicates marked" help="Do not remove duplicate marks" />
|
|
176 <param name="keepQualities" type="boolean" truevalue="-keepQualities" falsevalue="" label="Keep base qualities" help="Do not replace qualities with contect of OQ tag" />
|
|
177 </when>
|
|
178 <when value="sort">
|
|
179 <param name="byname" type="boolean" truevalue="-byname" falsevalue="" label="Sort by name" help="Checked: sort by name; Unchecked: sort by coordinate"/>
|
|
180 </when>
|
|
181 </conditional>
|
|
182
|
|
183 </inputs>
|
|
184 <outputs>
|
|
185 <data format="txt" name="out_file1">
|
|
186 <change_format>
|
|
187 <when input="analysis_type.format_type.format_type_selector" value="bed" format="bed" />
|
|
188 <when input="analysis_type.format_type.format_type_selector" value="fasta" format="fasta" />
|
|
189 <when input="analysis_type.format_type.format_type_selector" value="fastq" format="fastq" />
|
|
190 <when input="analysis_type.format_type.format_type_selector" value="sam" format="sam" />
|
|
191 <when input="analysis_type.format_type.format_type_selector" value="pileup" format="pileup" />
|
|
192 <when input="analysis_type.analysis_type_selector" value="coverage" format="tabular" />
|
|
193 <when input="analysis_type.analysis_type_selector" value="merge" format="bam" />
|
|
194 <when input="analysis_type.analysis_type_selector" value="random" format="bam" />
|
|
195 <when input="analysis_type.analysis_type_selector" value="revert" format="bam" />
|
|
196 <when input="analysis_type.analysis_type_selector" value="sort" format="bam" />
|
|
197 </change_format>
|
|
198 </data>
|
|
199 </outputs>
|
|
200 <tests>
|
|
201 <test>
|
|
202 <param name="input_bam" ftype="bam" value="bamtools-input1.bam"/>
|
|
203 <param name="analysis_type_selector" value="convert"/>
|
|
204 <param name="format_type_selector" value="pileup"/>
|
|
205 <param name="reference_source_selector" value="history" />
|
|
206 <param name="mapqual" value="true" />
|
|
207 <param name="ref_file" ftype="fasta" value="bamtools-fasta.fa"/>
|
|
208 <output name="output_bam" file="bamtools-convert-pileup.pu" />
|
|
209 </test>
|
|
210 <test>
|
|
211 <param name="input_bam" ftype="bam" value="bamtools-input1.bam"/>
|
|
212 <param name="analysis_type_selector" value="count"/>
|
|
213 <output name="output_bam" file="bamtools-count.tab" />
|
|
214 </test>
|
|
215 <test>
|
|
216 <param name="input_bam" ftype="bam" value="bamtools-input1.bam"/>
|
|
217 <param name="analysis_type_selector" value="coverage"/>
|
|
218 <output name="output_bam" file="bamtools-coverage.tab" />
|
|
219 </test>
|
|
220 <test>
|
|
221 <param name="input_bam" ftype="bam" value="bamtools-input1.bam"/>
|
|
222 <param name="analysis_type_selector" value="header"/>
|
|
223 <output name="output_bam" file="bamtools-header.txt" />
|
|
224 </test>
|
|
225 </tests>
|
|
226
|
|
227 <stdio>
|
|
228 <exit_code range="1:" />
|
|
229 </stdio>
|
|
230
|
|
231 <help>
|
|
232
|
|
233 **What is does**
|
|
234
|
|
235 BAMTools is a collection of utilities for manipulation on BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
|
|
236 This Galaxy implementation of BAMTools utilities includes seven utilities - Convert, Count, Coverage, Header, Merge, Random, and Revert - decsribed in detail below.
|
|
237
|
|
238 -----
|
|
239
|
|
240 **Convert**
|
|
241
|
|
242 Converts BAM dataset(s) into BED, FASTA, FASTQ, JSON, Pileup, SAM, or YAML formats. Note that the conversion to the pileup format requires providing a reference sequence either
|
|
243 cashed at this Galaxy instance, or provided by you as a FASTA dataset from History.
|
|
244
|
|
245 -----
|
|
246
|
|
247 **Count**
|
|
248
|
|
249 Counts a number of alignments in a BAM dataset(s).
|
|
250
|
|
251 -----
|
|
252
|
|
253 **Coverage**
|
|
254
|
|
255 Prints per-base coverage for a BAM dataset.
|
|
256
|
|
257 -----
|
|
258
|
|
259 **Header**
|
|
260
|
|
261 Prints header from a BAM dataset(s).
|
|
262
|
|
263 ------
|
|
264
|
|
265 **Merge**
|
|
266
|
|
267 Merges multiple BAM datasets into a single one. Obviously, you need to select multiple BAMs as input, which is done by pressing the "**Add new BAM dataset(s) to filter**" button.
|
|
268
|
|
269 ------
|
|
270
|
|
271 **Random**
|
|
272
|
|
273 Grabs a specified number of random lines from BAM dataset(s).
|
|
274
|
|
275 ------
|
|
276
|
|
277 **Revert**
|
|
278
|
|
279 Removes duplicate marks and restores original (non-recalibrated) base qualities.
|
|
280
|
|
281 -----
|
|
282
|
|
283 .. class:: infomark
|
|
284
|
|
285 **More information**
|
|
286
|
|
287 Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
|
|
288
|
|
289 </help>
|
|
290 <citations>
|
|
291 <citation type="doi">10.1093/bioinformatics/btr174</citation>
|
|
292 </citations>
|
|
293 </tool>
|