upstream-extended/iuc/tools/bcftools/bcftools_reheader.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>Modify header of VCF/BCF files, change sample names</description>
4 <macros>
5 <token name="@EXECUTABLE@">reheader</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@
13bcftools @EXECUTABLE@
14
15#set $section = $sec_default
16
17#if $section.header:
18 --header "${section.header}"
19#end if
20
21#if $section.rename_samples.samples_src == 'history':
22 --samples "${section.rename_samples.sample_file}"
23#elif $section.rename_samples.samples_src == 'entry':
24 --samples "${entered_sample_file}"
25#end if
26
27## Primary Input/Outputs
28@INPUT_FILE@
29| bcftools view
30@OUTPUT_TYPE@
31> '$output_file'
32]]>
33 </command>
34 <configfiles>
35 <configfile name="entered_sample_file"><![CDATA[#slurp
36#if $sec_default.rename_samples.samples_src == 'entry'
37$sec_default.rename_samples.sample_lines.__str__.strip()#slurp
38#end if]]></configfile>
39 </configfiles>
40
41 <inputs>
42 <expand macro="macro_input" />
43 <section name="sec_default" expanded="true" title="Default Options">
44 <param name="header" type="data" format="vcf" label="Header" optional="True" help="New header" />
45 <conditional name="rename_samples">
46 <param name="samples_src" type="select" label="New Sample names">
47 <help><![CDATA[
48 New sample names, one name per line, in the same order as they appear in the VCF file.
49 Alternatively, only samples which need to be renamed can be listed as
50 "old_name new_name" pairs separated by whitespaces, each on separate line.
51 ]]></help>
52 <option value="none">Do not change</option>
53 <option value="history">From your history</option>
54 <option value="entry">From text input</option>
55 </param>
56 <when value="none"/>
57 <when value="history">
58 <param name="sample_file" type="data" format="tabular" label="Samples file"/>
59 </when>
60 <when value="entry">
61 <param name="sample_lines" type="text" area="True" label="Samples text entry" >
62 <validator type="regex" message="Either one name per line, or old new sample names per line">^((\S+(\n\S+))|(\S+[ \t]\S+(\n\S+[ \t]\S+)*))$</validator>
63 <sanitizer sanitize="False"/>
64 </param>
65 </when>
66 </conditional>
67 </section>
68 <expand macro="macro_select_output_type" />
69 </inputs>
70 <outputs>
71 <expand macro="macro_vcf_output"/>
72 </outputs>
73 <tests>
74 <test>
75 <param name="input_file" ftype="vcf" value="reheader.vcf" />
76 <section name="sec_default">
77 <param name="header" ftype="vcf" value="reheader.hdr" />
78 </section>
79 <param name="output_type" value="v" />
80 <output name="output_file">
81 <assert_contents>
82 <has_text text="##fileformat=VCFv4.2" />
83 <has_text text="AAA0001" />
84 <not_has_text text="XY00001" />
85 </assert_contents>
86 </output>
87 </test>
88 <test>
89 <param name="input_file" ftype="vcf" value="reheader.vcf" />
90 <section name="sec_default">
91 <conditional name="rename_samples">
92 <param name="samples_src" value="history" />
93 <param name="sample_file" ftype="tabular" value="reheader.samples" />
94 </conditional>
95 </section>
96 <param name="output_type" value="v" />
97 <output name="output_file">
98 <assert_contents>
99 <not_has_text text="XY00001" />
100 <has_text_matching expression="FORMAT\tAAA\tBBB"/>
101 </assert_contents>
102 </output>
103 </test>
104 <test>
105 <param name="input_file" ftype="vcf" value="reheader.vcf" />
106 <section name="sec_default">
107 <conditional name="rename_samples">
108 <param name="samples_src" value="history" />
109 <param name="sample_file" ftype="tabular" value="reheader.samples2" />
110 </conditional>
111 </section>
112 <param name="output_type" value="v" />
113 <output name="output_file">
114 <assert_contents>
115 <not_has_text text="XY00001" />
116 <has_text_matching expression="FORMAT\tAAA\tBBB"/>
117 </assert_contents>
118 </output>
119 </test>
120 <!--
121 <test>
122 <param name="input_file" ftype="vcf" value="reheader.vcf" />
123 <param name="samples_src" value="entry" />
124 <param name="sample_lines" value="AAA\nBBB" />
125 <param name="output_type" value="v" />
126 <output name="output_file">
127 <assert_contents>
128 <not_has_text text="XY00001" />
129 <has_text_matching expression="FORMAT\tAAA\tBBB"/>
130 </assert_contents>
131 </output>
132 </test>
133 <test>
134 <param name="input_file" ftype="vcf" value="reheader.vcf" />
135 <param name="samples_src" value="entry" />
136 <param name="sample_lines" value="XY00002 BBB\nXY00001 AAA" />
137 <param name="output_type" value="v" />
138 <output name="output_file">
139 <assert_contents>
140 <not_has_text text="XY00001" />
141 <has_text_matching expression="FORMAT\tAAA\tBBB"/>
142 </assert_contents>
143 </output>
144 </test>
145 -->
146 </tests>
147 <help><![CDATA[
148=====================================
149 bcftools @EXECUTABLE@
150=====================================
151
152Modify header of VCF/BCF files, change sample names.
153
154@BCFTOOLS_MANPAGE@#@EXECUTABLE@
155
156@BCFTOOLS_HOWTOS@
157]]>
158 </help>
159 <expand macro="citations" />
160</tool>