Mercurial > repos > bgruening > text_processing
annotate sed.xml @ 12:062ed2bb4f2e draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f8896018f5b980a456c4ceaffe0ed457dc80b5a8
| author | bgruening |
|---|---|
| date | Thu, 02 Jun 2016 08:58:39 -0400 |
| parents | d64eace4f9f3 |
| children | 3c685c4106b3 |
| rev | line source |
|---|---|
| 4 | 1 <tool id="tp_sed_tool" name="Text transformation" version="@BASE_VERSION@.0"> |
| 2 <description>with sed</description> | |
| 3 <macros> | |
| 4 <import>macros.xml</import> | |
| 5 </macros> | |
| 6 <expand macro="requirements"> | |
|
12
062ed2bb4f2e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f8896018f5b980a456c4ceaffe0ed457dc80b5a8
bgruening
parents:
7
diff
changeset
|
7 <requirement type="package" version="4.2.2">sed</requirement> |
| 4 | 8 </expand> |
| 9 <version_command>sed --version | head -n 1</version_command> | |
| 1 | 10 <command> |
| 4 | 11 <![CDATA[ |
| 6 | 12 sed |
| 4 | 13 --sandbox |
| 14 -r | |
| 15 #if $adv_opts.adv_opts_selector == 'advanced': | |
| 16 $adv_opts.silent | |
| 17 #end if | |
| 18 -f '$sed_script' | |
| 19 '$infile' | |
| 20 > '$output' | |
| 21 ]]> | |
| 1 | 22 </command> |
| 23 <inputs> | |
| 4 | 24 <param format="txt" name="infile" type="data" label="File to process" /> |
| 6 | 25 <param name="code" type="text" area="true" size="5x35" label="SED Program" help=""> |
| 1 | 26 <sanitizer> |
| 27 <valid initial="string.printable"> | |
| 28 <remove value="'"/> | |
| 29 </valid> | |
| 30 </sanitizer> | |
| 31 </param> | |
| 32 <conditional name="adv_opts"> | |
| 33 <param name="adv_opts_selector" type="select" label="Advanced Options"> | |
| 34 <option value="basic" selected="True">Hide Advanced Options</option> | |
| 35 <option value="advanced">Show Advanced Options</option> | |
| 36 </param> | |
| 37 <when value="basic" /> | |
| 38 <when value="advanced"> | |
| 6 | 39 <param name="silent" type="select" label="Operation mode" help="Same as 'sed -n', leave at 'normal' unless you know what you're doing." > |
| 1 | 40 <option value="">normal</option> |
| 41 <option value="-n">silent</option> | |
| 42 </param> | |
| 43 </when> | |
| 44 </conditional> | |
| 4 | 45 </inputs> |
| 0 | 46 <configfiles> |
| 4 | 47 <configfile name="sed_script"> |
| 6 | 48 $code |
| 4 | 49 </configfile> |
| 50 </configfiles> | |
| 51 <outputs> | |
| 6 | 52 <data name="output" format_source="infile" metadata_source="infile" /> |
| 4 | 53 </outputs> |
| 54 <tests> | |
| 55 <test> | |
| 6 | 56 <param name="infile" value="sed1.txt" /> |
| 57 <param name="code" value="1d ; s/foo/bar/" /> | |
| 4 | 58 <param name="silent" value="" /> |
| 6 | 59 <output name="output" file="sed_results1.txt" /> |
| 4 | 60 </test> |
| 61 <test> | |
| 6 | 62 <param name="infile" value="sed1.txt" /> |
| 63 <param name="code" value="/foo/ { s/foo/baz/g ; p }" /> | |
| 64 <param name="adv_opts_selector" value="advanced" /> | |
| 65 <param name="silent" value="-n" /> | |
| 66 <output name="output" file="sed_results2.txt" /> | |
| 4 | 67 </test> |
| 68 </tests> | |
| 69 <help> | |
| 70 <![CDATA[ | |
| 0 | 71 **What it does** |
| 72 | |
| 73 This tool runs the unix **sed** command on the selected data file. | |
| 74 | |
| 75 .. class:: infomark | |
| 76 | |
| 77 **TIP:** This tool uses the **extended regular** expression syntax (same as running 'sed -r'). | |
| 78 | |
| 79 | |
| 80 | |
| 81 **Further reading** | |
| 82 | |
| 83 - Short sed tutorial (http://www.linuxhowtos.org/System/sed_tutorial.htm) | |
| 84 - Long sed tutorial (http://www.grymoire.com/Unix/Sed.html) | |
| 85 - sed faq with good examples (http://sed.sourceforge.net/sedfaq.html) | |
| 86 - sed cheat-sheet (http://www.catonmat.net/download/sed.stream.editor.cheat.sheet.pdf) | |
| 87 - Collection of useful sed one-liners (http://student.northpark.edu/pemente/sed/sed1line.txt) | |
| 88 | |
| 89 ----- | |
| 90 | |
| 91 **Sed commands** | |
| 92 | |
| 93 The most useful sed command is **s** (substitute). | |
| 94 | |
| 95 **Examples** | |
| 96 | |
| 97 - **s/hsa//** will remove the first instance of 'hsa' in every line. | |
| 98 - **s/hsa//g** will remove all instances (beacuse of the **g**) of 'hsa' in every line. | |
| 6 | 99 - **s/A{4,}/--&--/g** will find sequences of 4 or more consecutive A's, and once found, will surround them with two dashes from each side. The **&** marker is a place holder for 'whatever matched the regular expression'. |
| 100 - **s/hsa-mir-([^ ]+)/short name: \\1 full name: &/** 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**) . | |
| 0 | 101 |
| 102 | |
| 103 **sed's Regular Expression Syntax** | |
| 104 | |
| 7 | 105 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 | 106 |
| 107 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
| 108 - **^** matches the beginning of a string(but not an internal line). | |
| 109 - **(** .. **)** groups a particular pattern. | |
| 110 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
| 111 | |
| 112 - **{n}** The preceding item is matched exactly n times. | |
| 7 | 113 - **{n,}** The preceding item ismatched n or more times. |
| 114 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
| 0 | 115 |
| 116 - **[** ... **]** 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**. | |
| 117 - **.** Matches any single character except a newline. | |
| 118 - ***** The preceding item will be matched zero or more times. | |
| 119 - **?** The preceding item is optional and matched at most once. | |
| 120 - **+** The preceding item will be matched one or more times. | |
| 121 - **^** has two meaning: | |
| 7 | 122 - matches the beginning of a line or string. |
| 0 | 123 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. |
| 124 - **$** matches the end of a line or string. | |
| 7 | 125 - **\|** Separates alternate possibilities. |
| 0 | 126 |
| 127 | |
| 128 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. | |
| 129 | |
| 4 | 130 @REFERENCES@ |
| 131 ]]> | |
| 7 | 132 </help> |
| 0 | 133 </tool> |
