root/galaxy-central/tools/unix_tools/grep_tool.xml

リビジョン 3, 5.9 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

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