Mercurial > repos > bgruening > text_processing
annotate replace_text_in_column.xml @ 20:fbf99087e067 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit c4f50d1ee81c1618344ede1f04a46a28d8068bcc
author | bgruening |
---|---|
date | Thu, 28 Mar 2024 13:20:16 +0000 |
parents | 12615d397df7 |
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> |
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
|
8 <requirement type="package" version="5.3.0">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" /> |
54 <param name="column" value="4" /> | |
55 <param name="find_pattern" value=".+_(R.)" /> | |
56 <param name="replace_pattern" value="\\1" /> | |
57 <output name="outfile" file="replace_text_in_column_results1.txt" /> | |
58 </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
|
59 <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
|
60 <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
|
61 <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
|
62 <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
|
63 <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
|
64 <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
|
65 </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
|
66 <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
|
67 <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
|
68 <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
|
69 <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
|
70 </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
|
71 <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
|
72 </test> |
0 | 73 </tests> |
74 <help> | |
75 <![CDATA[ | |
76 **What it does** | |
77 | |
78 This tool performs find & replace operation on a specified column in a given file. | |
79 | |
80 .. class:: infomark | |
81 | |
82 The **pattern to find** uses the **extended regular** expression syntax (same as running 'awk --re-interval'). | |
83 | |
84 .. class:: infomark | |
85 | |
86 **TIP:** If you need more complex patterns, use the *awk* tool. | |
87 | |
88 ----- | |
89 | |
90 | |
91 **Examples of Find Patterns** | |
92 | |
93 - **HELLO** The word 'HELLO' (case sensitive). | |
94 - **AG.T** The letters A,G followed by any single character, followed by the letter T. | |
95 - **A{4,}** Four or more consecutive A's. | |
96 - **chr2[012]\\t** The words 'chr20' or 'chr21' or 'chr22' followed by a tab character. | |
97 - **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. | |
98 | |
99 | |
100 **Examples of Replace Patterns** | |
101 | |
102 - **WORLD** The word 'WORLD' will be placed whereever the find pattern was found. | |
103 - **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. | |
104 - **\\1** The text which matched the first parenthesis in the Find Pattern. | |
105 | |
106 | |
107 ----- | |
108 | |
109 **Example 1** | |
110 | |
111 **Find Pattern:** HELLO | |
112 **Replace Pattern:** WORLD | |
113 | |
114 Every time the word HELLO is found, it will be replaced with the word WORLD. This operation affects only the selected column. | |
115 | |
116 ----- | |
117 | |
118 **Example 2** | |
119 | |
120 **Find Pattern:** ^(.{4}) | |
121 **Replace Pattern:** &\\t | |
122 | |
123 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. | |
124 | |
125 | |
126 ----- | |
127 | |
128 **Extened Regular Expression Syntax** | |
129 | |
130 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. | |
131 | |
132 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
133 - **^** matches the beginning of a string(but not an internal line). | |
134 - **(** .. **)** groups a particular pattern. | |
135 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
136 | |
137 - **{n}** The preceding item is matched exactly n times. | |
138 - **{n,}** The preceding item ismatched n or more times. | |
139 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
140 | |
141 - **[** ... **]** 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**. | |
142 - **.** Matches any single character except a newline. | |
143 - ***** The preceding item will be matched zero or more times. | |
144 - **?** The preceding item is optional and matched at most once. | |
145 - **+** The preceding item will be matched one or more times. | |
146 - **^** has two meaning: | |
147 - matches the beginning of a line or string. | |
148 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. | |
149 - **$** matches the end of a line or string. | |
150 - **\|** Separates alternate possibilities. | |
151 | |
152 | |
153 **Note**: AWK uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. | |
154 | |
155 ]]> | |
156 </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
|
157 <expand macro="citations" /> |
0 | 158 </tool> |