Previous changeset 5:06061aa49527 (2019-03-06) |
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/add_input_name_as_column commit 9292c57c34283543e86ecc65f805977224f6fc7b" |
modified:
add_input_name_as_column.py add_input_name_as_column.xml test-data/signature_without_header.tab |
b |
diff -r 06061aa49527 -r 3284b72eef56 add_input_name_as_column.py --- a/add_input_name_as_column.py Wed Mar 06 09:16:29 2019 -0500 +++ b/add_input_name_as_column.py Wed Mar 25 07:11:05 2020 -0400 |
b |
@@ -1,5 +1,5 @@ +import argparse import io -import argparse def Parser(): @@ -8,6 +8,8 @@ the_parser.add_argument('--output', required=True, action="store", type=str, help="output file path") the_parser.add_argument('--label', required=True, action="store", type=str, help="label to add in last column") the_parser.add_argument('--header', action="store", type=str, help="column label for last column") + the_parser.add_argument('--prepend', action='store_true', default=False, help='Prepend column instead of appending' ) + args = the_parser.parse_args() return args @@ -19,7 +21,11 @@ for i, line in enumerate(input): line = line.strip('\n') if (i == 0) and args.header: - line = "%s\t%s\n" % (line, args.header) + new_entry = args.header else: - line = "%s\t%s\n" % (line, args.label) + new_entry = args.label + if args.prepend: + line = "%s\t%s\n" % (new_entry, line) + else: + line = "%s\t%s\n" % (line, new_entry) output.write(line) |
b |
diff -r 06061aa49527 -r 3284b72eef56 add_input_name_as_column.xml --- a/add_input_name_as_column.xml Wed Mar 06 09:16:29 2019 -0500 +++ b/add_input_name_as_column.xml Wed Mar 25 07:11:05 2020 -0400 |
[ |
@@ -1,9 +1,9 @@ -<tool id="addName" name="Add input name as column" version="0.1.2" profile="17.09"> - <description>to an existing tabular file</description> - <requirements> - <requirement type="package" version="3.7">python</requirement> - </requirements> - <command><![CDATA[ +<tool id="addName" name="Add input name as column" version="0.2.0" profile="17.09"> + <description>to an existing tabular file</description> + <requirements> + <requirement type="package" version="3.7">python</requirement> + </requirements> + <command><![CDATA[ python '$__tool_directory__/'add_input_name_as_column.py --input '$input' --label '$input.element_identifier' @@ -11,51 +11,52 @@ #if $header.contains_header=="yes": --header "$header.colname" #end if - ]]></command> - <inputs> - <param format="txt" name="input" type="data" label="to Dataset" help="Dataset missing? See TIP below" /> - <conditional name="header"> - <param name="contains_header" type="select" label="input contains a header line?" > - <option value="yes" selected="true">Yes</option> - <option value="no">No</option> - </param> - <when value="yes"> - <param name="colname" type="text" value="sample" help="select a column header to be added in the first line"> - <validator type="empty_field" message="please add a column header"/> - </param> - </when> - <when value="no"> - </when> - </conditional> - </inputs> - <outputs> - <data name="output" format="tabular" /> - </outputs> - <tests> - <test> - <param name="input" value="signature.tab" ftype="tabular" /> - <param name="contains_header" value="yes" /> - <param name="colname" value="sample" /> - <output name="output" file="signature_with_header.tab" ftype="tabular"/> - </test> - <test> - <param name="input" value="signature.tab" ftype="tabular" /> - <param name="contains_header" value="no" /> - <output name="output" file="signature_without_header.tab" ftype="tabular"/> - </test> - </tests> - <help> +$prepend + ]]></command> + <inputs> + <param format="txt" name="input" type="data" label="to Dataset" help="Dataset missing? See TIP below" /> + <conditional name="header"> + <param name="contains_header" type="select" label="input contains a header line?" > + <option value="yes" selected="true">Yes</option> + <option value="no">No</option> + </param> + <when value="yes"> + <param name="colname" type="text" value="sample" help="select a column header to be added in the first line"> + <validator type="empty_field" message="please add a column header"/> + </param> + </when> + <when value="no"/> + </conditional> + <param name="prepend" type="boolean" truevalue="--prepend" falsevalue="" checked="false" label="Prepend the colum" /> + </inputs> + <outputs> + <data name="output" format="tabular" /> + </outputs> + <tests> + <test> + <param name="input" value="signature.tab" ftype="tabular" /> + <param name="contains_header" value="yes" /> + <param name="colname" value="sample" /> + <output name="output" file="signature_with_header.tab" ftype="tabular"/> + </test> + <test> + <param name="input" value="signature.tab" ftype="tabular" /> + <param name="contains_header" value="no" /> + <param name="prepend" value="true" /> + <output name="output" file="signature_without_header.tab" ftype="tabular"/> + </test> + </tests> + <help><![CDATA[ +**What it does** + +Adds a new column with the name of the input file as it appears in the history. +By default the column is appended. + +----- .. class:: infomark -**TIP:** If your data is not TAB delimited, use *Text Manipulation->Convert* - ------ - -**What it does** +**TIP:** If your data is not TAB delimited, use *Text Manipulation->Convert* -Adds a new column with the name of the input file as it appears in the history. -Written by Marius van den Beek, m.vandenbeek at gmail dot com - </help> + ]]></help> </tool> - |
b |
diff -r 06061aa49527 -r 3284b72eef56 test-data/signature_without_header.tab --- a/test-data/signature_without_header.tab Wed Mar 06 09:16:29 2019 -0500 +++ b/test-data/signature_without_header.tab Wed Mar 25 07:11:05 2020 -0400 |
b |
@@ -1,27 +1,27 @@ -overlap num of pairs probability signature.tab -1 8 0.000028 signature.tab -2 7 0.000019 signature.tab -3 9 0.000034 signature.tab -4 6 0.000014 signature.tab -5 8 0.000020 signature.tab -6 10 0.000086 signature.tab -7 6 0.000030 signature.tab -8 9 0.000038 signature.tab -9 12 0.000058 signature.tab -10 24 0.000094 signature.tab -11 11 0.000071 signature.tab -12 9 0.000058 signature.tab -13 8 0.000029 signature.tab -14 11 0.000042 signature.tab -15 13 0.000112 signature.tab -16 8 0.000070 signature.tab -17 11 0.000066 signature.tab -18 12 0.000697 signature.tab -19 13 0.000085 signature.tab -20 5 0.000015 signature.tab -21 18 0.000540 signature.tab -22 9 0.000030 signature.tab -23 8 0.000036 signature.tab -24 7 0.000037 signature.tab -25 14 0.000058 signature.tab -26 12 0.000050 signature.tab +signature.tab overlap num of pairs probability +signature.tab 1 8 0.000028 +signature.tab 2 7 0.000019 +signature.tab 3 9 0.000034 +signature.tab 4 6 0.000014 +signature.tab 5 8 0.000020 +signature.tab 6 10 0.000086 +signature.tab 7 6 0.000030 +signature.tab 8 9 0.000038 +signature.tab 9 12 0.000058 +signature.tab 10 24 0.000094 +signature.tab 11 11 0.000071 +signature.tab 12 9 0.000058 +signature.tab 13 8 0.000029 +signature.tab 14 11 0.000042 +signature.tab 15 13 0.000112 +signature.tab 16 8 0.000070 +signature.tab 17 11 0.000066 +signature.tab 18 12 0.000697 +signature.tab 19 13 0.000085 +signature.tab 20 5 0.000015 +signature.tab 21 18 0.000540 +signature.tab 22 9 0.000030 +signature.tab 23 8 0.000036 +signature.tab 24 7 0.000037 +signature.tab 25 14 0.000058 +signature.tab 26 12 0.000050 |