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