annotate tools/unix_tools/grep_tool.xml @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 <tool id="cshl_grep_tool" name="grep">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 <description></description>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 <command interpreter="sh">grep_wrapper.sh $input $output '$url_paste' $color -A $lines_after -B $lines_before $invert $case_sensitive</command>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 <inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 <param format="txt" name="input" type="data" label="Select lines from" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 <param name="invert" type="select" label="that">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 <option value="">Match</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 <option value="-v">Don't Match</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 <!-- Note: the parameter ane MUST BE 'url_paste' -
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 This is a hack in the galaxy library (see ./lib/galaxy/util/__init__.py line 142)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 If the name is 'url_paste' the string won't be sanitized, and all the non-alphanumeric characters
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 will be passed to the shell script -->
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 <param name="url_paste" type="text" size="40" label="Regular Expression" help="">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 <validator type="expression" message="Invalid Program!">value.find('\'')==-1</validator>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 <param name="case_sensitive" type="select" label="Match type">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 <option value="-i">case insensitive</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 <option value="">case sensitive</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 <param name="lines_before" type="integer" label="Show lines preceding the matched line" help="(same as grep -B, leave it at zero unless you know what you're doing)" value="0" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 <param name="lines_after" type="integer" label="Show lines trailing the matched line" help="(same as grep -A, leave it at zero unless you know what you're doing)" value="0" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 <param name="color" type="select" label="Output">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 <option value="NOCOLOR">text file (for further processing)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 <option value="COLOR">Highlighted HTML (for easier viewing)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 </inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 <tests>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 <test>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 <!-- grep a FASTA file for sequences with specific motif -->
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 <param name="input" value="unix_grep_input1.txt" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 <output name="output" file="unix_grep_output1.txt" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 <param name="case_sensitive" value="case sensitive" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 <param name="invert" value="" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 <param name="url_paste" value="AA.{2}GT" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42 <param name="lines_before" value="1" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 <param name="lines_after" value="0" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 <param name="color" value="NOCOLOR" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 </test>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 <test>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 <!-- grep a FASTA file for sequences with specific motif -
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 show highlighed output -->
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 <param name="input" value="unix_grep_input1.txt" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 <output name="output" file="unix_grep_output2.html" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 <param name="case_sensitive" value="case sensitive" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52 <param name="invert" value="" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53 <param name="url_paste" value="AA.{2}GT" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 <param name="lines_before" value="0" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55 <param name="lines_after" value="0" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
56 <param name="color" value="COLOR" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
57 </test>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
58 </tests>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
59 <outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
60 <data format="input" name="output" metadata_source="input" >
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
61 <change_format>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
62 <when input="color" value="COLOR" format="HTML" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
63 </change_format>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
64 </data>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
65 </outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
66 <help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
67
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
68 **What it does**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
69
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
70 This tool runs the unix **grep** command on the selected data file.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
71
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
72 .. class:: infomark
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
73
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
74 **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).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
75
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
76
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
77 **Further reading**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
78
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
79 - Wikipedia's Regular Expression page (http://en.wikipedia.org/wiki/Regular_expression)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
80 - Regular Expressions cheat-sheet (PDF) (http://www.addedbytes.com/cheat-sheets/download/regular-expressions-cheat-sheet-v2.pdf)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
81 - Grep Tutorial (http://www.panix.com/~elflord/unix/grep.html)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
82
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
83 -----
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
84
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
85 **Grep Examples**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
86
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
87 - **AGC.AAT** would match lines with AGC followed by any character, followed by AAT (e.g. **AGCQAAT**, **AGCPAAT**, **AGCwAAT**)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
88 - **C{2,5}AGC** would match lines with 2 to 5 consecutive Cs followed by AGC
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
89 - **TTT.{4,10}AAA** would match lines with 3 Ts, followed by 4 to 10 characters (any characeters), followed by 3 As.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
90 - **^chr([0-9A-Za-z])+** would match lines that begin with chromsomes, such as lines in a BED format file.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
91 - **(ACGT){1,5}** would match at least 1 "ACGT" and at most 5 "ACGT" consecutively.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
92 - **hsa|mmu** would match lines containing "hsa" or "mmu" (or both).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
93
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
94 -----
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
95
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
96 **Regular Expression Syntax**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
97
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
98 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.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
99
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
100 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
101 - **^** matches the beginning of a string(but not an internal line).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
102 - **\\d** matches a digit, same as [0-9].
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
103 - **\\D** matches a non-digit.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
104 - **\\s** matches a whitespace character.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
105 - **\\S** matches anything BUT a whitespace.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
106 - **\\t** matches a tab.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
107 - **\\w** matches an alphanumeric character ( A to Z, 0 to 9 and underscore )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
108 - **\\W** matches anything but an alphanumeric character.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
109 - **(** .. **)** groups a particular pattern.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
110 - **\\Z** matches the end of a string(but not a internal line).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
111 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
112
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
113 - **{n}** The preceding item is matched exactly n times.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
114 - **{n,}** The preceding item ismatched n or more times.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
115 - **{n,m}** The preceding item is matched at least n times but not more than m times.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
116
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
117 - **[** ... **]** 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**.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
118 - **.** Matches any single character except a newline.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
119 - ***** The preceding item will be matched zero or more times.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
120 - **?** The preceding item is optional and matched at most once.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
121 - **+** The preceding item will be matched one or more times.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
122 - **^** has two meaning:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
123 - matches the beginning of a line or string.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
124 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
125 - **$** matches the end of a line or string.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
126 - **\|** Separates alternate possibilities.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
127
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
128
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
129 </help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
130 </tool>