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