Mercurial > repos > bgruening > text_processing
diff replace_text_in_column.xml @ 4:56e80527c482 draft
Uploaded
author | bgruening |
---|---|
date | Wed, 07 Jan 2015 11:10:52 -0500 |
parents | 7068d1548234 |
children | 8928e6d1e7ba |
line wrap: on
line diff
--- a/replace_text_in_column.xml Sun Oct 06 08:22:36 2013 -0400 +++ b/replace_text_in_column.xml Wed Jan 07 11:10:52 2015 -0500 @@ -1,16 +1,27 @@ -<tool id="tp_replace_in_column" name="Replace Text" version="0.1"> +<tool id="tp_replace_in_column" name="Replace Text" version="@BASE_VERSION@.0"> <description>in a specific column</description> - <requirements> + <macros> + <import>macros.xml</import> + </macros> + <expand macro="requirements"> <requirement type="package" version="4.1.0">gnu_awk</requirement> - </requirements> + </expand> + <version_command>awk --version | head -n 1</version_command> <command interpreter="sh"> - #adapt to awk's quirks - to pass an acutal backslash - two backslashes are required (just like in a C string) +<![CDATA[ + ##adapt to awk's quirks - to pass an acutal backslash - two backslashes are required (just like in a C string) REPLACE_PATTERN=\${$replace_pattern//\\/\\\\}; - awk -v OFS="\t" --re-interval --sandbox "{ \$$column = gensub( /$find_pattern/, \"$replace_pattern\", \"g\", \$$column ) ; print \$0 ; }" "$input" > "$output" + awk + -v OFS="\t" + --re-interval + --sandbox "{ \$$column = gensub( /$find_pattern/, \"$replace_pattern\", \"g\", \$$column ) ; print \$0 ; }" + "$infile" + > "$output" +]]> </command> <inputs> - <param format="tabular" name="input" type="data" label="File to process" /> - <param name="column" label="in column" type="data_column" data_ref="input" accept_default="true" /> + <param format="tabular" name="infile" type="data" label="File to process" /> + <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" /> <param name="find_pattern" type="text" size="20" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > <sanitizer> @@ -19,7 +30,6 @@ </valid> </sanitizer> </param> - <param name="replace_pattern" type="text" size="20" label="Replace with" help="Use simple text, or & (ampersand) and \\1 \\2 \\3 to refer to matched text. See examples below." > <sanitizer> <valid initial="string.printable"> @@ -27,22 +37,21 @@ </valid> </sanitizer> </param> - </inputs> + <outputs> + <data format="input" name="output" metadata_source="infile" /> + </outputs> <tests> <test> - <param name="input" value="replace_text_in_column_in1.txt" ftype="tabular" /> + <param name="infile" value="replace_text_in_column_in1.txt" ftype="tabular" /> + <param name="column" value="4" /> + <param name="find_pattern" value=".+_(R.)" /> + <param name="replace_pattern" value="\1" /> <output name="output" file="replace_text_in_column_output1.txt" /> - <param name="column" value="4" /> - <param name="url_paste" value=".+_(R.)" /> - <param name="file_data" value="\1" /> </test> </tests> - <outputs> - <data format="input" name="output" metadata_source="input" /> - </outputs> <help> - +<![CDATA[ **What it does** This tool performs find & replace operation on a specified column in a given file. @@ -74,8 +83,6 @@ - **\\1** The text which matched the first parenthesis in the Find Pattern. - - ----- **Example 1** @@ -124,5 +131,7 @@ **Note**: AWK uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. +@REFERENCES@ +]]> </help> </tool>