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