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