comparison find_and_replace.xml @ 18:d698c222f354 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 378e99cde623698fb44ee7ac9873f455fb51fdbc"
author bgruening
date Sat, 08 Oct 2022 21:01:33 +0000
parents fb4ff3c42cd3
children 12615d397df7
comparison
equal deleted inserted replaced
17:f46f0e4f75c4 18:d698c222f354
1 <tool id="tp_find_and_replace" name="Replace" version="@BASE_VERSION@.3"> 1 <tool id="tp_find_and_replace" name="Replace" version="@BASE_VERSION@.4">
2 <description>parts of text</description> 2 <description>parts of text</description>
3 <macros> 3 <macros>
4 <import>macros.xml</import> 4 <import>macros.xml</import>
5 </macros> 5 </macros>
6 <requirements> 6 <requirements>
7 <requirement type="package" version="5.22.0.1">perl</requirement> 7 <requirement type="package" version="5.22.0.1">perl</requirement>
8 </requirements> 8 </requirements>
9 <command> 9 <command>
10 <![CDATA[ 10 <![CDATA[
11 perl '$__tool_directory__/find_and_replace' 11 #for $i, $el in enumerate($find_and_replace)
12 #if $searchwhere.searchwhere_select == "column": 12 #if $i == (len($find_and_replace) - 1)
13 -c $searchwhere.column 13 #set $join = ""
14 #else
15 #set $join = "|"
14 #end if 16 #end if
15 -o $outfile 17 perl '$__tool_directory__/find_and_replace'
16 $global 18 #if $el.searchwhere.searchwhere_select == "column":
17 $caseinsensitive 19 -c $el.searchwhere.column
18 $wholewords 20 #end if
19 $skip_first_line 21 #if $i == (len($find_and_replace) - 1)
20 $is_regex 22 -o '$outfile'
21 '$find_pattern' 23 #end if
22 '$replace_pattern' 24 $el.global
23 '$infile' 25 $el.caseinsensitive
26 $el.wholewords
27 $el.skip_first_line
28 $el.is_regex
29 '$el.find_pattern'
30 '$el.replace_pattern'
31 #if $i == 0
32 '$infile'
33 #end if
34 $join
35 #end for
24 ]]> 36 ]]>
25 </command> 37 </command>
26 <inputs> 38 <inputs>
27 <param name="infile" format="txt" type="data" label="File to process" /> 39 <param name="infile" format="txt" type="data" label="File to process" />
28 <param name="find_pattern" type="text" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > 40 <repeat name="find_and_replace" title="Find and Replace" min="1">
29 <sanitizer> 41 <param name="find_pattern" type="text" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " >
30 <valid initial="string.printable"> 42 <sanitizer>
31 <remove value="&apos;"/> 43 <valid initial="string.printable">
32 </valid> 44 <remove value="&apos;"/>
33 </sanitizer> 45 </valid>
34 </param> 46 </sanitizer>
35 <param name="replace_pattern" type="text" label="Replace with"
36 help="Use simple text, or $&amp; (dollar-ampersand) and $1 $2 $3 to refer to matched text. See examples below." >
37 <sanitizer>
38 <valid initial="string.printable">
39 <remove value="&apos;"/>
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
46 <param name="global" type="boolean" checked="false" truevalue="-g" falsevalue=""
47 label="Replace all occurences of the pattern" />
48
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> 47 </param>
63 <when value="line" /> 48 <param name="replace_pattern" type="text" label="Replace with"
64 <when value="column"> 49 help="Use simple text, or $&amp; (dollar-ampersand) and $1 $2 $3 to refer to matched text. See examples below." >
65 <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" /> 50 <sanitizer>
66 </when> 51 <valid initial="string.printable">
67 </conditional> 52 <remove value="&apos;"/>
53 </valid>
54 </sanitizer>
55 </param>
56 <param name="is_regex" type="boolean" checked="false" truevalue="-r" falsevalue=""
57 label="Find-Pattern is a regular expression" help="see help section for details." />
58
59 <param name="global" type="boolean" checked="false" truevalue="-g" falsevalue=""
60 label="Replace all occurences of the pattern" />
61
62 <param name="caseinsensitive" type="boolean" checked="false" truevalue="-i" falsevalue=""
63 label="Case-Insensitive search" help="" />
64
65 <param name="wholewords" type="boolean" checked="false" truevalue="-w" falsevalue=""
66 label="Find whole-words" help="ignore partial matches (e.g. 'apple' will not match 'snapple')" />
67
68 <param name="skip_first_line" type="boolean" checked="false" truevalue="-s" falsevalue=""
69 label="Ignore first line" help="Select this option if the first line contains column headers. Text in the line will not be replaced. " />
70
71 <conditional name="searchwhere">
72 <param name="searchwhere_select" type="select" label="Find and Replace text in">
73 <option value="line" selected="true">entire line</option>
74 <option value="column">specific column</option>
75 </param>
76 <when value="line" />
77 <when value="column">
78 <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" />
79 </when>
80 </conditional>
81 </repeat>
68 </inputs> 82 </inputs>
69 <outputs> 83 <outputs>
70 <data format_source="infile" name="outfile" metadata_source="infile" /> 84 <data format_source="infile" name="outfile" metadata_source="infile" />
71 </outputs> 85 </outputs>
72 <tests> 86 <tests>
73 <test> 87 <test expect_num_outputs="1">
74 <param name="infile" value="find_and_replace1.txt" /> 88 <param name="infile" value="find_and_replace1.txt" />
75 <param name="find_pattern" value="day" /> 89 <repeat name="find_and_replace">
76 <param name="replace_pattern" value="great day" /> 90 <param name="find_pattern" value="day" />
77 <param name="is_regex" value="False" /> 91 <param name="replace_pattern" value="great day" />
78 <param name="global" value="true" /> 92 <param name="is_regex" value="False" />
79 <param name="caseinsensitive" value="False" /> 93 <param name="global" value="true" />
80 <param name="wholewords" value="True" /> 94 <param name="caseinsensitive" value="False" />
81 <output name="outfile" file="find_and_replace_results1.txt" /> 95 <param name="wholewords" value="True" />
96 </repeat>
97 <output name="outfile" file="find_and_replace_results1.txt" />
82 </test> 98 </test>
83 <!-- test that columns are split by tab not space. input has no tab loads of spaces 99 <!-- test that columns are split by tab not space. input has no tab loads of spaces
84 .. therefore the ftype needs to be set. 100 .. therefore the ftype needs to be set.
85 result should be the same as in test 1 which works on whole line --> 101 result should be the same as in test 1 which works on whole line -->
86 <test> 102 <test expect_num_outputs="1">
87 <param name="infile" value="find_and_replace1.txt" ftype="tabular" /> 103 <param name="infile" value="find_and_replace1.txt" ftype="tabular" />
88 <param name="find_pattern" value="day" /> 104 <repeat name="find_and_replace">
89 <param name="replace_pattern" value="great day" /> 105 <param name="find_pattern" value="day" />
90 <param name="is_regex" value="False" /> 106 <param name="replace_pattern" value="great day" />
91 <param name="global" value="true" /> 107 <param name="is_regex" value="False" />
92 <param name="caseinsensitive" value="False" /> 108 <param name="global" value="true" />
93 <param name="wholewords" value="True" /> 109 <param name="caseinsensitive" value="False" />
94 <conditional name="searchwhere"> 110 <param name="wholewords" value="True" />
95 <param name="searchwhere_select" value="column"/> 111 <conditional name="searchwhere">
96 <param name="column" value="1" /> 112 <param name="searchwhere_select" value="column"/>
97 </conditional> 113 <param name="column" value="1" />
114 </conditional>
115 </repeat>
98 <output name="outfile" file="find_and_replace_results1.txt" /> 116 <output name="outfile" file="find_and_replace_results1.txt" />
99 </test> 117 </test>
100 <test> 118 <test expect_num_outputs="1">
101 <param name="infile" value="find_and_replace2.txt" /> 119 <param name="infile" value="find_and_replace2.txt" />
102 <param name="find_pattern" value="^chr" /> 120 <repeat name="find_and_replace">
103 <param name="replace_pattern" value="" /> 121 <param name="find_pattern" value="^chr" />
104 <param name="is_regex" value="True" /> 122 <param name="replace_pattern" value="" />
105 <param name="caseinsensitive" value="False" /> 123 <param name="is_regex" value="True" />
106 <param name="wholewords" value="False" /> 124 <param name="caseinsensitive" value="False" />
107 <param name="searchwhere_select" value="column" /> 125 <param name="wholewords" value="False" />
108 <param name="column" value="3" /> 126 <conditional name="searchwhere">
127 <param name="searchwhere_select" value="column" />
128 <param name="column" value="3" />
129 </conditional>
130 </repeat>
109 <output name="outfile" file="find_and_replace_results2.txt" /> 131 <output name="outfile" file="find_and_replace_results2.txt" />
132 </test>
133 <test expect_num_outputs="1">
134 <param name="infile" value="find_and_replace1.txt" />
135 <repeat name="find_and_replace">
136 <param name="find_pattern" value="day" />
137 <param name="replace_pattern" value="great day" />
138 <param name="is_regex" value="False" />
139 <param name="global" value="true" />
140 <param name="caseinsensitive" value="False" />
141 <param name="wholewords" value="True" />
142 </repeat>
143 <param name="infile" value="find_and_replace1.txt" />
144 <repeat name="find_and_replace">
145 <param name="find_pattern" value="great" />
146 <param name="replace_pattern" value="best" />
147 <param name="is_regex" value="False" />
148 <param name="global" value="False" />
149 <param name="caseinsensitive" value="False" />
150 <param name="wholewords" value="True" />
151 </repeat>
152 <output name="outfile" file="find_and_replace_results3.txt" />
110 </test> 153 </test>
111 </tests> 154 </tests>
112 <help> 155 <help>
113 <![CDATA[ 156 <![CDATA[
114 **What it does** 157 **What it does**
123 166
124 When using regular expressions, the **replace pattern** can contain back-references ( e.g. \\1 ) 167 When using regular expressions, the **replace pattern** can contain back-references ( e.g. \\1 )
125 168
126 .. class:: infomark 169 .. class:: infomark
127 170
128 This tool uses Perl regular expression syntax. 171 This tool uses `Perl regular expression <https://perldoc.perl.org/perlre>`_ syntax.
129 172
130 ----- 173 -----
131 174
132 **Examples of *regular-expression* Find Patterns** 175 **Examples of *regular-expression* Find Patterns**
133 176