Skip to content

Commit

Permalink
Merge pull request #1413 from bernt-matthias/fix/grep
Browse files Browse the repository at this point in the history
Fixes for grep tool
  • Loading branch information
bgruening authored Mar 28, 2024
2 parents f95acc6 + b985ba7 commit c4f50d1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
45 changes: 39 additions & 6 deletions tools/text_processing/text_processing/grep.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<requirement type="package" version="3.11">grep</requirement>
<requirement type="package" version="4.8">sed</requirement><!-- for ansi2html.sh -->
</requirements>
<stdio>
<exit_code range="2:" level="fatal" description="grep failed" />
</stdio>
<version_command>grep --version | head -n 1</version_command>
<command>
<![CDATA[
Expand All @@ -27,10 +30,11 @@
$regex_type
-A $lines_after
-B $lines_before
--no-group-separator
$invert
$case_sensitive
-- '${url_paste}'
'${infile}' | grep -v "^--$" > '${output}'
'${infile}' > '${output}'
#end if
]]>
</command>
Expand Down Expand Up @@ -78,8 +82,8 @@
</data>
</outputs>
<tests>
<!-- grep a FASTA file for sequences with specific motif -->
<test>
<!-- grep a FASTA file for sequences with specific motif -->
<param name="infile" value="grep1.txt" />
<param name="case_sensitive" value="case sensitive" />
<param name="regex_type" value="-P" />
Expand All @@ -90,9 +94,9 @@
<param name="color" value="NOCOLOR" />
<output name="output" file="grep_results1.txt" />
</test>
<test>
<!-- grep a FASTA file for sequences with specific motif -
<!-- grep a FASTA file for sequences with specific motif -
show highlighed output -->
<test>
<param name="infile" value="grep1.txt" />
<param name="case_sensitive" value="case sensitive" />
<param name="regex_type" value="-P" />
Expand All @@ -103,7 +107,8 @@
<param name="color" value="COLOR" />
<output name="output" file="grep_results2.html" />
</test>
<test><!-- tests egrep -->
<!-- tests egrep -->
<test>
<param name="infile" value="egrep1.txt" />
<param name="case_sensitive" value="case sensitive" />
<param name="regex_type" value="-E" />
Expand All @@ -114,7 +119,8 @@
<param name="color" value="NOCOLOR" />
<output name="output" file="egrep_results1.txt" />
</test>
<test><!-- tests basic regex; + must be backslashed to match -->
<!-- tests basic regex; + must be backslashed to match -->
<test>
<param name="infile" value="egrep1.txt" />
<param name="case_sensitive" value="case sensitive" />
<param name="regex_type" value="-G" />
Expand All @@ -125,6 +131,33 @@
<param name="color" value="NOCOLOR" />
<output name="output" file="egrep_results1.txt" />
</test>
<!-- tests regex;matching nothing -->
<test>
<param name="infile" value="egrep1.txt" />
<param name="case_sensitive" value="case sensitive" />
<param name="regex_type" value="-G" />
<param name="invert" value="" />
<param name="url_paste" value="not existent pattern" />
<param name="lines_before" value="0" />
<param name="lines_after" value="0" />
<param name="color" value="NOCOLOR" />
<output name="output">
<assert_contents>
<has_size value="0"/>
</assert_contents>
</output>
</test>
<!-- tests invalid regex; i.e. that we still get exit code 2 -->
<test expect_failure="true" expect_exit_code="2">
<param name="infile" value="egrep1.txt" />
<param name="case_sensitive" value="case sensitive" />
<param name="regex_type" value="-G" />
<param name="invert" value="" />
<param name="url_paste" value="\(" />
<param name="lines_before" value="0" />
<param name="lines_after" value="0" />
<param name="color" value="NOCOLOR" />
</test>
</tests>
<help>
<![CDATA[
Expand Down
2 changes: 1 addition & 1 deletion tools/text_processing/text_processing/macros.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</requirements>
</xml>
<token name="@TOOL_VERSION@">9.3</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">1</token>
<token name="@PROFILE@">23.1</token>
<xml name="stdio">
<stdio>
Expand Down

0 comments on commit c4f50d1

Please sign in to comment.