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