Mercurial > repos > bgruening > text_processing
annotate replace_text_in_column.xml @ 23:6073bb457ec0 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 7cdafed6c6a1387395e5a869186518f129aa3132
author | bgruening |
---|---|
date | Tue, 25 Mar 2025 14:34:17 +0000 |
parents | 3dc70b59608c |
children |
rev | line source |
---|---|
19
12615d397df7
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 70980e329cd9fa78e74bf14a76fd4ded9bd2b91f
bgruening
parents:
12
diff
changeset
|
1 <tool id="tp_replace_in_column" name="Replace Text" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> |
0 | 2 <description>in a specific column</description> |
3 <macros> | |
4 <import>macros.xml</import> | |
5 </macros> | |
19
12615d397df7
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 70980e329cd9fa78e74bf14a76fd4ded9bd2b91f
bgruening
parents:
12
diff
changeset
|
6 <expand macro="creator"/> |
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
|
7 <requirements> |
22
3dc70b59608c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
bgruening
parents:
19
diff
changeset
|
8 <requirement type="package" version="5.3.1">gawk</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
|
9 </requirements> |
0 | 10 <version_command>awk --version | head -n 1</version_command> |
11 <command> | |
12 <![CDATA[ | |
13 awk | |
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
|
14 -v OFS="\t" |
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
|
15 -v FS="\t" |
0 | 16 --re-interval |
12
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
17 --sandbox |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
18 '{ |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
19 #for $replacement in $replacements: |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
20 \$$replacement.column = gensub( /$replacement.find_pattern/, "$replacement.replace_pattern", "g", \$$replacement.column ) ; |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
21 #end for |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
22 print \$0 ; }' |
19
12615d397df7
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 70980e329cd9fa78e74bf14a76fd4ded9bd2b91f
bgruening
parents:
12
diff
changeset
|
23 '$infile' |
12615d397df7
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 70980e329cd9fa78e74bf14a76fd4ded9bd2b91f
bgruening
parents:
12
diff
changeset
|
24 > '$outfile' |
0 | 25 ]]> |
26 </command> | |
27 <inputs> | |
28 <param format="tabular" name="infile" type="data" label="File to process" /> | |
12
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
29 <repeat name="replacements" title="Replacement" min="1"> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
30 <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" /> |
0 | 31 |
12
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
32 <param name="find_pattern" type="text" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
33 <sanitizer> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
34 <valid initial="string.printable"> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
35 <remove value="'"/> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
36 </valid> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
37 </sanitizer> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
38 </param> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
39 <param name="replace_pattern" type="text" label="Replace with" help="Use simple text, or & (ampersand) and \\1 \\2 \\3 to refer to matched text. See examples below." > |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
40 <sanitizer> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
41 <valid initial="string.printable"> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
42 <remove value="'"/> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
43 </valid> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
44 </sanitizer> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
45 </param> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
46 </repeat> |
0 | 47 </inputs> |
48 <outputs> | |
49 <data name="outfile" format_source="infile" metadata_source="infile" /> | |
50 </outputs> | |
51 <tests> | |
12
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
52 <test> |
0 | 53 <param name="infile" value="replace_text_in_column1.txt" ftype="tabular" /> |
22
3dc70b59608c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
bgruening
parents:
19
diff
changeset
|
54 <repeat name="replacements"> |
3dc70b59608c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
bgruening
parents:
19
diff
changeset
|
55 <param name="column" value="4" /> |
3dc70b59608c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
bgruening
parents:
19
diff
changeset
|
56 <param name="find_pattern" value=".+_(R.)" /> |
3dc70b59608c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
bgruening
parents:
19
diff
changeset
|
57 <param name="replace_pattern" value="\\1" /> |
3dc70b59608c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
bgruening
parents:
19
diff
changeset
|
58 </repeat> |
0 | 59 <output name="outfile" file="replace_text_in_column_results1.txt" /> |
60 </test> | |
12
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
61 <test> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
62 <param name="infile" value="replace_text_in_column1.txt" ftype="tabular" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
63 <repeat name="replacements"> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
64 <param name="column" value="1" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
65 <param name="find_pattern" value="[a-z]{2}([a-z])" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
66 <param name="replace_pattern" value="\\1" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
67 </repeat> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
68 <repeat name="replacements"> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
69 <param name="column" value="4" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
70 <param name="find_pattern" value=".+_(R.)" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
71 <param name="replace_pattern" value="\\1" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
72 </repeat> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
73 <output name="outfile" file="replace_text_in_column_results2.txt" /> |
a6f147a050a2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f47799941f9e11c313b38758bfdaab0ce83844f8
bgruening
parents:
11
diff
changeset
|
74 </test> |
0 | 75 </tests> |
76 <help> | |
77 <![CDATA[ | |
78 **What it does** | |
79 | |
80 This tool performs find & replace operation on a specified column in a given file. | |
81 | |
82 .. class:: infomark | |
83 | |
84 The **pattern to find** uses the **extended regular** expression syntax (same as running 'awk --re-interval'). | |
85 | |
86 .. class:: infomark | |
87 | |
88 **TIP:** If you need more complex patterns, use the *awk* tool. | |
89 | |
90 ----- | |
91 | |
92 | |
93 **Examples of Find Patterns** | |
94 | |
95 - **HELLO** The word 'HELLO' (case sensitive). | |
96 - **AG.T** The letters A,G followed by any single character, followed by the letter T. | |
97 - **A{4,}** Four or more consecutive A's. | |
98 - **chr2[012]\\t** The words 'chr20' or 'chr21' or 'chr22' followed by a tab character. | |
99 - **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. | |
100 | |
101 | |
102 **Examples of Replace Patterns** | |
103 | |
104 - **WORLD** The word 'WORLD' will be placed whereever the find pattern was found. | |
105 - **FOO-&-BAR** Each time the find pattern is found, it will be surrounded with 'FOO-' at the begining and '-BAR' at the end. **&** (ampersand) represents the matched find pattern. | |
106 - **\\1** The text which matched the first parenthesis in the Find Pattern. | |
107 | |
108 | |
109 ----- | |
110 | |
111 **Example 1** | |
112 | |
113 **Find Pattern:** HELLO | |
114 **Replace Pattern:** WORLD | |
115 | |
116 Every time the word HELLO is found, it will be replaced with the word WORLD. This operation affects only the selected column. | |
117 | |
118 ----- | |
119 | |
120 **Example 2** | |
121 | |
122 **Find Pattern:** ^(.{4}) | |
123 **Replace Pattern:** &\\t | |
124 | |
125 Find the first four characters in each line, and replace them with the same text, followed by a tab character. In practice - this will split the first line into two columns. This operation affects only the selected column. | |
126 | |
127 | |
128 ----- | |
129 | |
130 **Extened Regular Expression Syntax** | |
131 | |
132 The select 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. | |
133 | |
134 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
135 - **^** matches the beginning of a string(but not an internal line). | |
136 - **(** .. **)** groups a particular pattern. | |
137 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
138 | |
139 - **{n}** The preceding item is matched exactly n times. | |
140 - **{n,}** The preceding item ismatched n or more times. | |
141 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
142 | |
143 - **[** ... **]** 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**. | |
144 - **.** Matches any single character except a newline. | |
145 - ***** The preceding item will be matched zero or more times. | |
146 - **?** The preceding item is optional and matched at most once. | |
147 - **+** The preceding item will be matched one or more times. | |
148 - **^** has two meaning: | |
149 - matches the beginning of a line or string. | |
150 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. | |
151 - **$** matches the end of a line or string. | |
152 - **\|** Separates alternate possibilities. | |
153 | |
154 | |
155 **Note**: AWK uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. | |
156 | |
157 ]]> | |
158 </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
|
159 <expand macro="citations" /> |
0 | 160 </tool> |