annotate grep.xml @ 7:d64eace4f9f3 draft

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