Mercurial > repos > bgruening > text_processing
annotate grep.xml @ 10:c78b1767db2b 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:54 -0500 |
parents | fa7f88da29d7 |
children | 062ed2bb4f2e |
rev | line source |
---|---|
4 | 1 <tool id="tp_grep_tool" name="Search in textfiles" version="@BASE_VERSION@.0"> |
0 | 2 <description>(grep)</description> |
4 | 3 <macros> |
4 <import>macros.xml</import> | |
5 </macros> | |
6 <expand macro="requirements"> | |
0 | 7 <requirement type="package" version="2.14">gnu_grep</requirement> |
4 | 8 </expand> |
9 <version_command>grep --version | head -n 1</version_command> | |
2 | 10 <command> |
4 | 11 <![CDATA[ |
2 | 12 #if str($color) == "COLOR": |
4 | 13 GREP_COLOR='1;34' |
14 grep | |
15 --color=always | |
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
16 $regex_type |
4 | 17 -A $lines_after |
18 -B $lines_before | |
19 $invert | |
20 $case_sensitive | |
21 -- "${url_paste}" | |
8
fa7f88da29d7
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 369e40078146d00608d52205bb8cee66ae735b76-dirty
bgruening
parents:
7
diff
changeset
|
22 '${infile}' | $__tool_directory__/ansi2html.sh > "${output}" |
0 | 23 #else: |
4 | 24 grep |
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
25 $regex_type |
4 | 26 -A $lines_after |
27 -B $lines_before | |
28 $invert | |
29 $case_sensitive | |
30 -- "${url_paste}" | |
31 '${infile}' | grep -v "^--$" > "${output}" | |
0 | 32 #end if |
33 | |
4 | 34 ##grep_wrapper.sh '$infile' '$output' '$url_paste' $color -A $lines_after -B $lines_before $invert $case_sensitive |
35 ]]> | |
0 | 36 </command> |
37 <inputs> | |
4 | 38 <param name="infile" format="txt" type="data" label="Select lines from" /> |
0 | 39 |
40 <param name="invert" type="select" label="that"> | |
41 <option value="">Match</option> | |
42 <option value="-v">Don't Match</option> | |
43 </param> | |
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
44 |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
45 <param name="regex_type" type="select" label="Type of regex"> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
46 <option value="-G">Basic</option> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
47 <option value="-P" selected="true">Perl</option> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
48 <option value="-E">Extended (egrep)</option> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
49 </param> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
50 |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
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 | |
4 | 59 <param name="case_sensitive" type="select" label="Match type" help="(-i)"> |
0 | 60 <option value="-i">case insensitive</option> |
61 <option value="">case sensitive</option> | |
62 </param> | |
4 | 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)" /> | |
0 | 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 | |
4 | 72 </inputs> |
73 <outputs> | |
6 | 74 <data name="output" format_source="infile" metadata_source="infile"> |
4 | 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 --> | |
6 | 83 <param name="infile" value="grep1.txt" /> |
4 | 84 <param name="case_sensitive" value="case sensitive" /> |
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
85 <param name="regex_type" value="-P" /> |
4 | 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" /> | |
6 | 91 <output name="output" file="grep_results1.txt" /> |
4 | 92 </test> |
93 <test> | |
94 <!-- grep a FASTA file for sequences with specific motif - | |
0 | 95 show highlighed output --> |
6 | 96 <param name="infile" value="grep1.txt" /> |
4 | 97 <param name="case_sensitive" value="case sensitive" /> |
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
98 <param name="regex_type" value="-P" /> |
4 | 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" /> | |
6 | 104 <output name="output" file="grep_results2.html" /> |
4 | 105 </test> |
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
106 <test><!-- tests egrep --> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
107 <param name="infile" value="egrep1.txt" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
108 <param name="case_sensitive" value="case sensitive" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
109 <param name="regex_type" value="-E" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
110 <param name="invert" value="" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
111 <param name="url_paste" value="[^ ]+" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
112 <param name="lines_before" value="0" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
113 <param name="lines_after" value="0" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
114 <param name="color" value="NOCOLOR" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
115 <output name="output" file="egrep_results1.txt" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
116 </test> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
117 <test><!-- same regex as egrep test, but different outcome with basic regex --> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
118 <param name="infile" value="egrep1.txt" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
119 <param name="case_sensitive" value="case sensitive" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
120 <param name="regex_type" value="-G" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
121 <param name="invert" value="" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
122 <param name="url_paste" value="[^ ]+" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
123 <param name="lines_before" value="0" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
124 <param name="lines_after" value="0" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
125 <param name="color" value="NOCOLOR" /> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
126 <output name="output" file="egrep_results2.txt" />> |
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
8
diff
changeset
|
127 </test> |
4 | 128 </tests> |
129 <help> | |
130 <![CDATA[ | |
0 | 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). | |
7 | 156 |
0 | 157 ----- |
158 | |
159 **Regular Expression Syntax** | |
160 | |
7 | 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. |
0 | 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. | |
7 | 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. | |
0 | 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: | |
7 | 186 - matches the beginning of a line or string. |
0 | 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. | |
7 | 189 - **\|** Separates alternate possibilities. |
0 | 190 |
4 | 191 @REFERENCES@ |
192 ]]> | |
193 </help> | |
0 | 194 </tool> |