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

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

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

行番号 
1<tool id="cshl_sed_tool" name="sed">
2  <description></description>
3  <!-- NOTE
4          'sandbox' is a patched SED program,
5          which blocks executing shell commands and file reading/writing.
6
7          Hopefully, it is safe enough to allow users to execute their own SED commands
8          -->
9  <command interpreter="sh">sed_wrapper.sh $silent $input $output '$url_paste'</command>
10  <inputs>
11    <param format="txt" name="input" type="data" label="File to process" />
12
13    <!-- Note: the parameter ane MUST BE 'url_paste' -
14         This is a hack in the galaxy library (see ./lib/galaxy/util/__init__.py line 142)
15         If the name is 'url_paste' the string won't be sanitized, and all the non-alphanumeric characters
16         will be passed to the shell script -->
17    <param name="url_paste" type="text" area="true" size="5x35" label="SED Program" help="">
18        <validator type="expression" message="Invalid Program!">value.find('\'')==-1</validator>
19    </param>
20
21    <param name="silent" type="select"  label="operation mode" help="(Same as 'sed -n', leave at 'normal' unless you know what you're doing)" >
22      <option value="">normal</option>
23      <option value="-n">silent</option>
24    </param>
25
26  </inputs>
27  <outputs>
28    <data format="input" name="output" metadata_source="input" />
29  </outputs>
30<help>
31
32**What it does**
33
34This tool runs the unix **sed** command on the selected data file.
35
36.. class:: infomark
37
38**TIP:** This tool uses the **extended regular** expression syntax (same as running 'sed -r').
39
40
41
42**Further reading**
43
44- Short sed tutorial (http://www.linuxhowtos.org/System/sed_tutorial.htm)
45- Long sed tutorial (http://www.grymoire.com/Unix/Sed.html)
46- sed faq with good examples (http://sed.sourceforge.net/sedfaq.html)
47- sed cheat-sheet (http://www.catonmat.net/download/sed.stream.editor.cheat.sheet.pdf)
48- Collection of useful sed one-liners (http://student.northpark.edu/pemente/sed/sed1line.txt)
49
50-----
51
52**Sed commands**
53
54The most useful sed command is **s** (substitute).
55
56**Examples**
57
58- **s/hsa//**  will remove the first instance of 'hsa' in every line.
59- **s/hsa//g**  will remove all instances (beacuse of the **g**) of 'hsa' in every line.
60- **s/A{4,}/--&amp;--/g**  will find sequences of 4 or more consecutive A's, and once found, will surround them with two dashes from each side. The **&amp;** marker is a place holder for 'whatever matched the regular expression'.
61- **s/hsa-mir-([^ ]+)/short name: \\1 full name: &amp;/**  will find strings such as 'hsa-mir-43a' (the regular expression is 'hsa-mir-' followed by non-space characters) and will replace it will string such as 'short name: 43a full name: hsa-mir-43a'.  The **\\1** marker is a place holder for 'whatever matched the first parenthesis' (similar to perl's **$1**) .
62
63
64**sed's Regular Expression Syntax**
65
66The 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.
67
68- **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
69- **^** matches the beginning of a string(but not an internal line).
70- **(** .. **)** groups a particular pattern.
71- **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
72
73  - **{n}** The preceding item is matched exactly n times.
74  - **{n,}** The preceding item ismatched n or more times.
75  - **{n,m}** The preceding item is matched at least n times but not more than m times.
76
77- **[** ... **]** 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**.
78- **.** Matches any single character except a newline.
79- ***** The preceding item will be matched zero or more times.
80- **?** The preceding item is optional and matched at most once.
81- **+** The preceding item will be matched one or more times.
82- **^** has two meaning:
83  - matches the beginning of a line or string.
84  - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
85- **$** matches the end of a line or string.
86- **\|** Separates alternate possibilities.
87
88
89**Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported.
90
91</help>
92</tool>
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。