/tools/filters/grep.xml
XML | 73 lines | 62 code | 11 blank | 0 comment | 0 complexity | 653fa6a5f120f1f6b12427aa1a7dd6bb MD5 | raw file
1<tool id="Grep1" name="Select">
2 <description>lines that match an expression</description>
3 <command interpreter="python">grep.py -i $input -o $out_file1 -pattern '$pattern' -v $invert</command>
4 <inputs>
5 <param format="txt" name="input" type="data" label="Select lines from"/>
6 <param name="invert" type="select" label="that">
7 <option value="false">Matching</option>
8 <option value="true">NOT Matching</option>
9 </param>
10 <param name="pattern" size="40" type="text" value="^chr([0-9A-Za-z])+" label="the pattern" help="here you can enter text or regular expression (for syntax check lower part of this frame)"/>
11 </inputs>
12 <outputs>
13 <data format="input" name="out_file1" metadata_source="input"/>
14 </outputs>
15 <tests>
16 <test>
17 <param name="input" value="1.bed"/>
18 <param name="invert" value="false"/>
19 <param name="pattern" value="^chr[0-9]*"/>
20 <output name="out_file1" file="fs-grep.dat"/>
21 </test>
22 </tests>
23 <help>
24
25.. class:: infomark
26
27**TIP:** If your data is not TAB delimited, use *Text Manipulation->Convert*
28
29-----
30
31**Syntax**
32
33The select tool searches the data for lines containing or not containing a match to the given pattern. Regular Expression is introduced in this tool. A Regular Expression is a pattern descibing a certain amount of text.
34
35- **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
36- **\\A** matches the beginning of a string(but not an internal line).
37- **\\d** matches a digit, same as [0-9].
38- **\\D** matches a non-digit.
39- **\\s** matches a whitespace character.
40- **\\S** matches anything BUT a whitespace.
41- **\\t** matches a tab.
42- **\\w** matches an alphanumeric character.
43- **\\W** matches anything but an alphanumeric character.
44- **(** .. **)** groups a particular pattern.
45- **\\Z** matches the end of a string(but not a internal line).
46- **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
47
48 - **{n}** The preceding item is matched exactly n times.
49 - **{n,}** The preceding item ismatched n or more times.
50 - **{n,m}** The preceding item is matched at least n times but not more than m times.
51
52- **[** ... **]** 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**.
53- **.** Matches any single character except a newline.
54- ***** The preceding item will be matched zero or more times.
55- **?** The preceding item is optional and matched at most once.
56- **+** The preceding item will be matched one or more times.
57- **^** has two meaning:
58 - matches the beginning of a line or string.
59 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
60- **$** matches the end of a line or string.
61- **\|** Separates alternate possibilities.
62
63-----
64
65**Example**
66
67- **^chr([0-9A-Za-z])+** would match lines that begin with chromsomes, such as lines in a BED format file.
68- **(ACGT){1,5}** would match at least 1 "ACGT" and at most 5 "ACGT" consecutively.
69- **([^,][0-9]{1,3})(,[0-9]{3})\*** would match a large integer that is properly seperated with commas such as 23,078,651.
70- **(abc)|(def)** would match either "abc" or "def".
71- **^\\W+#** would match any line that is a comment.
72</help>
73</tool>