Skip to content

Commit 2dc2df9

Browse files
Added extra SED find and replace input option and test file (#1588)
* Added extra the SED find and replace input option and test files * add commit from #1520 * Update tools/text_processing/text_processing/replace_text_in_line.xml Co-authored-by: Björn Grüning <bjoern@gruenings.eu> * Update replace_text_in_line.xml help section * Modified tools to pass planemo lint and corrected one test_data * Update tools/text_processing/text_processing/replace_text_in_line.xml Co-authored-by: Björn Grüning <bjoern@gruenings.eu> * are we brave enough to bump the version? * reuse version token * fix version * update dependency --------- Co-authored-by: Björn Grüning <bjoern@gruenings.eu> Co-authored-by: Bjoern Gruening <bjoern.gruening@gmail.com>
1 parent 2723029 commit 2dc2df9

File tree

15 files changed

+103
-49
lines changed

15 files changed

+103
-49
lines changed

tools/text_processing/text_processing/awk.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</macros>
66
<expand macro="creator"/>
77
<requirements>
8-
<requirement type="package" version="5.3.0">gawk</requirement>
8+
<requirement type="package" version="5.3.1">gawk</requirement>
99
</requirements>
1010
<version_command>awk --version | head -n 1</version_command>
1111
<command>

tools/text_processing/text_processing/cut.xml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<tool id="tp_cut_tool" name="Advanced Cut" version="@TOOL_VERSION@+galaxy2" profile="@PROFILE@">
1+
<tool id="tp_cut_tool" name="Advanced Cut" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
22
<description>columns from a table (cut)</description>
33
<macros>
44
<import>macros.xml</import>
@@ -191,14 +191,19 @@
191191
<tests>
192192
<test expect_num_outputs="1">
193193
<param name="input" value="cut1.txt"/>
194-
<param name="list" value="1,3,4"/>
195-
<param name="delimiter" value=""/>
194+
<conditional name="cut_type_options">
195+
<param name="cut_element" value="-f"/>
196+
<param name="delimiter" value="" />
197+
<conditional name="colnames_option">
198+
<param name="header" value="Y"/>
199+
<param name="list" value="1,3,4"/>
200+
</conditional>
201+
</conditional>
196202
<output name="output" file="cut_results1.txt"/>
197203
<assert_command>
198204
<has_text text="-f '1,3,4'"/>
199205
</assert_command>
200206
</test>
201-
202207
<test expect_num_outputs="1">
203208
<param name="input" value="cut1.txt"/>
204209
<conditional name="cut_type_options">
@@ -217,9 +222,10 @@
217222
</test>
218223
<test expect_num_outputs="1">
219224
<param name="input" value="cut1.txt"/>
220-
<param name="list" value="-3" />
221-
<param name="delimiter" value="" />
222-
<param name="cut_element" value="-c" />
225+
<conditional name="cut_type_options">
226+
<param name="cut_element" value="-c" />
227+
<param name="list" value="-3" />
228+
</conditional>
223229
<output name="output" file="cut_results3.txt"/>
224230
</test>
225231
</tests>

tools/text_processing/text_processing/grep.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<!-- grep a FASTA file for sequences with specific motif -->
8686
<test>
8787
<param name="infile" value="grep1.txt" />
88-
<param name="case_sensitive" value="case sensitive" />
88+
<param name="case_sensitive" value="-i" />
8989
<param name="regex_type" value="-P" />
9090
<param name="invert" value="" />
9191
<param name="url_paste" value="AA.{2}GT" />
@@ -98,7 +98,7 @@
9898
show highlighed output -->
9999
<test>
100100
<param name="infile" value="grep1.txt" />
101-
<param name="case_sensitive" value="case sensitive" />
101+
<param name="case_sensitive" value="-i" />
102102
<param name="regex_type" value="-P" />
103103
<param name="invert" value="" />
104104
<param name="url_paste" value="AA.{2}GT" />
@@ -110,7 +110,7 @@
110110
<!-- tests egrep -->
111111
<test>
112112
<param name="infile" value="egrep1.txt" />
113-
<param name="case_sensitive" value="case sensitive" />
113+
<param name="case_sensitive" value="-i" />
114114
<param name="regex_type" value="-E" />
115115
<param name="invert" value="" />
116116
<param name="url_paste" value="[^ ]+" />
@@ -122,7 +122,7 @@
122122
<!-- tests basic regex; + must be backslashed to match -->
123123
<test>
124124
<param name="infile" value="egrep1.txt" />
125-
<param name="case_sensitive" value="case sensitive" />
125+
<param name="case_sensitive" value="-i" />
126126
<param name="regex_type" value="-G" />
127127
<param name="invert" value="" />
128128
<param name="url_paste" value="[^ ]\+" />
@@ -134,7 +134,7 @@
134134
<!-- tests regex;matching nothing -->
135135
<test>
136136
<param name="infile" value="egrep1.txt" />
137-
<param name="case_sensitive" value="case sensitive" />
137+
<param name="case_sensitive" value="-i" />
138138
<param name="regex_type" value="-G" />
139139
<param name="invert" value="" />
140140
<param name="url_paste" value="not existent pattern" />
@@ -150,7 +150,7 @@
150150
<!-- tests invalid regex; i.e. that we still get exit code 2 -->
151151
<test expect_failure="true" expect_exit_code="2">
152152
<param name="infile" value="egrep1.txt" />
153-
<param name="case_sensitive" value="case sensitive" />
153+
<param name="case_sensitive" value="-i" />
154154
<param name="regex_type" value="-G" />
155155
<param name="invert" value="" />
156156
<param name="url_paste" value="\(" />

tools/text_processing/text_processing/macros.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<macros>
22
<xml name="requirements">
33
<requirements>
4-
<requirement type="package" version="9.3">coreutils</requirement>
4+
<requirement type="package" version="@TOOL_VERSION@">coreutils</requirement>
55
<yield/>
66
</requirements>
77
</xml>
8-
<token name="@TOOL_VERSION@">9.3</token>
9-
<token name="@VERSION_SUFFIX@">1</token>
8+
<token name="@TOOL_VERSION@">9.5</token>
9+
<token name="@VERSION_SUFFIX@">0</token>
1010
<token name="@PROFILE@">23.1</token>
1111
<xml name="stdio">
1212
<stdio>

tools/text_processing/text_processing/multijoin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<param name="first_file" value="multijoin1.txt" />
5353
<param name="files" value="multijoin2.txt,multijoin3.txt" />
5454
<param name="key_column" value="4" />
55-
<param name="value_columns" value="c7,c8,c9" />
55+
<param name="value_columns" value="7,8,9" />
5656
<param name="output_header" value="True" />
5757
<output name="outfile" file="multijoin_result1.txt" lines_diff="2" />
5858
</test>

tools/text_processing/text_processing/recurring_lines.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,27 @@
4444
<test>
4545
<repeat name="token_set">
4646
<param name="line" value="freedom" />
47-
<param name="repeat_select_opts" value="file" />
48-
<param name="infile" value="multijoin2.txt" />
47+
<conditional name="repeat_select">
48+
<param name="repeat_select_opts" value="file" />
49+
<param name="infile" value="multijoin2.txt" />
50+
</conditional>
4951
</repeat>
5052
<output name="outfile" file="recurring_result1.txt" />
5153
</test>
5254
<test>
5355
<repeat name="token_set">
5456
<param name="line" value="freedom" />
55-
<param name="repeat_select_opts" value="user" />
56-
<param name="times" value="10" />
57+
<conditional name="repeat_select">
58+
<param name="repeat_select_opts" value="user" />
59+
<param name="times" value="10" />
60+
</conditional>
5761
</repeat>
5862
<repeat name="token_set">
5963
<param name="line" value="war is over" />
60-
<param name="repeat_select_opts" value="user" />
61-
<param name="times" value="10" />
64+
<conditional name="repeat_select">
65+
<param name="repeat_select_opts" value="user" />
66+
<param name="times" value="10" />
67+
</conditional>
6268
</repeat>
6369
<output name="outfile" file="recurring_result2.txt" />
6470
</test>

tools/text_processing/text_processing/replace_text_in_column.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</macros>
66
<expand macro="creator"/>
77
<requirements>
8-
<requirement type="package" version="5.3.0">gawk</requirement>
8+
<requirement type="package" version="5.3.1">gawk</requirement>
99
</requirements>
1010
<version_command>awk --version | head -n 1</version_command>
1111
<command>
@@ -51,9 +51,11 @@
5151
<tests>
5252
<test>
5353
<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" />
54+
<repeat name="replacements">
55+
<param name="column" value="4" />
56+
<param name="find_pattern" value=".+_(R.)" />
57+
<param name="replace_pattern" value="\\1" />
58+
</repeat>
5759
<output name="outfile" file="replace_text_in_column_results1.txt" />
5860
</test>
5961
<test>

tools/text_processing/text_processing/replace_text_in_line.xml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
-r
1515
--sandbox
1616
#for $replacement in $replacements:
17+
-e '$replacement.sed_options'
1718
-e
1819
's/$replacement.find_pattern/$replacement.replace_pattern/g'
1920
#end for
@@ -47,10 +48,20 @@
4748
<add source="&#39;" target="&#39;&quot;&#39;&quot;&#39;" />
4849
<add source="/" target="\/"/>
4950
</mapping>
50-
5151
</sanitizer>
52-
53-
</param>
52+
</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="&#39;"/> <!-- Removes single quotes -->
57+
<remove value="/"/> <!-- Removes slashes -->
58+
</valid>
59+
<mapping initial="none">
60+
<add source="&#39;" target="&#39;&quot;&#39;&quot;&#39;" /> <!-- Escapes single quotes -->
61+
<add source="/" target="\/"/> <!-- Escapes slashes -->
62+
</mapping>
63+
</sanitizer>
64+
</param>
5465
</repeat>
5566
</inputs>
5667
<outputs>
@@ -59,22 +70,36 @@
5970
<tests>
6071
<test>
6172
<param name="infile" value="replace_text_in_line1.txt" />
62-
<param name="find_pattern" value="CTC." />
63-
<param name="replace_pattern" value="FOOBAR" />
73+
<repeat name="replacements">
74+
<param name="find_pattern" value="CTC." />
75+
<param name="replace_pattern" value="FOOBAR" />
76+
<param name="sed_options" value="" />
77+
</repeat>
6478
<output name="outfile" file="replace_text_in_line_results1.txt" />
6579
</test>
6680
<test>
6781
<param name="infile" value="replace_text_in_line1.txt" />
6882
<repeat name="replacements">
6983
<param name="find_pattern" value="CTC." />
7084
<param name="replace_pattern" value="FOOBAR" />
85+
<param name="sed_options" value="" />
7186
</repeat>
7287
<repeat name="replacements">
7388
<param name="find_pattern" value="chr" />
7489
<param name="replace_pattern" value="domain" />
90+
<param name="sed_options" value="" />
7591
</repeat>
7692
<output name="outfile" file="replace_text_in_line_results2.txt" />
7793
</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" />
102+
</test>
78103
</tests>
79104
<help>
80105
<![CDATA[
@@ -155,7 +180,9 @@ The select tool searches the data for lines containing or not containing a match
155180
- **\|** Separates alternate possibilities.
156181
157182
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
159186
160187
]]>
161188
</help>

tools/text_processing/text_processing/sed.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,19 @@
5656
<test>
5757
<param name="infile" value="sed1.txt" />
5858
<param name="code" value="1d ; s/foo/bar/" />
59-
<param name="silent" value="" />
59+
<conditional name="adv_opts">
60+
<param name="adv_opts_selector" value="advanced" />
61+
<param name="silent" value="" />
62+
</conditional>
6063
<output name="output" file="sed_results1.txt" />
6164
</test>
6265
<test>
6366
<param name="infile" value="sed1.txt" />
6467
<param name="code" value="/foo/ { s/foo/baz/g ; p }" />
65-
<param name="adv_opts_selector" value="advanced" />
66-
<param name="silent" value="-n" />
68+
<conditional name="adv_opts">
69+
<param name="adv_opts_selector" value="advanced" />
70+
<param name="silent" value="-n" />
71+
</conditional>
6772
<output name="output" file="sed_results2.txt" />
6873
</test>
6974
</tests>

tools/text_processing/text_processing/sort.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<command>
1212
<![CDATA[
1313
(
14-
LC_ALL=C
14+
LC_ALL=C;
1515
#if int($header) > 0:
1616
sed -u '${header}'q &&
1717
#end if

0 commit comments

Comments
 (0)