Mercurial > repos > bgruening > text_processing
annotate find_and_replace.xml @ 19:bed2226b90f7 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 29899be24c03f631ef3be107fd60e9f898806321
| author | bgruening |
|---|---|
| date | Tue, 01 Jan 2019 06:01:13 -0500 |
| parents | 74aae7d6cb09 |
| children | 1aa30b2c73c9 |
| rev | line source |
|---|---|
|
15
74aae7d6cb09
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 3103ebed1a420c7d3415b67ef532ea579edf9faa
bgruening
parents:
14
diff
changeset
|
1 <tool id="tp_find_and_replace" name="Replace" version="@BASE_VERSION@.1"> |
| 2 | 2 <description>parts of text</description> |
| 4 | 3 <macros> |
| 4 <import>macros.xml</import> | |
| 5 </macros> | |
|
13
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
10
diff
changeset
|
6 <requirements> |
|
15
74aae7d6cb09
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 3103ebed1a420c7d3415b67ef532ea579edf9faa
bgruening
parents:
14
diff
changeset
|
7 <requirement type="package" version="5.22.0.1">perl</requirement> |
|
13
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
10
diff
changeset
|
8 </requirements> |
|
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
10
diff
changeset
|
9 <command> |
| 4 | 10 <![CDATA[ |
|
13
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
10
diff
changeset
|
11 perl '$__tool_directory__/find_and_replace' |
| 4 | 12 #if $searchwhere.searchwhere_select == "column": |
| 0 | 13 -c $searchwhere.column |
| 14 #end if | |
| 4 | 15 -o $outfile |
| 0 | 16 $caseinsensitive |
| 17 $wholewords | |
| 18 $skip_first_line | |
| 19 $is_regex | |
| 4 | 20 '$find_pattern' |
| 21 '$replace_pattern' | |
| 22 '$infile' | |
| 23 ]]> | |
| 0 | 24 </command> |
| 25 <inputs> | |
| 4 | 26 <param name="infile" format="txt" type="data" label="File to process" /> |
|
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
7
diff
changeset
|
27 <param name="find_pattern" type="text" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > |
| 0 | 28 <sanitizer> |
| 29 <valid initial="string.printable"> | |
| 30 <remove value="'"/> | |
| 31 </valid> | |
| 32 </sanitizer> | |
| 33 </param> | |
|
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
7
diff
changeset
|
34 <param name="replace_pattern" type="text" label="Replace with" |
| 6 | 35 help="Use simple text, or $& (dollar-ampersand) and $1 $2 $3 to refer to matched text. See examples below." > |
| 0 | 36 <sanitizer> |
| 37 <valid initial="string.printable"> | |
| 38 <remove value="'"/> | |
| 39 </valid> | |
| 40 </sanitizer> | |
| 41 </param> | |
| 4 | 42 <param name="is_regex" type="boolean" checked="false" truevalue="-r" falsevalue="" |
| 43 label="Find-Pattern is a regular expression" help="see help section for details." /> | |
| 0 | 44 |
| 4 | 45 <param name="caseinsensitive" type="boolean" checked="false" truevalue="-i" falsevalue="" |
| 46 label="Case-Insensitive search" help="" /> | |
| 0 | 47 |
| 4 | 48 <param name="wholewords" type="boolean" checked="false" truevalue="-w" falsevalue="" |
| 49 label="Find whole-words" help="ignore partial matches (e.g. 'apple' will not match 'snapple')" /> | |
| 0 | 50 |
| 4 | 51 <param name="skip_first_line" type="boolean" checked="false" truevalue="-s" falsevalue="" |
| 52 label="Ignore first line" help="Select this option if the first line contains column headers. Text in the line will not be replaced. " /> | |
| 0 | 53 |
| 54 <conditional name="searchwhere"> | |
| 4 | 55 <param name="searchwhere_select" type="select" label="Find and Replace text in"> |
| 0 | 56 <option value="line" selected="true">entire line</option> |
| 57 <option value="column">specific column</option> | |
| 58 </param> | |
| 59 <when value="line" /> | |
| 60 <when value="column"> | |
| 4 | 61 <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" /> |
| 0 | 62 </when> |
| 63 </conditional> | |
| 64 </inputs> | |
| 65 <outputs> | |
| 6 | 66 <data format_source="infile" name="outfile" metadata_source="infile" /> |
| 0 | 67 </outputs> |
| 4 | 68 <tests> |
| 69 <test> | |
| 70 <param name="infile" value="find_and_replace1.txt" /> | |
| 71 <param name="find_pattern" value="day" /> | |
| 72 <param name="replace_pattern" value="great day" /> | |
| 73 <param name="is_regex" value="False" /> | |
| 74 <param name="caseinsensitive" value="False" /> | |
| 75 <param name="wholewords" value="True" /> | |
| 76 <output name="outfile" file="find_and_replace_results1.txt" /> | |
| 77 </test> | |
| 78 <test> | |
| 79 <param name="infile" value="find_and_replace2.txt" /> | |
| 80 <param name="find_pattern" value="^chr" /> | |
| 81 <param name="replace_pattern" value="" /> | |
| 82 <param name="is_regex" value="True" /> | |
| 83 <param name="caseinsensitive" value="False" /> | |
| 84 <param name="wholewords" value="False" /> | |
| 85 <param name="searchwhere_select" value="column" /> | |
| 86 <param name="column" value="3" /> | |
| 87 <output name="outfile" file="find_and_replace_results2.txt" /> | |
| 88 </test> | |
| 89 </tests> | |
| 90 <help> | |
| 91 <![CDATA[ | |
| 0 | 92 **What it does** |
| 93 | |
| 4 | 94 This tool finds $ replaces text in an input dataset. |
| 0 | 95 |
| 96 .. class:: infomark | |
| 97 | |
| 98 The **pattern to find** can be a simple text string, or a perl **regular expression** string (depending on *pattern is a regex* check-box). | |
| 99 | |
| 100 .. class:: infomark | |
| 101 | |
| 102 When using regular expressions, the **replace pattern** can contain back-references ( e.g. \\1 ) | |
| 103 | |
| 104 .. class:: infomark | |
| 105 | |
| 106 This tool uses Perl regular expression syntax. | |
| 107 | |
| 108 ----- | |
| 109 | |
| 110 **Examples of *regular-expression* Find Patterns** | |
| 111 | |
| 112 - **HELLO** The word 'HELLO' (case sensitive). | |
| 113 - **AG.T** The letters A,G followed by any single character, followed by the letter T. | |
| 114 - **A{4,}** Four or more consecutive A's. | |
| 115 - **chr2[012]\\t** The words 'chr20' or 'chr21' or 'chr22' followed by a tab character. | |
| 116 - **hsa-mir-([^ ]+)** The text 'hsa-mir-' followed by one-or-more non-space characters. When using parenthesis, the matched content of the parenthesis can be accessed with **\1** in the **replace** pattern. | |
| 117 | |
| 118 | |
| 119 **Examples of Replace Patterns** | |
| 120 | |
| 121 - **WORLD** The word 'WORLD' will be placed whereever the find pattern was found. | |
| 6 | 122 - **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. |
| 0 | 123 - **$1** The text which matched the first parenthesis in the Find Pattern. |
| 124 | |
| 125 | |
| 126 ----- | |
| 127 | |
| 128 **Example 1** | |
| 129 | |
| 130 **Find Pattern:** HELLO | |
| 131 **Replace Pattern:** WORLD | |
| 132 **Regular Expression:** no | |
| 133 **Replace what:** entire line | |
| 134 | |
| 4 | 135 Every time the word HELLO is found, it will be replaced with the word WORLD. |
| 0 | 136 |
| 137 ----- | |
| 138 | |
| 139 **Example 2** | |
| 140 | |
| 7 | 141 **Find Pattern:** ^chr |
| 0 | 142 **Replace Pattern:** (empty) |
| 143 **Regular Expression:** yes | |
| 144 **Replace what:** column 11 | |
| 145 | |
| 146 If column 11 (of every line) begins with ther letters 'chr', they will be removed. Effectively, it'll turn "chr4" into "4" and "chrXHet" into "XHet" | |
| 147 | |
| 148 | |
| 149 ----- | |
| 150 | |
| 151 **Perl's Regular Expression Syntax** | |
| 152 | |
| 7 | 153 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. |
| 0 | 154 |
| 155 - **( ) { } [ ] . * ? + \\ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
| 156 - **^** matches the beginning of a string(but not an internal line). | |
| 157 - **(** .. **)** groups a particular pattern. | |
| 158 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
| 159 | |
| 160 - **{n}** The preceding item is matched exactly n times. | |
| 7 | 161 - **{n,}** The preceding item ismatched n or more times. |
| 162 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
| 0 | 163 |
| 164 - **[** ... **]** creates a character class. Within the brackets, single characters can be placed. A dash (-) may be used to indicate a range such as **a-z**. | |
| 165 - **.** Matches any single character except a newline. | |
| 166 - ***** The preceding item will be matched zero or more times. | |
| 167 - **?** The preceding item is optional and matched at most once. | |
| 168 - **+** The preceding item will be matched one or more times. | |
| 169 - **^** has two meaning: | |
| 7 | 170 - matches the beginning of a line or string. |
| 0 | 171 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. |
| 172 - **$** matches the end of a line or string. | |
| 7 | 173 - **\\|** Separates alternate possibilities. |
| 0 | 174 - **\\d** matches a single digit |
| 175 - **\\w** matches a single letter or digit or an underscore. | |
| 176 - **\\s** matches a single white-space (space or tabs). | |
| 177 | |
| 4 | 178 @REFERENCES@ |
| 179 ]]> | |
| 180 </help> | |
|
14
7725ab6dab67
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
13
diff
changeset
|
181 <expand macro="citations" /> |
| 0 | 182 </tool> |
