Source code

Download source archive ↓

upstream/cut_columns/cutWrapper.xml

1<tool id="Cut1" name="Cut" version="1.0.2">
2  <description>columns from a table</description>
3  <command>
4    perl $__tool_directory__/cutWrapper.pl
5        "${input}"
6        "${columnList}"
7        "${delimiter}"
8        "${out_file1}"
9  </command>
10  <inputs>
11    <param name="columnList" type="text" value="c1,c2" label="Cut columns"/>
12    <param name="delimiter" type="select" label="Delimited by">
13      <option value="T">Tab</option>
14      <option value="Sp">Whitespace</option>
15      <option value="Dt">Dot</option>
16      <option value="C">Comma</option>
17      <option value="D">Dash</option>
18      <option value="U">Underscore</option>
19      <option value="P">Pipe</option>
20    </param>
21    <param format="txt" name="input" type="data" label="From"/>
22  </inputs>
23  <outputs>
24    <data format="tabular" name="out_file1" >
25      <actions>
26        <conditional name="delimiter">
27          <when value="T">
28            <conditional name="input">
29              <when datatype_isinstance="interval">
30                <action type="format" default="tabular">
31                  <option type="from_param" name="columnList" column="0" offset="0"> <!-- chromCol is 1-->
32
33                    <filter type="insert_column" column="0" value="interval"/>
34
35                    <filter type="insert_column" ref="columnList" /> <!-- startCol -->
36
37                    <filter type="insert_column" ref="columnList" /> <!-- endCol -->
38
39                    <filter type="multiple_splitter" column="1" separator=","/>
40                    <filter type="column_strip" column="1"/> <!-- get rid of all external whitespace -->
41                    <filter type="string_function" column="1" name="lower" />
42                    <filter type="param_value" column="1" value="^c\d{1,}$" compare="re_search" keep="True"/>
43                    <filter type="column_strip" column="1" strip="c"/> <!-- get rid of c's  -->
44                    <filter type="boolean" column="1" cast="int" />
45
46                    <filter type="multiple_splitter" column="2" separator=","/>
47                    <filter type="column_strip" column="2"/> <!-- get rid of all external whitespace -->
48                    <filter type="string_function" column="2" name="lower" />
49                    <filter type="param_value" column="2" value="^c\d{1,}$" compare="re_search" keep="True"/>
50                    <filter type="column_strip" column="2" strip="c"/> <!-- get rid of c's  -->
51                    <filter type="boolean" column="2" cast="int" />
52
53                    <filter type="multiple_splitter" column="3" separator=","/>
54                    <filter type="column_strip" column="3"/> <!-- get rid of all external whitespace -->
55                    <filter type="string_function" column="3" name="lower" />
56                    <filter type="param_value" column="3" value="^c\d{1,}$" compare="re_search" keep="True"/>
57                    <filter type="column_strip" column="3" strip="c"/> <!-- get rid of c's  -->
58                    <filter type="boolean" column="3" cast="int" />
59
60                    <filter type="metadata_value" ref="input" name="chromCol" column="1" />
61                    <filter type="metadata_value" ref="input" name="startCol" column="2" />
62                    <filter type="metadata_value" ref="input" name="endCol" column="3" />
63
64                  </option>
65                </action>
66
67                <conditional name="out_file1">
68                  <when datatype_isinstance="interval">
69                    <action type="metadata" name="chromCol">
70                      <option type="from_param" name="columnList" column="0" offset="0"> <!-- chromCol is 0-->
71                        <filter type="multiple_splitter" column="0" separator=","/>
72                        <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
73                        <filter type="string_function" column="0" name="lower" />
74                        <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
75                        <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
76                        <filter type="insert_column" value="1" iterate="True" column="0"/>
77                        <filter type="boolean" column="1" cast="int" />
78                        <filter type="metadata_value" ref="input" name="chromCol" column="1" />
79                      </option>
80                    </action>
81
82                    <action type="metadata" name="startCol">
83                      <option type="from_param" name="columnList" column="0" offset="0"> <!-- startCol is 0-->
84                        <filter type="multiple_splitter" column="0" separator=","/>
85                        <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
86                        <filter type="string_function" column="0" name="lower" />
87                        <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
88                        <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
89                        <filter type="insert_column" value="1" iterate="True" column="0"/>
90                        <filter type="boolean" column="1" cast="int" />
91                        <filter type="metadata_value" ref="input" name="startCol" column="1" />
92                      </option>
93                    </action>
94
95                    <action type="metadata" name="endCol">
96                      <option type="from_param" name="columnList" column="0" offset="0"> <!-- endCol is 0-->
97                        <filter type="multiple_splitter" column="0" separator=","/>
98                        <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
99                        <filter type="string_function" column="0" name="lower" />
100                        <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
101                        <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
102                        <filter type="insert_column" value="1" iterate="True" column="0"/>
103                        <filter type="boolean" column="1" cast="int" />
104                        <filter type="metadata_value" ref="input" name="endCol" column="1" />
105                      </option>
106                    </action>
107
108                    <action type="metadata" name="nameCol" default="0">
109                      <option type="from_param" name="columnList" column="0" offset="0"> <!-- nameCol is 0-->
110                        <filter type="multiple_splitter" column="0" separator=","/>
111                        <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
112                        <filter type="string_function" column="0" name="lower" />
113                        <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
114                        <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
115                        <filter type="insert_column" value="1" iterate="True" column="0"/>
116                        <filter type="boolean" column="1" cast="int" />
117                        <filter type="metadata_value" ref="input" name="nameCol" column="1" />
118                      </option>
119                    </action>
120
121                    <action type="metadata" name="strandCol" default="0">
122                      <option type="from_param" name="columnList" column="0" offset="0"> <!-- strandCol is 0-->
123                        <filter type="multiple_splitter" column="0" separator=","/>
124                        <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
125                        <filter type="string_function" column="0" name="lower" />
126                        <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
127                        <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
128                        <filter type="insert_column" value="1" iterate="True" column="0"/>
129                        <filter type="boolean" column="1" cast="int" />
130                        <filter type="metadata_value" ref="input" name="strandCol" column="1" />
131                      </option>
132                    </action>
133                  </when>
134                </conditional>
135
136              </when>
137            </conditional>
138          </when>
139        </conditional>
140      </actions>
141    </data>
142  </outputs>
143  <tests>
144    <test>
145      <param name="columnList" value="c1,c4,c2,c3"/>
146      <param name="delimiter" value="T"/>
147      <param name="input" value="1.bed"/>
148      <output name="out_file1" file="eq-cut.dat"/>
149    </test>
150    <test>
151      <param name="columnList" value="c1,c4,c2-c3" />
152      <param name="delimiter" value="T" />
153      <param name="input" value="1.bed" />
154      <output name="out_file1" file="eq-cut.dat" />
155    </test>
156  </tests>
157  <help>
158
159.. class:: warningmark
160
161**WARNING: This tool breaks column assignments.** To re-establish column assignments run the tools and click on the pencil icon in the latest history item.
162
163.. class:: infomark
164
165The output of this tool is always in tabular format (e.g., if your original delimiters are commas, they will be replaced with tabs). For example:
166
167  Cutting columns 1 and 3 from::
168
169     apple,is,good
170     windows,is,bad
171     linux,is,best
172
173  will give::
174
175    apple   good
176    windows bad
177    linux   best
178
179-----
180
181**What it does**
182
183This tool selects (cuts out) specified columns from the dataset.
184
185- Columns are specified as **c1**, **c2**, and so on. Column count begins with **1**
186- Columns can be specified in any order (e.g., **c2,c1,c6**)
187- If you specify more columns than actually present - empty spaces will be filled with dots
188
189-----
190
191**Example**
192
193Input dataset (six columns: c1, c2, c3, c4, c5, and c6)::
194
195   chr1 10   1000  gene1 0 +
196   chr2 100  1500  gene2 0 +
197
198**cut** on columns "**c1,c4,c6**" will return::
199
200   chr1 gene1 +
201   chr2 gene2 +
202
203**cut** on columns "**c6,c5,c4,c1**" will return::
204
205   + 0 gene1 chr1
206   + 0 gene2 chr2
207
208**cut** on columns "**c1-c3**" will return::
209
210   chr1 10   1000
211   chr2 100  1500
212
213
214**cut** on columns "**c8,c7,c4**" will return::
215
216   . . gene1
217   . . gene2
218</help>
219</tool>