comparison grep.xml @ 0:5314e5d6f040 draft

Imported from capsule None
author bgruening
date Thu, 29 Jan 2015 07:53:17 -0500
parents
children 43b1f073b693
comparison
equal deleted inserted replaced
-1:000000000000 0:5314e5d6f040
1 <tool id="tp_grep_tool" name="Search in textfiles" version="@BASE_VERSION@.0">
2 <description>(grep)</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="requirements">
7 <requirement type="package" version="2.14">gnu_grep</requirement>
8 <requirement type="set_environment">TP_SCRIPT_PATH</requirement>
9 </expand>
10 <version_command>grep --version | head -n 1</version_command>
11 <command>
12 <![CDATA[
13 #if str($color) == "COLOR":
14 GREP_COLOR='1;34'
15 grep
16 --color=always
17 -P
18 -A $lines_after
19 -B $lines_before
20 $invert
21 $case_sensitive
22 -- "${url_paste}"
23 '${infile}' | \$TP_SCRIPT_PATH/ansi2html.sh > "${output}"
24 #else:
25 grep
26 -P
27 -A $lines_after
28 -B $lines_before
29 $invert
30 $case_sensitive
31 -- "${url_paste}"
32 '${infile}' | grep -v "^--$" > "${output}"
33 #end if
34
35 ##grep_wrapper.sh '$infile' '$output' '$url_paste' $color -A $lines_after -B $lines_before $invert $case_sensitive
36 ]]>
37 </command>
38 <inputs>
39 <param name="infile" format="txt" type="data" label="Select lines from" />
40
41 <param name="invert" type="select" label="that">
42 <option value="">Match</option>
43 <option value="-v">Don't Match</option>
44 </param>
45
46 <param name="url_paste" type="text" size="40" label="Regular Expression" help="See below for more details">
47 <sanitizer>
48 <valid initial="string.printable">
49 <remove value="&apos;"/>
50 </valid>
51 </sanitizer>
52 </param>
53
54 <param name="case_sensitive" type="select" label="Match type" help="(-i)">
55 <option value="-i">case insensitive</option>
56 <option value="">case sensitive</option>
57 </param>
58 <param name="lines_before" type="integer" value="0"
59 label="Show lines preceding the matched line" help="leave it at zero unless you know what you're doing. (-B)" />
60 <param name="lines_after" type="integer" value="0"
61 label="Show lines trailing the matched line" help="leave it at zero unless you know what you're doing. (-A)" />
62 <param name="color" type="select" label="Output">
63 <option value="NOCOLOR">text file (for further processing)</option>
64 <option value="COLOR">Highlighted HTML (for easier viewing)</option>
65 </param>
66
67 </inputs>
68 <outputs>
69 <data name="output" format_source="infile" metadata_source="infile">
70 <change_format>
71 <when input="color" value="COLOR" format="html"/>
72 </change_format>
73 </data>
74 </outputs>
75 <tests>
76 <test>
77 <!-- grep a FASTA file for sequences with specific motif -->
78 <param name="infile" value="grep1.txt" />
79 <param name="case_sensitive" value="case sensitive" />
80 <param name="invert" value="" />
81 <param name="url_paste" value="AA.{2}GT" />
82 <param name="lines_before" value="1" />
83 <param name="lines_after" value="0" />
84 <param name="color" value="NOCOLOR" />
85 <output name="output" file="grep_results1.txt" />
86 </test>
87 <test>
88 <!-- grep a FASTA file for sequences with specific motif -
89 show highlighed output -->
90 <param name="infile" value="grep1.txt" />
91 <param name="case_sensitive" value="case sensitive" />
92 <param name="invert" value="" />
93 <param name="url_paste" value="AA.{2}GT" />
94 <param name="lines_before" value="0" />
95 <param name="lines_after" value="0" />
96 <param name="color" value="COLOR" />
97 <output name="output" file="grep_results2.html" />
98 </test>
99 </tests>
100 <help>
101 <![CDATA[
102 **What it does**
103
104 This tool runs the unix **grep** command on the selected data file.
105
106 .. class:: infomark
107
108 **TIP:** This tool uses the **perl** regular expression syntax (same as running 'grep -P'). This is **NOT** the POSIX or POSIX-extended syntax (unlike the awk/sed tools).
109
110
111 **Further reading**
112
113 - Wikipedia's Regular Expression page (http://en.wikipedia.org/wiki/Regular_expression)
114 - Regular Expressions cheat-sheet (PDF) (http://www.addedbytes.com/cheat-sheets/download/regular-expressions-cheat-sheet-v2.pdf)
115 - Grep Tutorial (http://www.panix.com/~elflord/unix/grep.html)
116
117 -----
118
119 **Grep Examples**
120
121 - **AGC.AAT** would match lines with AGC followed by any character, followed by AAT (e.g. **AGCQAAT**, **AGCPAAT**, **AGCwAAT**)
122 - **C{2,5}AGC** would match lines with 2 to 5 consecutive Cs followed by AGC
123 - **TTT.{4,10}AAA** would match lines with 3 Ts, followed by 4 to 10 characters (any characeters), followed by 3 As.
124 - **^chr([0-9A-Za-z])+** would match lines that begin with chromsomes, such as lines in a BED format file.
125 - **(ACGT){1,5}** would match at least 1 "ACGT" and at most 5 "ACGT" consecutively.
126 - **hsa|mmu** would match lines containing "hsa" or "mmu" (or both).
127
128 -----
129
130 **Regular Expression Syntax**
131
132 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.
133
134 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
135 - **^** matches the beginning of a string(but not an internal line).
136 - **\\d** matches a digit, same as [0-9].
137 - **\\D** matches a non-digit.
138 - **\\s** matches a whitespace character.
139 - **\\S** matches anything BUT a whitespace.
140 - **\\t** matches a tab.
141 - **\\w** matches an alphanumeric character ( A to Z, 0 to 9 and underscore )
142 - **\\W** matches anything but an alphanumeric character.
143 - **(** .. **)** groups a particular pattern.
144 - **\\Z** matches the end of a string(but not a internal line).
145 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
146
147 - **{n}** The preceding item is matched exactly n times.
148 - **{n,}** The preceding item ismatched n or more times.
149 - **{n,m}** The preceding item is matched at least n times but not more than m times.
150
151 - **[** ... **]** 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**.
152 - **.** Matches any single character except a newline.
153 - ***** The preceding item will be matched zero or more times.
154 - **?** The preceding item is optional and matched at most once.
155 - **+** The preceding item will be matched one or more times.
156 - **^** has two meaning:
157 - matches the beginning of a line or string.
158 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
159 - **$** matches the end of a line or string.
160 - **\|** Separates alternate possibilities.
161
162 @REFERENCES@
163 ]]>
164 </help>
165 </tool>