Mercurial > repos > bgruening > text_processing
annotate replace_text_in_line.xml @ 16:61b3b01662fd draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
| author | bgruening |
|---|---|
| date | Fri, 01 Dec 2017 13:46:51 -0500 |
| parents | 7725ab6dab67 |
| children | f2918761eaf3 |
| rev | line source |
|---|---|
|
16
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
1 <?xml version="1.0" encoding="UTF-8"?> |
| 4 | 2 <tool id="tp_replace_in_line" name="Replace Text" version="@BASE_VERSION@.0"> |
| 3 | 3 <description>in entire line</description> |
| 4 | 4 <macros> |
| 5 <import>macros.xml</import> | |
| 6 </macros> | |
|
13
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
12
diff
changeset
|
7 <requirements> |
|
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
12
diff
changeset
|
8 <requirement type="package" version="4.2.3.dev0">sed</requirement> |
|
3c685c4106b3
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
12
diff
changeset
|
9 </requirements> |
| 4 | 10 <version_command>sed --version | head -n 1</version_command> |
| 6 | 11 <command> |
|
16
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
12 <!-- |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
13 This looks quite strange but it is intentional. We have used U+0090 as |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
14 the replacement brackets in the sed expression. This meets multiple requirements for use: |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
15 |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
16 - is legal entity in XML 1.0 (https://en.wikipedia.org/wiki/Valid_characters_in_XML) |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
17 - is legal as a sed delimiter character (must be single-byte) |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
18 - is not in string.printable |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
19 |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
20 Thus, this should execute properly. Additionally it allows users to |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
21 use characters like '/' and '\' and '|' in their regex without them |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
22 being able to prematurely terminate the expression. |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
23 --> |
| 4 | 24 <![CDATA[ |
| 7 | 25 sed |
| 4 | 26 -r |
| 27 --sandbox | |
|
16
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
28 's$find_pattern$replace_patterng' |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
29 '$infile' |
|
61b3b01662fd
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5d3a6a822897569f22f288589543562f54482418
bgruening
parents:
14
diff
changeset
|
30 > '$outfile' |
| 4 | 31 ]]> |
| 3 | 32 </command> |
| 33 <inputs> | |
| 6 | 34 <param format="txt" name="infile" type="data" label="File to process" /> |
|
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
7
diff
changeset
|
35 <param name="find_pattern" type="text" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > |
| 3 | 36 <sanitizer> |
| 37 <valid initial="string.printable"> | |
| 38 <remove value="'"/> | |
| 39 </valid> | |
| 40 </sanitizer> | |
| 41 </param> | |
|
10
c78b1767db2b
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
7
diff
changeset
|
42 <param name="replace_pattern" type="text" label="Replace with:" help="Use simple text, or & (ampersand) and \\1 \\2 \\3 to refer to matched text. See examples below." > |
| 3 | 43 <sanitizer> |
| 44 <valid initial="string.printable"> | |
| 45 <remove value="'"/> | |
| 46 </valid> | |
| 47 </sanitizer> | |
| 48 </param> | |
| 49 </inputs> | |
| 50 <outputs> | |
| 6 | 51 <data name="outfile" format_source="infile" metadata_source="infile"/> |
| 3 | 52 </outputs> |
| 4 | 53 <tests> |
| 54 <test> | |
| 6 | 55 <param name="infile" value="replace_text_in_line1.txt" /> |
| 4 | 56 <param name="find_pattern" value="CTC." /> |
| 57 <param name="replace_pattern" value="FOOBAR" /> | |
| 6 | 58 <output name="outfile" file="replace_text_in_line_results1.txt" /> |
| 4 | 59 </test> |
| 60 </tests> | |
| 3 | 61 <help> |
| 4 | 62 <![CDATA[ |
| 3 | 63 **What it does** |
| 64 | |
| 6 | 65 This tool performs find & replace operation on a specified file. |
| 3 | 66 |
| 67 .. class:: infomark | |
| 68 | |
| 69 The **pattern to find** uses the **extended regular** expression syntax (same as running 'sed -r'). | |
| 70 | |
| 71 .. class:: infomark | |
| 72 | |
| 73 **TIP:** If you need more complex patterns, use the *sed* tool. | |
| 74 | |
| 75 ----- | |
| 76 | |
| 77 **Examples of Find Patterns** | |
| 78 | |
| 79 - **HELLO** The word 'HELLO' (case sensitive). | |
| 80 - **AG.T** The letters A,G followed by any single character, followed by the letter T. | |
| 81 - **A{4,}** Four or more consecutive A's. | |
| 82 - **chr2[012]\\t** The words 'chr20' or 'chr21' or 'chr22' followed by a tab character. | |
| 83 - **hsa-mir-([^ ]+)** The text 'hsa-mir-' followed by one-or-more non-space characters. When using parenthesis, the matched content of the parenthesis can be accessed with **\1** in the **replace** pattern. | |
| 84 | |
| 85 | |
| 86 **Examples of Replace Patterns** | |
| 87 | |
| 88 - **WORLD** The word 'WORLD' will be placed whereever the find pattern was found. | |
|
14
7725ab6dab67
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
13
diff
changeset
|
89 - **FOO-&-BAR** Each time the find pattern is found, it will be surrounded with 'FOO-' at the beginning and '-BAR' at the end. **&** (ampersand) represents the matched find pattern. |
| 3 | 90 - **\\1** The text which matched the first parenthesis in the Find Pattern. |
| 91 | |
| 92 | |
| 93 ----- | |
| 94 | |
| 95 **Example 1** | |
| 96 | |
| 97 **Find Pattern:** HELLO | |
| 98 **Replace Pattern:** WORLD | |
| 99 | |
| 100 Every time the word HELLO is found, it will be replaced with the word WORLD. | |
| 101 | |
| 102 | |
| 103 ----- | |
| 104 | |
| 105 **Example 2** | |
| 106 | |
| 7 | 107 **Find Pattern:** ^(.{4}) |
| 6 | 108 **Replace Pattern:** &\\t |
| 3 | 109 |
| 110 Find the first four characters in each line, and replace them with the same text, followed by a tab character. In practice - this will split the first line into two columns. | |
| 111 | |
| 112 | |
| 113 ----- | |
| 114 | |
| 115 **Extened Regular Expression Syntax** | |
| 116 | |
| 7 | 117 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. |
| 3 | 118 |
| 119 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
| 120 - **^** matches the beginning of a string(but not an internal line). | |
| 121 - **(** .. **)** groups a particular pattern. | |
| 122 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
| 123 | |
| 124 - **{n}** The preceding item is matched exactly n times. | |
| 7 | 125 - **{n,}** The preceding item ismatched n or more times. |
| 126 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
| 3 | 127 |
| 128 - **[** ... **]** 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**. | |
| 129 - **.** Matches any single character except a newline. | |
| 130 - ***** The preceding item will be matched zero or more times. | |
| 131 - **?** The preceding item is optional and matched at most once. | |
| 132 - **+** The preceding item will be matched one or more times. | |
| 133 - **^** has two meaning: | |
| 7 | 134 - matches the beginning of a line or string. |
| 3 | 135 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. |
| 136 - **$** matches the end of a line or string. | |
| 7 | 137 - **\|** Separates alternate possibilities. |
| 3 | 138 |
| 139 | |
| 140 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. | |
| 141 | |
| 4 | 142 @REFERENCES@ |
| 143 ]]> | |
| 3 | 144 </help> |
|
14
7725ab6dab67
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
13
diff
changeset
|
145 <expand macro="citations" /> |
| 3 | 146 </tool> |
