-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreheader.xml
300 lines (286 loc) · 12.9 KB
/
reheader.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<tool id="mimodd_reheader" name="MiModD Reheader" version="@MIMODD_WRAPPER_VERSION@">
<description>
takes a BAM file and generates a copy with the original header (if any) replaced or modified by that found in a template SAM file
</description>
<macros>
<import>macros.xml</import>
<macro name="getreadgroupinfo">
<conditional name="rginfo">
<param name="source" type="select"
label="source of new read-group information">
<option value="from_file">existing SAM file</option>
<option value="from_form">input form</option>
</param>
<when value="from_file">
<param name="data" type="data" format="sam"
label="read-group template file in SAM format"
help="use the read group information found in this file" />
<repeat name="rg" title="custom read-group mapping" default="0" min="0"
help="read-group information found in the input file, by default, gets updated / replaced with information from template file read-groups with matching IDs. Alternatively, you may specify explicit read-group mappings below.">
<param name="source_id" type="text"
label="modify input file information for read-group ID (will create the read-group if it does not exist)" />
<param name="rg_id" type="text"
label="with template file information for read-group ID" />
</repeat>
</when>
<when value="from_form">
<repeat name="rg" title="new read-group info" default="1" min="1">
<param name="source_id" type="text"
label="read-group ID (will create the read-group if it does not exist)"
help="required field">
<validator type="empty_field" />
<expand macro="lex_sam_header" />
</param>
<param name="rg_id" type="hidden" value="" />
<param name="rg_sm" type="text" label="sample name"
help="required field">
<validator type="empty_field" />
<expand macro="lex_sam_header" />
</param>
<param name="rg_ds" type="text" label="description">
<expand macro="lex_sam_header" />
</param>
<param name="rg_date" type="text"
label="date (YY-MM-DD format) the run was produced">
<expand macro="YYYY-MM-DD_format_validator" />
</param>
<param name="rg_cn" type="text"
label="name of sequencing center">
<expand macro="lex_sam_header" />
</param>
<param name="rg_lb" type="text" label="read-group library">
<expand macro="lex_sam_header" />
</param>
<param name="rg_pl" type="text"
label="platform/technology used to produce the reads">
<expand macro="known_sequencing_platform options" />
<expand macro="lex_sam_header" />
</param>
<param name="rg_pi" type="text"
label="predicted median insert size">
<validator type="expression" message="an integer number is required">not value or value.isdigit()</validator>
</param>
<param name="rg_pu" type="text"
label="platform unit; unique identifier">
<expand macro="lex_sam_header" />
</param>
</repeat>
</when>
</conditional>
</macro>
</macros>
<expand macro="requirements" />
<expand macro="stdio" />
<expand macro="version_command" />
<command><![CDATA[
#if ($str($rg.treat_rg) != "ignore" and $str($rg.rginfo.source) == "from_form") or $str($co.treat_co) != "ignore":
mimodd header
#if $str($rg.treat_rg) != "ignore" and $str($rg.rginfo.source) == "from_form":
#for $rginfo in $rg.rginfo.rg
#if $str($rginfo.source_id):
--rg-id '${rginfo.source_id}'
#end if
#if $str($rginfo.rg_sm):
--rg-sm '${rginfo.rg_sm}'
#end if
#if $str($rginfo.rg_cn):
--rg-cn '${rginfo.rg_cn}'
#else:
--rg-cn ""
#end if
#if $str($rginfo.rg_ds):
--rg-ds '${rginfo.rg_ds}'
#else:
--rg-ds ""
#end if
#if $str($rginfo.rg_date):
--rg-dt '${rginfo.rg_date}'
#else:
--rg-dt ""
#end if
#if $str($rginfo.rg_lb):
--rg-lb '${rginfo.rg_lb}'
#else:
--rg-lb ""
#end if
#if $str($rginfo.rg_pl):
--rg-pl '${rginfo.rg_pl}'
#else:
--rg-pl ""
#end if
#if $str($rginfo.rg_pi):
--rg-pi '${rginfo.rg_pi}'
#else:
--rg-pi ""
#end if
#if $str($rginfo.rg_pu):
--rg-pu '${rginfo.rg_pu}'
#else:
--rg-pu ""
#end if
#end for
#end if
#if $str($co.treat_co) != "ignore":
--co
#for $comment in $co.coinfo
#if $str($comment.line):
'${comment.line}'
#end if
#end for
#end if
|
#end if
mimodd reheader '$inputfile' --sq ignore --rg ${rg.treat_rg}
#if $str($rg.treat_rg) != "ignore":
#if $str($rg.rginfo.source) == "from_file":
'${rg.rginfo.data}'
#else:
-
#end if
#for $rgmapping in $rg.rginfo.rg
#if $str($rgmapping.source_id) and $str($rgmapping.rg_id):
'$str($rgmapping.source_id)' : '$str($rgmapping.rg_id)'
#end if
#end for
#end if
--co ${co.treat_co}
#if $str($co.treat_co) != "ignore":
-
#end if
#set $restr = ""
#for $rename in $rg_renaming
#set $restr = $restr + ($str($rename.from) and $str($rename.to) and "'" + $str($rename.from) + "' : '" + $str($rename.to) + "' ")
#end for
#if $restr
--rgm $restr
#end if
#set $restr = ""
#for $rename in $sq_renaming
#set $restr = $restr + ($str($rename.from) and $str($rename.to) and "'" + $str($rename.from) + "' : '" + $str($rename.to) + "' ")
#end for
#if $restr
--sqm $restr
#end if
-o '$output'
]]></command>
<inputs>
<param name="inputfile" type="data" format="bam"
label="input dataset in BAM format" help="the file to reheader." />
<conditional name="rg">
<param name="treat_rg" type="select"
label="modify read-group information?"
help="Replace mode will ignore ALL existing read group information in the input file and use ONLY template information, Update mode will COPY existing input file information and UPDATE it with template information; choose No, ... to leave read-group information alone.">
<option value="ignore">No, do not change read-groups.</option>
<option value="update">Yes, update existing information</option>
<option value="replace">Yes, replace existing information</option>
</param>
<when value="update">
<expand macro="getreadgroupinfo" />
</when>
<when value="replace">
<expand macro="getreadgroupinfo" />
</when>
<when value="ignore">
</when>
</conditional>
<conditional name="co">
<param name="treat_co" type="select"
label="modify comments in the input file?">
<option value="ignore">No, do not change comments.</option>
<option value="update">Yes, append new comments to existing ones</option>
<option value="replace">Yes, replace all existing comments</option>
</param>
<when value="update">
<repeat name="coinfo" title="comment line" default="0" min="0">
<param name="line" type="text" size="80">
<expand macro="lex_sam_header" />
</param>
</repeat>
</when>
<when value="replace">
<repeat name="coinfo" title="comment line" default="0" min="0">
<param name="line" type="text" size="80">
<expand macro="lex_sam_header" />
</param>
</repeat>
</when>
<when value="ignore">
</when>
</conditional>
<repeat name="rg_renaming" title="rename read-group" default="0" min="0"
help="Warning: changing read-group IDs may increase job runtime substantially.">
<param name="from" type="text" size="30" label="old name"
help="as it appears in the current input file header">
<expand macro="lex_sam_header" />
</param>
<param name="to" type="text" size="30" label="new name">
<expand macro="lex_sam_header" />
</param>
</repeat>
<repeat name="sq_renaming" title="rename sequence" default="0" min="0"
help="Warning: changing sequence names may increase job runtime substantially.">
<param name="from" type="text" size="30" label="old name"
help="as it appears in the current input file header">
<expand macro="lex_sam_header" />
</param>
<param name="to" type="text" size="30" label="new name">
<validator type="expression" message="Sequence names may not contain non-ASCII, whitespace, non-printable characters, nor any of: <>[]*;=,">all((32 < ord(c) < 127 and c not in '<>[]*;=,') for c in value)</validator>
<expand macro="lex_sam_header" />
</param>
</repeat>
</inputs>
<outputs>
<data name="output" format="bam"
label="(Re)headered bam file from MiModd ${tool.name} on ${on_string}" />
</outputs>
<tests>
<test>
<param name="inputfile" value="a.bam" />
<conditional name="co">
<param name="treat_co" value="update" />
<repeat name="coinfo">
<param name="line" value="ceterum censeo ..." />
</repeat>
</conditional>
<output name="output" file="a.bam" ftype="bam" lines_diff="1" />
</test>
<test>
<param name="inputfile" value="header_only.bam" />
<conditional name="rg">
<param name="treat_rg" value="update" />
<conditional name="rginfo">
<param name="source" value="from_form" />
<repeat name="rg">
<param name="source_id" value="000" />
<param name="rg_sm" value="Bristol" />
</repeat>
</conditional>
</conditional>
<output name="output" file="header_only.bam" ftype="bam" lines_diff="2" />
</test>
<test>
<param name="inputfile" value="header_only.bam" />
<conditional name="rg">
<param name="treat_rg" value="update" />
<conditional name="rginfo">
<param name="source" value="from_form" />
<repeat name="rg">
<param name="source_id" value="001" />
<param name="rg_sm" value="Hawaiian" />
</repeat>
</conditional>
</conditional>
<output name="output" file="header_only.bam" ftype="bam" lines_diff="1" />
</test>
</tests>
<help><![CDATA[
.. class:: infomark
**What it does**
The tool generates a copy of the BAM input file with a modified header (i.e., metadata).
It can update or replace read-group information (i.e., information about the samples in the file), add or replace comment lines, and rename reference sequences declared in the header.
The tool ensures that the resulting BAM file is valid and can be further processed by other MiModD tools and standard software like samtools. It aborts with an error message if a valid BAM file cannot be generated with the user-specified settings.
The template information used to modify or replace the input file metadata is provided through forms or, in the case of read-group information, can be taken from an existing SAM file as can be generated, for example, with the *NGS Run Annotation* tool.
@HELP_FOOTER@
]]></help>
<expand macro="citations" />
</tool>