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