comparison cut.xml @ 0:5314e5d6f040 draft

Imported from capsule None
author bgruening
date Thu, 29 Jan 2015 07:53:17 -0500
parents
children 37e1eb05b1b4
comparison
equal deleted inserted replaced
-1:000000000000 0:5314e5d6f040
1 <tool id="tp_cut_tool" name="Cut" version="@BASE_VERSION@.0">
2 <description>columns from a table</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="requirements" />
7 <version_command>cut --version | head -n 1</version_command>
8 <command>
9 <![CDATA[
10 cut
11 #if str($delimiter) != '':
12 -d"${delimiter}"
13 #end if
14 ${complement}
15 ${cut_type_options.cut_element}
16 '${cut_type_options.list}'
17 '${input}'
18 > '${output}'
19 ]]>
20 </command>
21 <inputs>
22 <param name="input" format="txt" type="data" label="File to cut" />
23 <param name="complement" type="select" label="Operation">
24 <option value="">Keep</option>
25 <option value="--complement">Discard</option>
26 </param>
27 <param name="delimiter" type="select" label="Delimited by">
28 <option value="">Tab</option>
29 <option value=" ">Whitespace</option>
30 <option value=".">Dot</option>
31 <option value=",">Comma</option>
32 <option value="-">Dash</option>
33 <option value="_">Underscore</option>
34 <option value="|">Pipe</option>
35 </param>
36 <conditional name="cut_type_options">
37 <param name="cut_element" type="select" label="Cut by">
38 <option value="-f">fields</option>
39 <option value="-c">characters</option>
40 <option value="-b">bytes</option>
41 </param>
42 <when value="-f">
43 <param name="list" type="data_column" data_ref="input" multiple="true" label="List of Fields" help="(-f)" />
44 </when>
45 <when value="-c">
46 <param name="list" type="text" size="20" value="" label="List of characters" help="These will be kept/discarded (depending on 'operation'). &lt;BR /&gt; Examples: 1,3,4 or 2-5">
47 <sanitizer>
48 <valid initial="string.printable">
49 <remove value="&apos;"/>
50 </valid>
51 </sanitizer>
52 </param>
53 </when>
54 <when value="-b">
55 <param name="list" type="text" size="20" value="" label="List of Bytes" help="These will be kept/discarded (depending on 'operation'). &lt;BR /&gt; Examples: 1,3,4 or 2-5">
56 <sanitizer>
57 <valid initial="string.printable">
58 <remove value="&apos;"/>
59 </valid>
60 </sanitizer>
61 </param>
62 </when>
63 </conditional>
64 </inputs>
65 <outputs>
66 <!--<data format="tabular" name="output" />-->
67 <!-- WIP, not sure that will work with the complement option -->
68 <data format="tabular" name="output">
69 <actions>
70 <conditional name="cut_type_options.cut_element">
71 <!-- fields -->
72 <when value="-f">
73 <conditional name="delimiter">
74 <when value="T">
75 <conditional name="input">
76 <when datatype_isinstance="interval">
77 <action type="format" default="tabular">
78 <option type="from_param" name="list" column="0" offset="0"> <!-- chromCol is 1-->
79 <filter type="insert_column" column="0" value="interval"/>
80 <filter type="insert_column" ref="list" /> <!-- startCol -->
81 <filter type="insert_column" ref="list" /> <!-- endCol -->
82
83 <filter type="multiple_splitter" column="1" separator=","/>
84 <filter type="column_strip" column="1"/> <!-- get rid of all external whitespace -->
85 <filter type="string_function" column="1" name="lower" />
86 <filter type="param_value" column="1" value="^c\d{1,}$" compare="re_search" keep="True"/>
87 <filter type="column_strip" column="1" strip="c"/> <!-- get rid of c's -->
88 <filter type="boolean" column="1" cast="int" />
89
90 <filter type="multiple_splitter" column="2" separator=","/>
91 <filter type="column_strip" column="2"/> <!-- get rid of all external whitespace -->
92 <filter type="string_function" column="2" name="lower" />
93 <filter type="param_value" column="2" value="^c\d{1,}$" compare="re_search" keep="True"/>
94 <filter type="column_strip" column="2" strip="c"/> <!-- get rid of c's -->
95 <filter type="boolean" column="2" cast="int" />
96
97 <filter type="multiple_splitter" column="3" separator=","/>
98 <filter type="column_strip" column="3"/> <!-- get rid of all external whitespace -->
99 <filter type="string_function" column="3" name="lower" />
100 <filter type="param_value" column="3" value="^c\d{1,}$" compare="re_search" keep="True"/>
101 <filter type="column_strip" column="3" strip="c"/> <!-- get rid of c's -->
102 <filter type="boolean" column="3" cast="int" />
103
104 <filter type="metadata_value" ref="input" name="chromCol" column="1" />
105 <filter type="metadata_value" ref="input" name="startCol" column="2" />
106 <filter type="metadata_value" ref="input" name="endCol" column="3" />
107 </option>
108 </action>
109 <conditional name="output">
110 <when datatype_isinstance="interval">
111 <action type="metadata" name="chromCol">
112 <option type="from_param" name="list" column="0" offset="0"> <!-- chromCol is 0-->
113 <filter type="multiple_splitter" column="0" separator=","/>
114 <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
115 <filter type="string_function" column="0" name="lower" />
116 <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
117 <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
118 <filter type="insert_column" value="1" iterate="True" column="0"/>
119 <filter type="boolean" column="1" cast="int" />
120 <filter type="metadata_value" ref="input" name="chromCol" column="1" />
121 </option>
122 </action>
123
124 <action type="metadata" name="startCol">
125 <option type="from_param" name="list" column="0" offset="0"> <!-- startCol is 0-->
126 <filter type="multiple_splitter" column="0" separator=","/>
127 <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
128 <filter type="string_function" column="0" name="lower" />
129 <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
130 <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
131 <filter type="insert_column" value="1" iterate="True" column="0"/>
132 <filter type="boolean" column="1" cast="int" />
133 <filter type="metadata_value" ref="input" name="startCol" column="1" />
134 </option>
135 </action>
136
137 <action type="metadata" name="endCol">
138 <option type="from_param" name="list" column="0" offset="0"> <!-- endCol is 0-->
139 <filter type="multiple_splitter" column="0" separator=","/>
140 <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
141 <filter type="string_function" column="0" name="lower" />
142 <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
143 <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
144 <filter type="insert_column" value="1" iterate="True" column="0"/>
145 <filter type="boolean" column="1" cast="int" />
146 <filter type="metadata_value" ref="input" name="endCol" column="1" />
147 </option>
148 </action>
149
150 <action type="metadata" name="nameCol" default="0">
151 <option type="from_param" name="list" column="0" offset="0"> <!-- nameCol is 0-->
152 <filter type="multiple_splitter" column="0" separator=","/>
153 <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
154 <filter type="string_function" column="0" name="lower" />
155 <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
156 <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
157 <filter type="insert_column" value="1" iterate="True" column="0"/>
158 <filter type="boolean" column="1" cast="int" />
159 <filter type="metadata_value" ref="input" name="nameCol" column="1" />
160 </option>
161 </action>
162
163 <action type="metadata" name="strandCol" default="0">
164 <option type="from_param" name="list" column="0" offset="0"> <!-- strandCol is 0-->
165 <filter type="multiple_splitter" column="0" separator=","/>
166 <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
167 <filter type="string_function" column="0" name="lower" />
168 <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
169 <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
170 <filter type="insert_column" value="1" iterate="True" column="0"/>
171 <filter type="boolean" column="1" cast="int" />
172 <filter type="metadata_value" ref="input" name="strandCol" column="1" />
173 </option>
174 </action>
175 </when>
176 </conditional>
177 </when>
178 </conditional>
179 </when>
180 </conditional>
181 </when>
182 </conditional>
183 </actions>
184 </data>
185 </outputs>
186 <tests>
187 <test>
188 <param name="input" value="cut1.txt"/>
189 <param name="list" value="1,3,4"/>
190 <param name="delimiter" value=""/>
191 <output name="output" file="cut_results1.txt"/>
192 </test>
193 <test>
194 <param name="input" value="cut1.txt"/>
195 <param name="list" value="2" />
196 <param name="delimiter" value="" />
197 <param name="complement" value="--complement" />
198 <output name="output" file="cut_results2.txt"/>
199 </test>
200 <test>
201 <param name="input" value="cut1.txt"/>
202 <param name="list" value="-3" />
203 <param name="delimiter" value="" />
204 <param name="cut_element" value="-c" />
205 <output name="output" file="cut_results3.txt"/>
206 </test>
207 </tests>
208 <help>
209 <![CDATA[
210 **What it does**
211
212 This tool runs the **cut** unix command, which extract or delete columns from a file.
213
214 -----
215
216 Field List Example:
217
218 **1,3,7** - Cut specific fields/characters.
219
220 **3-** - Cut from the third field/character to the end of the line.
221
222 **2-5** - Cut from the second to the fifth field/character.
223
224 **-8** - Cut from the first to the eight field/characters.
225
226
227 Input Example::
228
229 fruit color price weight
230 apple red 1.4 0.5
231 orange orange 1.5 0.3
232 banana yellow 0.9 0.3
233
234
235 Output Example ( **Keeping fields 1,3,4** )::
236
237 fruit price weight
238 apple 1.4 0.5
239 orange 1.5 0.3
240 banana 0.9 0.3
241
242 Output Example ( **Discarding field 2** )::
243
244 fruit price weight
245 apple 1.4 0.5
246 orange 1.5 0.3
247 banana 0.9 0.3
248
249 Output Example ( **Keeping 3 characters** )::
250
251 fru
252 app
253 ora
254 ban
255
256 @REFERENCES@
257 ]]>
258 </help>
259 </tool>