diff cut.xml @ 1:a4ad586d1403 draft

Uploaded
author bgruening
date Thu, 05 Sep 2013 11:42:27 -0400
parents ec66f9d90ef0
children fc862d5bccaf
line wrap: on
line diff
--- a/cut.xml	Thu Sep 05 04:58:21 2013 -0400
+++ b/cut.xml	Thu Sep 05 11:42:27 2013 -0400
@@ -1,10 +1,10 @@
-<tool id="unixtools_cut_tool" name="cut" version="0.1.1">
-    <description>columns from files</description>
+<tool id="unixtools_cut_tool" name="Cut" version="0.1.1">
+    <description>columns from a table</description>
     <requirements>
         <requirement type="package" version="8.21">gnu_coreutils</requirement>
     </requirements>
     <command>
-        cut ${complement} ${cutwhat} '${list}' '${input}' &gt; '${output}'
+        cut -d"${delimiter}" ${complement} ${cut_element} '${list}' '${input}' &gt; '${output}'
     </command>
 
     <inputs>
@@ -14,7 +14,17 @@
             <option value="--complement">Discard</option>
         </param>
 
-        <param name="cutwhat" type="select" label="Cut by">
+        <param name="delimiter" type="select" label="Delimited by">
+          <option value="">Tab</option>
+          <option value=" ">Whitespace</option>
+          <option value=".">Dot</option>
+          <option value=",">Comma</option>
+          <option value="-">Dash</option>
+          <option value="_">Underscore</option>
+          <option value="|">Pipe</option>
+        </param>
+
+        <param name="cut_element" type="select" label="Cut by">
             <option value="-f">fields</option>
             <option value="-c">characters</option>
             <option value="-b">bytes</option>
@@ -28,27 +38,145 @@
             </sanitizer>
         </param>
     </inputs>
+    <outputs>
+        <!--<data format="tabular" name="output" />-->
+        <!-- WIP, not sure that will work with the complement option -->
+        <data format="tabular" name="output">
+          <actions>
+            <conditional name="cut_element">
+              <when value="-f">
+                <conditional name="delimiter">
+                  <when value="T">
+                    <conditional name="input">
+                      <when datatype_isinstance="interval">
+                            <action type="format" default="tabular">
+                                <option type="from_param" name="list" column="0" offset="0"> <!-- chromCol is 1-->
 
+                                    <filter type="insert_column" column="0" value="interval"/>
+                                    <filter type="insert_column" ref="list" /> <!-- startCol -->
+                                    <filter type="insert_column" ref="list" /> <!-- endCol -->
+
+                                    <filter type="multiple_splitter" column="1" separator=","/>
+                                    <filter type="column_strip" column="1"/> <!-- get rid of all external whitespace -->
+                                    <filter type="string_function" column="1" name="lower" />
+                                    <filter type="param_value" column="1" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                    <filter type="column_strip" column="1" strip="c"/> <!-- get rid of c's  -->
+                                    <filter type="boolean" column="1" cast="int" />
+
+                                    <filter type="multiple_splitter" column="2" separator=","/>
+                                    <filter type="column_strip" column="2"/> <!-- get rid of all external whitespace -->
+                                    <filter type="string_function" column="2" name="lower" />
+                                    <filter type="param_value" column="2" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                    <filter type="column_strip" column="2" strip="c"/> <!-- get rid of c's  -->
+                                    <filter type="boolean" column="2" cast="int" />
+
+                                    <filter type="multiple_splitter" column="3" separator=","/>
+                                    <filter type="column_strip" column="3"/> <!-- get rid of all external whitespace -->
+                                    <filter type="string_function" column="3" name="lower" />
+                                    <filter type="param_value" column="3" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                    <filter type="column_strip" column="3" strip="c"/> <!-- get rid of c's  -->
+                                    <filter type="boolean" column="3" cast="int" />
+
+                                    <filter type="metadata_value" ref="input" name="chromCol" column="1" />
+                                    <filter type="metadata_value" ref="input" name="startCol" column="2" />
+                                    <filter type="metadata_value" ref="input" name="endCol" column="3" />
+
+                                </option>
+                            </action>
+                        
+                        <conditional name="output">
+                          <when datatype_isinstance="interval">
+                            <action type="metadata" name="chromCol">
+                              <option type="from_param" name="list" column="0" offset="0"> <!-- chromCol is 0-->
+                                <filter type="multiple_splitter" column="0" separator=","/>
+                                <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
+                                <filter type="string_function" column="0" name="lower" />
+                                <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
+                                <filter type="insert_column" value="1" iterate="True" column="0"/>
+                                <filter type="boolean" column="1" cast="int" /> 
+                                <filter type="metadata_value" ref="input" name="chromCol" column="1" />
+                              </option>
+                            </action>
+                            
+                            <action type="metadata" name="startCol">
+                              <option type="from_param" name="list" column="0" offset="0"> <!-- startCol is 0-->
+                                <filter type="multiple_splitter" column="0" separator=","/>
+                                <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
+                                <filter type="string_function" column="0" name="lower" />
+                                <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
+                                <filter type="insert_column" value="1" iterate="True" column="0"/>
+                                <filter type="boolean" column="1" cast="int" />
+                                <filter type="metadata_value" ref="input" name="startCol" column="1" />
+                              </option>
+                            </action>
+                            
+                            <action type="metadata" name="endCol">
+                              <option type="from_param" name="list" column="0" offset="0"> <!-- endCol is 0-->
+                                <filter type="multiple_splitter" column="0" separator=","/>
+                                <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
+                                <filter type="string_function" column="0" name="lower" />
+                                <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
+                                <filter type="insert_column" value="1" iterate="True" column="0"/>
+                                <filter type="boolean" column="1" cast="int" />
+                                <filter type="metadata_value" ref="input" name="endCol" column="1" />
+                              </option>
+                            </action>
+                          
+                            <action type="metadata" name="nameCol" default="0">
+                              <option type="from_param" name="list" column="0" offset="0"> <!-- nameCol is 0-->
+                                <filter type="multiple_splitter" column="0" separator=","/>
+                                <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
+                                <filter type="string_function" column="0" name="lower" />
+                                <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
+                                <filter type="insert_column" value="1" iterate="True" column="0"/>
+                                <filter type="boolean" column="1" cast="int" />
+                                <filter type="metadata_value" ref="input" name="nameCol" column="1" />
+                              </option>
+                            </action>
+                          
+                            <action type="metadata" name="strandCol" default="0">
+                              <option type="from_param" name="list" column="0" offset="0"> <!-- strandCol is 0-->
+                                <filter type="multiple_splitter" column="0" separator=","/>
+                                <filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
+                                <filter type="string_function" column="0" name="lower" />
+                                <filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
+                                <filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's  -->
+                                <filter type="insert_column" value="1" iterate="True" column="0"/>
+                                <filter type="boolean" column="1" cast="int" />
+                                <filter type="metadata_value" ref="input" name="strandCol" column="1" />
+                              </option>
+                            </action>  
+                          </when>
+                        </conditional>
+                        
+                      </when>
+                    </conditional>
+                  </when>
+                </conditional>
+              </when>
+            </conditional>
+          </actions>
+        </data>
+    </outputs>
     <tests>
         <test>
-            <param name="input" value="unix_cut_input1.txt" />
-            <output name="output" file="unix_cut_output1.txt" />
-            <param name="complement" value="Keep" />
-            <param name="cutwhat" value="fields" />
-            <param name="list"  value="1,3,4" />
+            <param name="list" value="1,4,2,3"/>
+            <param name="delimiter" value="T"/>
+            <param name="input" value="1.bed"/>
+            <output name="output" file="eq-cut.dat"/>
         </test>
         <test>
-            <param name="input" value="unix_cut_input1.txt" />
-            <output name="output" file="unix_cut_output1.txt" />
-            <param name="complement" value="Discard" />
-            <param name="cutwhat" value="fields" />
-            <param name="list"  value="2" />
+            <param name="list" value="1,4,2-3" />
+            <param name="delimiter" value="T" />
+            <param name="input" value="1.bed" />
+            <output name="output" file="eq-cut.dat" />
         </test>
     </tests>
 
-    <outputs>
-        <data format="input" name="output" metadata_source="input" />
-    </outputs>
     <help>
 
 **What it does**
@@ -68,8 +196,6 @@
 **-8**    - Cut from the first to the eight field/characters.
 
 
-
-
 Input Example::
 
     fruit	color	price	weight