Mercurial > repos > bgruening > text_processing
comparison replace_text_in_line.xml @ 27:08cdbfffce67 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 2dc2df988bd2dde9f8d7f629b594186dbd4fdc2b
author | bgruening |
---|---|
date | Fri, 07 Mar 2025 20:43:41 +0000 |
parents | f22a309187a3 |
children |
comparison
equal
deleted
inserted
replaced
26:f22a309187a3 | 27:08cdbfffce67 |
---|---|
12 <![CDATA[ | 12 <![CDATA[ |
13 sed | 13 sed |
14 -r | 14 -r |
15 --sandbox | 15 --sandbox |
16 #for $replacement in $replacements: | 16 #for $replacement in $replacements: |
17 -e '$replacement.sed_options' | |
17 -e | 18 -e |
18 's/$replacement.find_pattern/$replacement.replace_pattern/g' | 19 's/$replacement.find_pattern/$replacement.replace_pattern/g' |
19 #end for | 20 #end for |
20 '$infile' | 21 '$infile' |
21 > '$outfile' | 22 > '$outfile' |
45 </valid> | 46 </valid> |
46 <mapping initial="none"> | 47 <mapping initial="none"> |
47 <add source="'" target="'"'"'" /> | 48 <add source="'" target="'"'"'" /> |
48 <add source="/" target="\/"/> | 49 <add source="/" target="\/"/> |
49 </mapping> | 50 </mapping> |
50 | |
51 </sanitizer> | 51 </sanitizer> |
52 | 52 </param> |
53 </param> | 53 <param name="sed_options" type="text" size="20" optional="true" label="Additional sed commands before replacement" help="Provide additional sed commands before the replacement (e.g., ':a;N;$!ba;')." > |
54 <sanitizer> | |
55 <valid initial="string.printable"> | |
56 <remove value="'"/> <!-- Removes single quotes --> | |
57 <remove value="/"/> <!-- Removes slashes --> | |
58 </valid> | |
59 <mapping initial="none"> | |
60 <add source="'" target="'"'"'" /> <!-- Escapes single quotes --> | |
61 <add source="/" target="\/"/> <!-- Escapes slashes --> | |
62 </mapping> | |
63 </sanitizer> | |
64 </param> | |
54 </repeat> | 65 </repeat> |
55 </inputs> | 66 </inputs> |
56 <outputs> | 67 <outputs> |
57 <data name="outfile" format_source="infile" metadata_source="infile"/> | 68 <data name="outfile" format_source="infile" metadata_source="infile"/> |
58 </outputs> | 69 </outputs> |
59 <tests> | 70 <tests> |
60 <test> | 71 <test> |
61 <param name="infile" value="replace_text_in_line1.txt" /> | 72 <param name="infile" value="replace_text_in_line1.txt" /> |
62 <param name="find_pattern" value="CTC." /> | 73 <repeat name="replacements"> |
63 <param name="replace_pattern" value="FOOBAR" /> | 74 <param name="find_pattern" value="CTC." /> |
75 <param name="replace_pattern" value="FOOBAR" /> | |
76 <param name="sed_options" value="" /> | |
77 </repeat> | |
64 <output name="outfile" file="replace_text_in_line_results1.txt" /> | 78 <output name="outfile" file="replace_text_in_line_results1.txt" /> |
65 </test> | 79 </test> |
66 <test> | 80 <test> |
67 <param name="infile" value="replace_text_in_line1.txt" /> | 81 <param name="infile" value="replace_text_in_line1.txt" /> |
68 <repeat name="replacements"> | 82 <repeat name="replacements"> |
69 <param name="find_pattern" value="CTC." /> | 83 <param name="find_pattern" value="CTC." /> |
70 <param name="replace_pattern" value="FOOBAR" /> | 84 <param name="replace_pattern" value="FOOBAR" /> |
85 <param name="sed_options" value="" /> | |
71 </repeat> | 86 </repeat> |
72 <repeat name="replacements"> | 87 <repeat name="replacements"> |
73 <param name="find_pattern" value="chr" /> | 88 <param name="find_pattern" value="chr" /> |
74 <param name="replace_pattern" value="domain" /> | 89 <param name="replace_pattern" value="domain" /> |
90 <param name="sed_options" value="" /> | |
75 </repeat> | 91 </repeat> |
76 <output name="outfile" file="replace_text_in_line_results2.txt" /> | 92 <output name="outfile" file="replace_text_in_line_results2.txt" /> |
93 </test> | |
94 <test> | |
95 <param name="infile" value="replace_text_in_line1.txt" /> | |
96 <repeat name="replacements"> | |
97 <param name="find_pattern" value="\n" /> | |
98 <param name="replace_pattern" value="" /> | |
99 <param name="sed_options" value=":a;N;$!ba" /> | |
100 </repeat> | |
101 <output name="outfile" file="replace_text_in_line_results3.txt" /> | |
77 </test> | 102 </test> |
78 </tests> | 103 </tests> |
79 <help> | 104 <help> |
80 <![CDATA[ | 105 <![CDATA[ |
81 **What it does** | 106 **What it does** |
153 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. | 178 - 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. | 179 - **$** matches the end of a line or string. |
155 - **\|** Separates alternate possibilities. | 180 - **\|** Separates alternate possibilities. |
156 | 181 |
157 | 182 |
158 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. | 183 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. However, you can use SED FAQ to perform commands using special characters. |
184 More complex options can look like `sed -e '$!N;s/foo/bar/;'`. Here, `$!N;` is an optional part which you only need to set in very special cases. The `foo` part is the search string, and the `bar` part is the replacement string. | |
185 Please read the SED FAQ here: https://www.pement.org/sed/sedfaq3.html#s3.2 | |
159 | 186 |
160 ]]> | 187 ]]> |
161 </help> | 188 </help> |
162 <expand macro="citations" /> | 189 <expand macro="citations" /> |
163 </tool> | 190 </tool> |