upstream-extended/iuc/tools/bcftools/bcftools_annotate.xml
1<?xml version='1.0' encoding='utf-8'?>
2<tool name="bcftools @EXECUTABLE@" id="bcftools_@EXECUTABLE@" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
3 <description>Annotate and edit VCF/BCF files</description>
4 <macros>
5 <token name="@EXECUTABLE@">annotate</token>
6 <import>macros.xml</import>
7 </macros>
8 <expand macro="bio_tools" />
9 <expand macro="requirements" />
10 <expand macro="version_command" />
11 <command detect_errors="aggressive"><![CDATA[
12@PREPARE_INPUT_FILE@
13#set $annotation_file = None
14#set $annotation_hdr = None
15#set $section = $sec_annofile
16#if $section.annofile.anno_fmt == 'vcf':
17 #if $section.annofile.annotations.is_of_type('vcf')
18 #set $annotation_file = 'annotations.vcf.gz'
19 bgzip -c '$section.annofile.annotations' > $annotation_file &&
20 bcftools index $annotation_file &&
21 #elif $section.annofile.annotations.is_of_type('bcf')
22 #set $annotation_file = 'annotations.bcf'
23 ln -s '$section.annofile.annotations' $annotation_file &&
24 #if $section.annofile.annotations.metadata.bcf_index:
25 ln -s '${section.annofile.annotations.metadata.bcf_index}' ${annotation_file}.csi &&
26 #else
27 bcftools index $annotation_file &&
28 #end if
29 #end if
30#elif $section.annofile.anno_fmt == 'tab':
31 #if $section.annofile.annotations.is_of_type('bed')
32 #set $annotation_file = 'annotations.bed.gz'
33 bgzip -c '$section.annofile.annotations' > $annotation_file &&
34 tabix -s 1 -b 2 -e 3 $annotation_file &&
35 #else:
36 #set $annotation_file = 'annotations.tab.gz'
37 bgzip -c '$section.annofile.annotations' > $annotation_file &&
38 tabix -s 1 -b 2 -e 2 $annotation_file &&
39 #end if
40 #if $section.annofile.header_file:
41 #set $annotation_hdr = $section.annofile.header_file
42 #elif $section.annofile.header_lines:
43 #set $annotation_hdr = 'annotation.hdr'
44 grep '^\#\#INFO' '${hdr_file}' > $annotation_hdr &&
45 #end if
46#end if
47#set $section = $sec_restrict
48
49bcftools @EXECUTABLE@
50@PREPARE_REGIONS_FILE@
51
52#set $section = $sec_annofile
53@COLUMNS@
54#if $annotation_file:
55 --annotations '${annotation_file}'
56#end if
57#if $annotation_hdr:
58 --header-lines '${annotation_hdr}'
59#end if
60
61#if $section.set_id:
62 --set-id '${section.set_id}'
63#end if
64#if $section.mark_sites:
65 --mark-sites '${section.mark_sites}'
66#end if
67#if $section.min_overlap
68 --min-overlap '$section.min_overlap'
69#end if
70
71#set $section = $sec_annotate
72#if $section.rename_chrs:
73 --rename-chrs '${section.rename_chrs}'
74#end if
75#if $section.remove:
76 --remove '${section.remove}'
77#end if
78#if $section.rename_annots
79 --rename-annots '$section.rename_annots'
80#end if
81
82
83## Default section
84#set $section = $sec_restrict
85@INCLUDE@
86@EXCLUDE@
87@COLLAPSE@
88@REGIONS@
89@SAMPLES@
90
91@OUTPUT_TYPE@
92@THREADS@
93
94## Primary Input/Outputs
95@INPUT_FILE@
96> '$output_file'
97]]>
98 </command>
99 <configfiles>
100 <configfile name="hdr_file"><![CDATA[#slurp
101#if $sec_annofile.annofile.anno_fmt == 'tab' and str($sec_annofile.annofile.header_lines) != '':
102$sec_annofile.annofile.header_lines.__str__.strip()#slurp
103#end if]]></configfile>
104 </configfiles>
105 <inputs>
106 <expand macro="macro_input" />
107 <section name="sec_annofile" expanded="false" title="Add Annotations">
108 <expand macro="macro_columns" />
109 <conditional name="annofile">
110 <param name="anno_fmt" type="select" label="Annotations File">
111 <option value="none">None</option>
112 <option value="vcf">From a VCF/BCF file</option>
113 <option value="tab">From a BED or tab-delimited file</option>
114 </param>
115 <when value="none"/>
116 <when value="vcf">
117 <param name="annotations" type="data" format="vcf,bcf" label="Annotations VCF"/>
118 </when>
119 <when value="tab">
120 <param name="annotations" type="data" format="tabular,bed" label="Annotations">
121 <help><![CDATA[
122 BED, or a tab-delimited file with mandatory columns CHROM, POS (or, alternatively, FROM and TO),
123 optional columns REF and ALT, and arbitrary number of annotation columns.
124 Note that in case of tab-delimited file, the coordinates POS, FROM and TO are one-based and inclusive.
125 ]]></help>
126 </param>
127 <param name="header_file" type="data" format="txt" label="Header Lines File" optional="true" help="lines which should be appended to the VCF header" />
128 <param name="header_lines" type="text" area="true" label="Header Lines" optional="true" help="lines which should be appended to the VCF header" >
129 <help><![CDATA[
130 ##INFO=<ID=NUMERIC_TAG,Number=1,Type=Integer,Description="Example header line">
131 ##INFO=<ID=STRING_TAG,Number=1,Type=String,Description="Yet another header line">
132 ]]></help>
133 <sanitizer sanitize="False"/>
134 </param>
135 </when>
136 </conditional>
137 <param argument="--mark-sites" type="text" value="" label="Mark Sites TAG"
138 help="add INFO/TAG flag to sites which are ("+") or are not ("-") listed in the annotations file" />
139 <param argument="--min-overlap" type="text" value="" label="Minimum required overlap of intersecting regions" optional="true" help="Minimum overlap required as a fraction of the variant in the annotation -a file (ANN), in the target VCF file (:VCF), or both for reciprocal overlap (ANN:VCF). By default overlaps of arbitrary length are sufficient.">
140 <sanitizer invalid_char="">
141 <valid initial="string.digits">
142 <add value=":" />
143 <add value="." />
144 </valid>
145 </sanitizer>
146 <validator type="regex">[0-9.:]+</validator>
147 </param>
148 <param argument="--set-id" type="text" value="" optional="true" label="Set Id">
149 <help>Assign ID on the fly using the given format.
150 By default all existing IDs are replaced.
151 If the format string is preceded by "+", only missing IDs will be set.
152 For example: '%CHROM\_%POS\_%REF\_%FIRST_ALT'
153 </help>
154 <sanitizer sanitize="False"/>
155 <validator type="regex" message="">^([+]?(%[A-Z_]+)(\\_%[A-Z_]+)*)?$</validator>
156 </param>
157 </section>
158 <section name="sec_annotate" expanded="false" title="Change Annotations">
159 <param argument="--remove" type="text" value="" label="Remove annotations" optional="true">
160 <help><![CDATA[
161 List of annotations to remove.
162 Use "FILTER" to remove all filters or "FILTER/SomeFilter" to remove a specific filter.
163 Similarly, "INFO" can be used to remove all INFO tags and "FORMAT" to remove all FORMAT tags except GT.
164 To remove all INFO tags except "FOO" and "BAR", use "^INFO/FOO,INFO/BAR" (and similarly for FORMAT and FILTER).
165 "INFO" can be abbreviated to "INF" and "FORMAT" to "FMT".
166 ]]></help>
167 <validator type="regex" message="">^(\^?[A-Z]+(/\w+)?(,\^?[A-Z]+(/\w+)?)*)?$</validator>
168 </param>
169 <param argument="--rename-chrs" type="data" format="tabular" label="Rename CHROM" optional="true"
170 help="rename chromosomes according to the map in file, with old_name new_name pairs separated by whitespaces, each on a separate line." />
171 <param argument="--rename-annots" type="data" format="tabular" optional="true" label="Rename annotations" help="TYPE/old\tnew, where TYPE is one of FILTER,INFO,FORMAT" />
172 </section>
173 <section name="sec_restrict" expanded="false" title="Restrict to">
174 <expand macro="macro_include" />
175 <expand macro="macro_exclude" />
176 <expand macro="macro_collapse" />
177 <expand macro="macro_region_restrict" />
178 <expand macro="macro_samples" />
179 </section>
180 <expand macro="macro_select_output_type" />
181 </inputs>
182 <outputs>
183 <expand macro="macro_vcf_output"/>
184 </outputs>
185 <tests>
186 <test>
187 <param name="input_file" ftype="vcf" value="annotate.vcf" />
188 <section name="sec_annofile">
189 <conditional name="annofile">
190 <param name="anno_fmt" value="tab" />
191 <param name="annotations" value="annotate.tab" />
192 <param name="header_file" value="annotate.hdr" />
193 </conditional>
194 <param name="columns" value="CHROM,POS,REF,ALT,ID,QUAL,INFO/T_INT,INFO/T_FLOAT,INDEL" />
195 </section>
196 <param name="output_type" value="v" />
197 <output name="output_file">
198 <assert_contents>
199 <has_text text="snp_3000150" />
200 </assert_contents>
201 </output>
202 </test>
203 <test>
204 <param name="input_file" ftype="vcf" value="annotate.vcf" />
205 <section name="sec_annofile">
206 <param name="columns" value="CHROM,FROM,TO,T_STR" />
207 <conditional name="annofile">
208 <param name="anno_fmt" value="tab" />
209 <param name="annotations" value="annotate2.tab" />
210 <param name="header_file" value="annotate.hdr" />
211 </conditional>
212 <param name="set_id" value="%CHROM\_%POS\_%REF\_%FIRST_ALT" />
213 </section>
214 <param name="output_type" value="v" />
215 <output name="output_file">
216 <assert_contents>
217 <has_text text="T_STR=region_3000150_3106154" />
218 <has_text text="1_3062915_GTTT_G" />
219 </assert_contents>
220 </output>
221 </test>
222 <test>
223 <param name="input_file" ftype="vcf" value="annotate.vcf" />
224 <section name="sec_annofile">
225 <conditional name="annofile">
226 <param name="anno_fmt" value="vcf" />
227 <param name="annotations" value="annots.vcf" />
228 </conditional>
229 <param name="columns" value="STR,ID,QUAL,FILTER" />
230 </section>
231 <param name="output_type" value="v" />
232 <output name="output_file">
233 <assert_contents>
234 <has_text text="idIndel" />
235 <has_text text="STR=testSNP" />
236 </assert_contents>
237 </output>
238 </test>
239 <test>
240 <param name="input_file" ftype="vcf" value="annotate.vcf" />
241 <section name="sec_annofile">
242 <conditional name="annofile">
243 <param name="anno_fmt" value="vcf" />
244 <param name="annotations" value="annots.bcf" />
245 </conditional>
246 <param name="columns" value="STR,ID,QUAL,FILTER" />
247 </section>
248 <param name="output_type" value="v" />
249 <output name="output_file">
250 <assert_contents>
251 <has_text text="idIndel" />
252 <has_text text="STR=testSNP" />
253 </assert_contents>
254 </output>
255 </test>
256 <test>
257 <param name="input_file" ftype="vcf" value="annotate2.vcf" />
258 <section name="sec_annofile">
259 <conditional name="annofile">
260 <param name="anno_fmt" value="vcf" />
261 <param name="annotations" value="annots2.vcf" />
262 </conditional>
263 <param name="columns" value="ID,QUAL,FILTER,INFO,FMT" />
264 </section>
265 <param name="output_type" value="v" />
266 <output name="output_file">
267 <assert_contents>
268 <has_text text="q99" />
269 <has_text text="FLAG;IINT=88,99;IFLT=8.8,9.9;ISTR=888,999" />
270 </assert_contents>
271 </output>
272 </test>
273 <test>
274 <param name="input_file" ftype="vcf" value="annotate2.vcf" />
275 <section name="sec_annofile">
276 <conditional name="annofile">
277 <param name="anno_fmt" value="vcf" />
278 <param name="annotations" value="annots2.vcf" />
279 </conditional>
280 <param name="columns" value="ID,QUAL,FILTER,INFO,FMT" />
281 </section>
282 <section name="sec_restrict">
283 <param name="samples" value="A" />
284 </section>
285 <param name="output_type" value="v" />
286 <output name="output_file">
287 <assert_contents>
288 <has_text text="q11" />
289 <has_text text="FLAG;IINT=88,99;IFLT=8.8,9.9;ISTR=888,999" />
290 </assert_contents>
291 </output>
292 </test>
293 <test>
294 <param name="input_file" ftype="vcf" value="annotate3.vcf" />
295 <section name="sec_annofile">
296 <conditional name="annofile">
297 <param name="anno_fmt" value="none" />
298 </conditional>
299 </section>
300 <section name="sec_annotate">
301 <param name="remove" value="ID,QUAL,^FILTER/fltA,FILTER/fltB,^INFO/AA,INFO/BB,^FMT/GT,FMT/PL" />
302 </section>
303 <param name="output_type" value="v" />
304 <output name="output_file">
305 <assert_contents>
306 <not_has_text text="fltY" />
307 </assert_contents>
308 </output>
309 </test>
310 <test>
311 <param name="input_file" ftype="vcf" value="annotate3.vcf" />
312 <section name="sec_annofile">
313 <conditional name="annofile">
314 <param name="anno_fmt" value="none" />
315 </conditional>
316 </section>
317 <section name="sec_annotate">
318 <param name="remove" value="FORMAT" />
319 </section>
320 <param name="output_type" value="v" />
321 <output name="output_file">
322 <assert_contents>
323 <not_has_text text="GT:X:PL:Y:AA" />
324 </assert_contents>
325 </output>
326 </test>
327 <!-- Test region overlap option -->
328 <test>
329 <param name="input_file" ftype="vcf" value="annotate3.vcf" />
330 <section name="sec_annofile">
331 <conditional name="annofile">
332 <param name="anno_fmt" value="none" />
333 </conditional>
334 </section>
335 <section name="sec_annotate">
336 <param name="remove" value="FORMAT" />
337 </section>
338 <param name="output_type" value="v" />
339 <section name="sec_restrict">
340 <conditional name="regions">
341 <param name="regions_src" value="regions" />
342 <repeat name="region_specs">
343 <param name="chrom" value="1" />
344 </repeat>
345 </conditional>
346 </section>
347 <output name="output_file">
348 <assert_contents>
349 <not_has_text text="GT:X:PL:Y:AA" />
350 </assert_contents>
351 </output>
352 <assert_command>
353 <has_text text="--regions-overlap" />
354 </assert_command>
355 </test>
356 <!-- Test min overlap option -->
357 <test>
358 <param name="input_file" ftype="vcf" value="annotate3.vcf" />
359 <section name="sec_annofile">
360 <conditional name="annofile">
361 <param name="anno_fmt" value="none" />
362 </conditional>
363 <param name="min_overlap" value="0.5"/>
364 </section>
365 <section name="sec_annotate">
366 <param name="remove" value="FORMAT" />
367 </section>
368 <param name="output_type" value="v" />
369 <output name="output_file">
370 <assert_contents>
371 <not_has_text text="GT:X:PL:Y:AA" />
372 </assert_contents>
373 </output>
374 <assert_command>
375 <has_text text="--min-overlap" />
376 </assert_command>
377 </test>
378 </tests>
379 <help><![CDATA[
380==================================
381 bcftools @EXECUTABLE@
382==================================
383
384Annotate and edit VCF/BCF files.
385
386Examples:
387
388 # Remove three fields
389 bcftools annotate -x ID,INFO/DP,FORMAT/DP file.vcf.gz
390
391 # Remove all INFO fields and all FORMAT fields except for GT and PL
392 bcftools annotate -x INFO,^FORMAT/GT,FORMAT/PL file.vcf
393
394 # Add ID, QUAL and INFO/TAG, not replacing TAG if already present
395 bcftools annotate -a src.bcf -c ID,QUAL,+TAG dst.bcf
396
397 # Carry over all INFO and FORMAT annotations except FORMAT/GT
398 bcftools annotate -a src.bcf -c INFO,^FORMAT/GT dst.bcf
399
400 # Annotate from a tab-delimited file with six columns (the fifth is ignored),
401 # first indexing with tabix. The coordinates are 1-based.
402 tabix -s1 -b2 -e2 annots.tab.gz
403 bcftools annotate -a annots.tab.gz -h annots.hdr -c CHROM,POS,REF,ALT,-,TAG file.vcf
404
405 # Annotate from a tab-delimited file with regions (1-based coordinates, inclusive)
406 tabix -s1 -b2 -e3 annots.tab.gz
407 bcftools annotate -a annots.tab.gz -h annots.hdr -c CHROM,FROM,TO,TAG inut.vcf
408
409 # Annotate from a bed file (0-based coordinates, half-closed, half-open intervals)
410 bcftools annotate -a annots.bed.gz -h annots.hdr -c CHROM,FROM,TO,TAG input.vcf
411
412@REGIONS_HELP@
413@EXPRESSIONS_HELP@
414
415@BCFTOOLS_MANPAGE@#@EXECUTABLE@
416
417@BCFTOOLS_HOWTOS@
418]]>
419 </help>
420 <expand macro="citations" />
421</tool>