Repository 'column_maker'
hg clone https://toolshed.g2.bx.psu.edu/repos/devteam/column_maker

Changeset 2:464b9305180e (2018-10-25)
Previous changeset 1:626658afe4cb (2015-11-11) Next changeset 3:be25c075ed54 (2020-06-04)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/column_maker commit f6e96ffa420035051ea4632596dfd171074aa66d
modified:
column_maker.py
column_maker.xml
added:
test-data/1.header.tsv
test-data/column_maker_out2.header.tsv
b
diff -r 626658afe4cb -r 464b9305180e column_maker.py
--- a/column_maker.py Wed Nov 11 12:07:18 2015 -0500
+++ b/column_maker.py Thu Oct 25 17:31:42 2018 -0400
[
@@ -47,7 +47,7 @@
     expr = expr.replace( key, value )
 
 operators = 'is|not|or|and'
-builtin_and_math_functions = 'abs|all|any|bin|chr|cmp|complex|divmod|float|hex|int|len|long|max|min|oct|ord|pow|range|reversed|round|sorted|str|sum|type|unichr|unicode|log|exp|sqrt|ceil|floor'
+builtin_and_math_functions = 'abs|all|any|bin|chr|cmp|complex|divmod|float|bool|hex|int|len|long|max|min|oct|ord|pow|range|reversed|round|sorted|str|sum|type|unichr|unicode|log|exp|sqrt|ceil|floor'
 string_and_list_methods = [ name for name in dir('') + dir([]) if not name.startswith('_') ]
 whitelist = "^([c0-9\+\-\*\/\(\)\.\'\"><=,:! ]|%s|%s|%s)*$" % (operators, builtin_and_math_functions, '|'.join(string_and_list_methods))
 if not re.compile(whitelist).match(expr):
b
diff -r 626658afe4cb -r 464b9305180e column_maker.xml
--- a/column_maker.xml Wed Nov 11 12:07:18 2015 -0500
+++ b/column_maker.xml Thu Oct 25 17:31:42 2018 -0400
[
@@ -1,40 +1,79 @@
-<tool id="Add_a_column1" name="Compute" version="1.1.0">
-  <description>an expression on every row</description>
-  <command interpreter="python">
-    column_maker.py $input $out_file1 "$cond" $round ${input.metadata.columns} "${input.metadata.column_types}"
-  </command>
-  <inputs>
-    <param name="cond" type="text" value="c3-c2" label="Add expression"/>
-    <param format="tabular" name="input" type="data" label="as a new column to" help="Dataset missing? See TIP below"/>
-    <param name="round" type="select" label="Round result?">
-      <option value="no">NO</option>
-      <option value="yes">YES</option>
-    </param>    
-  </inputs>
-  <outputs>
-    <data format="input" name="out_file1" metadata_source="input"/>
-  </outputs>
-  <tests>
-    <test>
-      <param name="cond" value="c3-c2"/>
-      <param name="input" value="1.bed"/>
-      <param name="round" value="no"/>
-      <output name="out_file1" file="column_maker_out1.interval"/>
-    </test>
-    <test>
-      <param name="cond" value="c4*1"/>
-      <param name="input" value="1.interval"/>
-      <param name="round" value="no"/>
-      <output name="out_file1" file="column_maker_out2.interval"/>
-    </test>
-    <test>
-      <param name="cond" value="c4*1"/>
-      <param name="input" value="1.interval"/>
-      <param name="round" value="yes"/>
-      <output name="out_file1" file="column_maker_out3.interval"/>
-    </test>
-  </tests>
-  <help>
+<tool id="Add_a_column1" name="Compute" version="1.2.0">
+    <description>an expression on every row</description>
+    <requirements>
+        <requirement type="package" version="2.7.13">python</requirement>
+        <requirement type="package" version="4.4">sed</requirement>
+    </requirements>
+    <command detect_errors="aggressive"><![CDATA[
+        #if $header_lines_conditional.header_lines_select == "yes":
+            (sed -n '1,1p' '$input' | sed  "s|$|%${header_lines_conditional.header_new_column_name}|" | tr "%" "\t") > header &&
+            sed '1,1d' '$input' > data &&
+        #else:
+            touch header &&
+            ln -s '$input' data &&
+        #end if
+
+        python '$__tool_directory__/column_maker.py'
+            data column_maker_output
+            "$cond"
+            $round
+            ${input.metadata.columns}
+            "${input.metadata.column_types}" &&
+        cat header column_maker_output > '$out_file1'
+    ]]></command>
+    <inputs>
+        <param name="cond" type="text" value="c3-c2" label="Add expression"/>
+        <param format="tabular" name="input" type="data" label="as a new column to" help="Dataset missing? See TIP below"/>
+        <param name="round" type="select" label="Round result?">
+            <option value="no">NO</option>
+            <option value="yes">YES</option>
+        </param>
+        <conditional name="header_lines_conditional">
+            <param name="header_lines_select" type="select" label="Skip a header line" help="# characters are already considered as comments and kept" >
+                <option value="no" >no</option>
+                <option value="yes" >yes</option>
+            </param>
+            <when value="no">
+            </when>
+            <when value="yes">
+                <param name="header_new_column_name" type="text" value="New Column" label="The new column name" />
+            </when>
+        </conditional>
+    </inputs>
+    <outputs>
+        <data format_source="input" name="out_file1" metadata_source="input"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="cond" value="c3-c2"/>
+            <param name="input" value="1.bed"/>
+            <param name="round" value="no"/>
+            <output name="out_file1" file="column_maker_out1.interval"/>
+        </test>
+        <test>
+            <param name="cond" value="c4*1"/>
+            <param name="input" value="1.interval"/>
+            <param name="round" value="no"/>
+            <output name="out_file1" file="column_maker_out2.interval"/>
+        </test>
+        <test>
+            <param name="cond" value="c4*1"/>
+            <param name="input" value="1.header.tsv"/>
+            <param name="round" value="no"/>
+            <conditional name="header_lines_conditional">
+                <param name="header_lines_select" value="yes" />
+                <param name="header_new_column_name" value="value1_again" />
+            </conditional>
+            <output name="out_file1" file="column_maker_out2.header.tsv"/>
+        </test>
+        <test>
+            <param name="cond" value="c4*1"/>
+            <param name="input" value="1.interval"/>
+            <param name="round" value="yes"/>
+            <output name="out_file1" file="column_maker_out3.interval"/>
+        </test>
+    </tests>
+    <help>
 
  .. class:: infomark
 
@@ -63,7 +102,7 @@
 
    chr1  151077881  151077918  2  200  -   400.0
    chr1  151081985  151082078  3  500  +  1500.0
-    
+
 if, at the same time, "Round result?" is set to **YES** results will look like this::
 
    chr1  151077881  151077918  2  200  -   400
@@ -79,5 +118,17 @@
    chr1  151077881  151077918  2  200  -  False
    chr1  151081985  151082078  3  500  +  False
 
-</help>
+
+The following build-in functions are available::
+
+  abs | all | any | bin | bool | chr | ceil | cmp | complex
+
+  divmod | exp | float | log | floor | hex | int | len | long
+
+  max | min | oct | ord | pow | range | reversed
+
+  round | sorted | sqrt | str | sum | type | unichr | unicode |
+
+    </help>
+    <citations />
 </tool>
b
diff -r 626658afe4cb -r 464b9305180e test-data/1.header.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/1.header.tsv Thu Oct 25 17:31:42 2018 -0400
b
@@ -0,0 +1,6 @@
+chromosome start end value1 value2 value3 value4 value5
+chr1 4348187 4348589 3.70 4.90 2.55 0.24 0.46
+chr1 4488177 4488442 4.03 5.77 1.92 -0.67 0.81
+chr1 4774091 4774440 8.07 8.33 7.82 0.85 -0.40
+chr1 4800122 4800409 6.40 7.35 5.44 1.19 -0.42
+chr1 4878925 4879277 2.18 0.28 4.93 -0.96 1.24
b
diff -r 626658afe4cb -r 464b9305180e test-data/column_maker_out2.header.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/column_maker_out2.header.tsv Thu Oct 25 17:31:42 2018 -0400
b
@@ -0,0 +1,6 @@
+chromosome start end value1 value2 value3 value4 value5 value1_again
+chr1 4348187 4348589 3.70 4.90 2.55 0.24 0.46 3.7
+chr1 4488177 4488442 4.03 5.77 1.92 -0.67 0.81 4.03
+chr1 4774091 4774440 8.07 8.33 7.82 0.85 -0.40 8.07
+chr1 4800122 4800409 6.40 7.35 5.44 1.19 -0.42 6.4
+chr1 4878925 4879277 2.18 0.28 4.93 -0.96 1.24 2.18