6
|
1 <tool id="reheader" name="Reheader BAM file" version="0.1.7.0">
|
0
|
2 <description>From a BAM file generate a new file with the original header (if any) replaced or modified by that found in a second SAM file</description>
|
2
|
3 <expand macro="requirements"/>
|
0
|
4 <version_command>mimodd version -q</version_command>
|
|
5 <command>
|
|
6 #if ($str($rg.treat_rg) != "ignore" and $str($rg.rginfo.source) == "from_form") or $str($co.treat_co) != "ignore":
|
|
7 mimodd header
|
|
8 #if $str($rg.treat_rg) != "ignore" and $str($rg.rginfo.source) == "from_form":
|
|
9 #for $rginfo in $rg.rginfo.rg
|
|
10 #if $str($rginfo.source_id):
|
|
11 --rg-id "${rginfo.source_id}"
|
|
12 #end if
|
|
13 #if $str($rginfo.rg_sm):
|
|
14 --rg-sm "${rginfo.rg_sm}"
|
|
15 #end if
|
|
16 #if $str($rginfo.rg_cn):
|
|
17 --rg-cn "${rginfo.rg_cn}"
|
|
18 #else:
|
|
19 --rg-cn ""
|
|
20 #end if
|
|
21 #if $str($rginfo.rg_ds):
|
|
22 --rg-ds "${rginfo.rg_ds}"
|
|
23 #else:
|
|
24 --rg-ds ""
|
|
25 #end if
|
|
26 #if $str($rginfo.rg_date):
|
|
27 --rg-dt "${rginfo.rg_date}"
|
|
28 #else:
|
|
29 --rg-dt ""
|
|
30 #end if
|
|
31 #if $str($rginfo.rg_lb):
|
|
32 --rg-lb "${rginfo.rg_lb}"
|
|
33 #else:
|
|
34 --rg-lb ""
|
|
35 #end if
|
|
36 #if $str($rginfo.rg_pl):
|
|
37 --rg-pl "${rginfo.rg_pl}"
|
|
38 #else:
|
|
39 --rg-pl ""
|
|
40 #end if
|
|
41 #if $str($rginfo.rg_pi):
|
|
42 --rg-pi "${rginfo.rg_pi}"
|
|
43 #else:
|
|
44 --rg-pi ""
|
|
45 #end if
|
|
46 #if $str($rginfo.rg_pu):
|
|
47 --rg-pu "${rginfo.rg_pu}"
|
|
48 #else:
|
|
49 --rg-pu ""
|
|
50 #end if
|
|
51 #end for
|
|
52 #end if
|
|
53 #if $str($co.treat_co) != "ignore":
|
|
54 --co
|
|
55 #for $comment in $co.coinfo
|
|
56 #if $str($comment.line):
|
|
57 "${comment.line}"
|
|
58 #end if
|
|
59 #end for
|
|
60 #end if
|
|
61 |
|
|
62 #end if
|
|
63 mimodd reheader "$inputfile" --sq ignore
|
|
64 --rg ${rg.treat_rg}
|
|
65 #if $str($rg.treat_rg) != "ignore":
|
|
66 #if $str($rg.rginfo.source) == "from_file":
|
|
67 "${rg.rginfo.data}"
|
|
68 #else:
|
|
69 -
|
|
70 #end if
|
|
71 #for $rgmapping in $rg.rginfo.rg
|
|
72 #if $str($rgmapping.source_id) and $str($rgmapping.rg_id):
|
|
73 "$str($rgmapping.source_id)" : "$str($rgmapping.rg_id)"
|
|
74 #end if
|
|
75 #end for
|
|
76 #end if
|
|
77
|
|
78 --co ${co.treat_co}
|
|
79 #if $str($co.treat_co) != "ignore":
|
|
80 -
|
|
81 #end if
|
|
82
|
|
83 #set $restr = ""
|
|
84 #for $rename in $rg_renaming
|
5
|
85 #set $restr = $restr + ($str($rename.from) and $str($rename.to) and '"' + $str($rename.from) + '" : "' + $str($rename.to) + '" ')
|
0
|
86 #end for
|
|
87 #if $restr
|
|
88 --rgm $restr
|
|
89 #end if
|
|
90
|
|
91 #set $restr = ""
|
|
92 #for $rename in $sq_renaming
|
5
|
93 #set $restr = $restr + ($str($rename.from) and $str($rename.to) and '"' + $str($rename.from) + '" : "' + $str($rename.to) + '" ')
|
0
|
94 #end for
|
|
95 #if $restr
|
|
96 --sqm $restr
|
|
97 #end if
|
|
98
|
|
99 -o "$output"
|
|
100 </command>
|
|
101
|
|
102 <macros>
|
3
|
103 <import>toolshed_macros.xml</import>
|
0
|
104 <macro name="getreadgroupinfo">
|
|
105 <conditional name="rginfo">
|
|
106 <param name="source" type="select" label="source of new read-group information" help="">
|
|
107 <option value="from_file">existing SAM file</option>
|
|
108 <option value="from_form">input form</option>
|
|
109 </param>
|
|
110 <when value="from_file">
|
|
111 <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" />
|
|
112 <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.">
|
|
113 <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)" />
|
|
114 <param name="rg_id" type="text" label="with template file information for read-group ID" />
|
|
115 </repeat>
|
|
116 </when>
|
|
117 <when value="from_form">
|
|
118 <repeat name="rg" title="new read-group info" default="1" min="1">
|
|
119 <param name="source_id" type="text" label="read-group ID (will create the read-group if it does not exist)" help="required field" />
|
|
120 <param name="rg_id" type="hidden" value="" />
|
|
121 <param name="rg_sm" type="text" label="sample name" help="required field" />
|
|
122 <param name="rg_ds" type="text" label="description" />
|
|
123 <param name="rg_date" type="text" label="date (YY-MM-DD format) the run was produced" />
|
|
124 <param name="rg_cn" type="text" label="name of sequencing center" />
|
|
125 <param name="rg_lb" type="text" label="read-group library" />
|
|
126 <param name="rg_pl" type="text" label="platform/technology used to produce the reads" />
|
|
127 <param name="rg_pi" type="text" label="predicted median insert size" />
|
|
128 <param name="rg_pu" type="text" label="platform unit; unique identifier" />
|
|
129 </repeat>
|
|
130 </when>
|
|
131 </conditional>
|
|
132 </macro>
|
|
133 </macros>
|
|
134
|
|
135 <inputs>
|
|
136
|
|
137 <param name="inputfile" type="data" format="bam" label="input file in BAM format" help="the file to reheader." />
|
|
138
|
|
139 <conditional name="rg">
|
|
140 <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.">
|
|
141 <option value="ignore">No, do not change read-groups.</option>
|
|
142 <option value="update">Yes, update existing information</option>
|
|
143 <option value="replace">Yes, replace existing information</option>
|
|
144 </param>
|
|
145 <when value="update">
|
|
146 <expand macro="getreadgroupinfo" />
|
|
147 </when>
|
|
148 <when value="replace">
|
|
149 <expand macro="getreadgroupinfo" />
|
|
150 </when>
|
|
151 </conditional>
|
|
152
|
|
153 <conditional name="co">
|
|
154 <param name="treat_co" type="select" label="modify comments in the input file ?" help="">
|
|
155 <option value="ignore">No, do not change comments.</option>
|
|
156 <option value="update">Yes, append new comments to existing ones</option>
|
|
157 <option value="replace">Yes, replace all existing comments</option>
|
|
158 </param>
|
|
159 <when value="update">
|
|
160 <repeat name="coinfo" title="comment line" default="0" min="0">
|
|
161 <param name="line" type="text" size="80" />
|
|
162 </repeat>
|
|
163 </when>
|
|
164 <when value="replace">
|
|
165 <repeat name="coinfo" title="comment line" default="0" min="0">
|
|
166 <param name="line" type="text" size="80" />
|
|
167 </repeat>
|
|
168 </when>
|
|
169 </conditional>
|
|
170
|
|
171 <repeat name="rg_renaming" title="rename read-group" default="0" min="0" help="Warning: changing read-group IDs may increase job runtime substantially.">
|
|
172 <param name="from" type="text" size="30" label="old name" help="as it appears in the current input file header"/>
|
|
173 <param name="to" type="text" size="30" label="new name" />
|
|
174 </repeat>
|
|
175
|
|
176 <repeat name="sq_renaming" title="rename sequence" default="0" min="0" help="Warning: changing sequence names may increase job runtime substantially.">
|
|
177 <param name="from" type="text" size="30" label="old name" help="as it appears in the current input file header"/>
|
|
178 <param name="to" type="text" size="30" label="new name" />
|
|
179 </repeat>
|
|
180
|
|
181 </inputs>
|
|
182
|
|
183 <outputs>
|
|
184 <data name="output" format="bam" label="(Re)headered bam file from MiModd ${tool.name} on ${on_string}">
|
|
185 </data>
|
|
186 </outputs>
|
|
187
|
|
188 <help>
|
|
189 .. class:: infomark
|
|
190
|
|
191 **What it does**
|
|
192
|
|
193 The tool generates a copy of the BAM input file with a modified header (i.e., metadata).
|
|
194
|
|
195 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.
|
|
196
|
|
197 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.
|
|
198
|
|
199 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.
|
|
200
|
|
201 </help>
|
|
202 </tool>
|
|
203
|