Mercurial > repos > bgruening > text_processing
annotate grep.xml @ 8:fa7f88da29d7 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 369e40078146d00608d52205bb8cee66ae735b76-dirty
author | bgruening |
---|---|
date | Tue, 30 Jun 2015 16:20:05 -0400 |
parents | d64eace4f9f3 |
children | c78b1767db2b |
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 | |
16 -P | |
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 |
25 -P | |
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> | |
44 | |
45 <param name="url_paste" type="text" size="40" label="Regular Expression" help="See below for more details"> | |
46 <sanitizer> | |
47 <valid initial="string.printable"> | |
48 <remove value="'"/> | |
49 </valid> | |
50 </sanitizer> | |
51 </param> | |
52 | |
4 | 53 <param name="case_sensitive" type="select" label="Match type" help="(-i)"> |
0 | 54 <option value="-i">case insensitive</option> |
55 <option value="">case sensitive</option> | |
56 </param> | |
4 | 57 <param name="lines_before" type="integer" value="0" |
58 label="Show lines preceding the matched line" help="leave it at zero unless you know what you're doing. (-B)" /> | |
59 <param name="lines_after" type="integer" value="0" | |
60 label="Show lines trailing the matched line" help="leave it at zero unless you know what you're doing. (-A)" /> | |
0 | 61 <param name="color" type="select" label="Output"> |
62 <option value="NOCOLOR">text file (for further processing)</option> | |
63 <option value="COLOR">Highlighted HTML (for easier viewing)</option> | |
64 </param> | |
65 | |
4 | 66 </inputs> |
67 <outputs> | |
6 | 68 <data name="output" format_source="infile" metadata_source="infile"> |
4 | 69 <change_format> |
70 <when input="color" value="COLOR" format="html"/> | |
71 </change_format> | |
72 </data> | |
73 </outputs> | |
74 <tests> | |
75 <test> | |
76 <!-- grep a FASTA file for sequences with specific motif --> | |
6 | 77 <param name="infile" value="grep1.txt" /> |
4 | 78 <param name="case_sensitive" value="case sensitive" /> |
79 <param name="invert" value="" /> | |
80 <param name="url_paste" value="AA.{2}GT" /> | |
81 <param name="lines_before" value="1" /> | |
82 <param name="lines_after" value="0" /> | |
83 <param name="color" value="NOCOLOR" /> | |
6 | 84 <output name="output" file="grep_results1.txt" /> |
4 | 85 </test> |
86 <test> | |
87 <!-- grep a FASTA file for sequences with specific motif - | |
0 | 88 show highlighed output --> |
6 | 89 <param name="infile" value="grep1.txt" /> |
4 | 90 <param name="case_sensitive" value="case sensitive" /> |
91 <param name="invert" value="" /> | |
92 <param name="url_paste" value="AA.{2}GT" /> | |
93 <param name="lines_before" value="0" /> | |
94 <param name="lines_after" value="0" /> | |
95 <param name="color" value="COLOR" /> | |
6 | 96 <output name="output" file="grep_results2.html" /> |
4 | 97 </test> |
98 </tests> | |
99 <help> | |
100 <![CDATA[ | |
0 | 101 **What it does** |
102 | |
103 This tool runs the unix **grep** command on the selected data file. | |
104 | |
105 .. class:: infomark | |
106 | |
107 **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). | |
108 | |
109 | |
110 **Further reading** | |
111 | |
112 - Wikipedia's Regular Expression page (http://en.wikipedia.org/wiki/Regular_expression) | |
113 - Regular Expressions cheat-sheet (PDF) (http://www.addedbytes.com/cheat-sheets/download/regular-expressions-cheat-sheet-v2.pdf) | |
114 - Grep Tutorial (http://www.panix.com/~elflord/unix/grep.html) | |
115 | |
116 ----- | |
117 | |
118 **Grep Examples** | |
119 | |
120 - **AGC.AAT** would match lines with AGC followed by any character, followed by AAT (e.g. **AGCQAAT**, **AGCPAAT**, **AGCwAAT**) | |
121 - **C{2,5}AGC** would match lines with 2 to 5 consecutive Cs followed by AGC | |
122 - **TTT.{4,10}AAA** would match lines with 3 Ts, followed by 4 to 10 characters (any characeters), followed by 3 As. | |
123 - **^chr([0-9A-Za-z])+** would match lines that begin with chromsomes, such as lines in a BED format file. | |
124 - **(ACGT){1,5}** would match at least 1 "ACGT" and at most 5 "ACGT" consecutively. | |
125 - **hsa|mmu** would match lines containing "hsa" or "mmu" (or both). | |
7 | 126 |
0 | 127 ----- |
128 | |
129 **Regular Expression Syntax** | |
130 | |
7 | 131 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 | 132 |
133 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
134 - **^** matches the beginning of a string(but not an internal line). | |
135 - **\\d** matches a digit, same as [0-9]. | |
136 - **\\D** matches a non-digit. | |
137 - **\\s** matches a whitespace character. | |
138 - **\\S** matches anything BUT a whitespace. | |
139 - **\\t** matches a tab. | |
140 - **\\w** matches an alphanumeric character ( A to Z, 0 to 9 and underscore ) | |
141 - **\\W** matches anything but an alphanumeric character. | |
142 - **(** .. **)** groups a particular pattern. | |
143 - **\\Z** matches the end of a string(but not a internal line). | |
144 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
145 | |
146 - **{n}** The preceding item is matched exactly n times. | |
7 | 147 - **{n,}** The preceding item ismatched n or more times. |
148 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
0 | 149 |
150 - **[** ... **]** 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**. | |
151 - **.** Matches any single character except a newline. | |
152 - ***** The preceding item will be matched zero or more times. | |
153 - **?** The preceding item is optional and matched at most once. | |
154 - **+** The preceding item will be matched one or more times. | |
155 - **^** has two meaning: | |
7 | 156 - matches the beginning of a line or string. |
0 | 157 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. |
158 - **$** matches the end of a line or string. | |
7 | 159 - **\|** Separates alternate possibilities. |
0 | 160 |
4 | 161 @REFERENCES@ |
162 ]]> | |
163 </help> | |
0 | 164 </tool> |