annotate tools/unix_tools/sed_tool.xml @ 1:cdcb0ce84a1b

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