Mercurial > repos > bgruening > text_processing
diff find_and_replace.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/find_and_replace.xml Sun Oct 06 08:22:36 2013 -0400 +++ b/find_and_replace.xml Wed Jan 07 11:10:52 2015 -0500 @@ -1,30 +1,34 @@ -<tool id="tp_find_and_replace" name="Replace" version="0.1.1"> +<tool id="tp_find_and_replace" name="Replace" version="@BASE_VERSION@.0"> <description>parts of text</description> + <macros> + <import>macros.xml</import> + </macros> <command interpreter="perl"> +<![CDATA[ find_and_replace - #if $searchwhere.choice == "column": + #if $searchwhere.searchwhere_select == "column": -c $searchwhere.column #end if - -o $output + -o $outfile $caseinsensitive $wholewords $skip_first_line $is_regex - '$url_paste' - '$file_data' - '$input' + '$find_pattern' + '$replace_pattern' + '$infile' +]]> </command> <inputs> - <param format="txt" name="input" type="data" label="File to process" /> - <param name="url_paste" type="text" size="20" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > + <param name="infile" format="txt" type="data" label="File to process" /> + <param name="find_pattern" type="text" size="20" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > <sanitizer> <valid initial="string.printable"> <remove value="'"/> </valid> </sanitizer> </param> - - <param name="file_data" type="text" size="20" label="Replace with" help="Use simple text, or $& (dollar-ampersand) and $1 $2 $3 to refer to matched text. See examples below." > + <param name="replace_pattern" type="text" size="20" label="Replace with" help="Use simple text, or $& (dollar-ampersand) and $1 $2 $3 to refer to matched text. See examples below." > <sanitizer> <valid initial="string.printable"> <remove value="'"/> @@ -32,40 +36,59 @@ </sanitizer> </param> - <param name="is_regex" type="boolean" checked="false" truevalue="-r" falsevalue="" label="Find-Pattern is a regular expression" - help="see help section for details." /> + <param name="is_regex" type="boolean" checked="false" truevalue="-r" falsevalue="" + label="Find-Pattern is a regular expression" help="see help section for details." /> - <param name="caseinsensitive" type="boolean" checked="false" truevalue="-i" falsevalue="" label="Case-Insensitive search" - help="" /> + <param name="caseinsensitive" type="boolean" checked="false" truevalue="-i" falsevalue="" + label="Case-Insensitive search" help="" /> - <param name="wholewords" type="boolean" checked="false" truevalue="-w" falsevalue="" label="find whole-words" - help="ignore partial matches (e.g. 'apple' will not match 'snapple') " /> + <param name="wholewords" type="boolean" checked="false" truevalue="-w" falsevalue="" + label="Find whole-words" help="ignore partial matches (e.g. 'apple' will not match 'snapple')" /> - <param name="skip_first_line" type="boolean" checked="false" truevalue="-s" falsevalue="" label="Ignore first line" - help="Select this option if the first line contains column headers. Text in the line will not be replaced. " /> + <param name="skip_first_line" type="boolean" checked="false" truevalue="-s" falsevalue="" + label="Ignore first line" help="Select this option if the first line contains column headers. Text in the line will not be replaced. " /> <conditional name="searchwhere"> - <param name="choice" type="select" label="Find and Replace text in"> + <param name="searchwhere_select" type="select" label="Find and Replace text in"> <option value="line" selected="true">entire line</option> <option value="column">specific column</option> </param> <when value="line" /> - <when value="column"> - <param name="column" label="in column" type="data_column" data_ref="input" accept_default="true" /> + <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" /> </when> </conditional> </inputs> - <outputs> - <data format="input" name="output" metadata_source="input" /> + <data format="input" name="outfile" metadata_source="infile" /> </outputs> - -<help> - + <tests> + <test> + <param name="infile" value="find_and_replace1.txt" /> + <param name="find_pattern" value="day" /> + <param name="replace_pattern" value="great day" /> + <param name="is_regex" value="False" /> + <param name="caseinsensitive" value="False" /> + <param name="wholewords" value="True" /> + <output name="outfile" file="find_and_replace_results1.txt" /> + </test> + <test> + <param name="infile" value="find_and_replace2.txt" /> + <param name="find_pattern" value="^chr" /> + <param name="replace_pattern" value="" /> + <param name="is_regex" value="True" /> + <param name="caseinsensitive" value="False" /> + <param name="wholewords" value="False" /> + <param name="searchwhere_select" value="column" /> + <param name="column" value="3" /> + <output name="outfile" file="find_and_replace_results2.txt" /> + </test> + </tests> + <help> +<![CDATA[ **What it does** -This tool finds & replaces text in an input dataset. +This tool finds $ replaces text in an input dataset. .. class:: infomark @@ -93,7 +116,7 @@ **Examples of Replace Patterns** - **WORLD** The word 'WORLD' will be placed whereever the find pattern was found. -- **FOO-&-BAR** Each time the find pattern is found, it will be surrounded with 'FOO-' at the begining and '-BAR' at the end. **$&** (dollar-ampersand) represents the matched find pattern. +- **FOO-$&-BAR** Each time the find pattern is found, it will be surrounded with 'FOO-' at the begining and '-BAR' at the end. **$&** (dollar-ampersand) represents the matched find pattern. - **$1** The text which matched the first parenthesis in the Find Pattern. @@ -106,7 +129,7 @@ **Regular Expression:** no **Replace what:** entire line -Every time the word HELLO is found, it will be replaced with the word WORLD. +Every time the word HELLO is found, it will be replaced with the word WORLD. ----- @@ -124,7 +147,7 @@ **Perl's Regular Expression Syntax** -The Find & Replace tool searches the data for lines containing or not containing a match to the given pattern. A Regular Expression is a pattern descibing a certain amount of text. +The Find & Replace tool searches the data for lines containing or not containing a match to the given pattern. A Regular Expression is a pattern descibing a certain amount of text. - **( ) { } [ ] . * ? + \\ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. - **^** matches the beginning of a string(but not an internal line). @@ -149,7 +172,7 @@ - **\\w** matches a single letter or digit or an underscore. - **\\s** matches a single white-space (space or tabs). - -</help> - +@REFERENCES@ +]]> + </help> </tool>