Mercurial > repos > bgruening > text_processing
annotate replace_text_in_column.xml @ 10:e39fceb6ab85 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit f48156f03164bde1f1be4826b2f0a1f16dc2cd2f
author | bgruening |
---|---|
date | Tue, 20 Feb 2018 09:24:19 -0500 |
parents | 60edf2f8c28f |
children | 74a8bef53a00 |
rev | line source |
---|---|
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
|
1 <tool id="tp_replace_in_column" name="Replace Text" version="@BASE_VERSION@.1"> |
0 | 2 <description>in a specific column</description> |
3 <macros> | |
4 <import>macros.xml</import> | |
5 </macros> | |
5
20344ce0c811
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
3
diff
changeset
|
6 <requirements> |
20344ce0c811
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
3
diff
changeset
|
7 <requirement type="package" version="4.1.3">gawk</requirement> |
20344ce0c811
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
bgruening
parents:
3
diff
changeset
|
8 </requirements> |
0 | 9 <version_command>awk --version | head -n 1</version_command> |
10 <command> | |
11 <![CDATA[ | |
12 awk | |
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
|
13 -v OFS="\t" |
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
|
14 -v FS="\t" |
0 | 15 --re-interval |
16 --sandbox '{ \$$column = gensub( /$find_pattern/, "$replace_pattern", "g", \$$column ) ; print \$0 ; }' | |
17 "$infile" | |
18 > "$outfile" | |
19 ]]> | |
20 </command> | |
21 <inputs> | |
22 <param format="tabular" name="infile" type="data" label="File to process" /> | |
23 <param name="column" label="in column" type="data_column" data_ref="infile" accept_default="true" /> | |
24 | |
3
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
25 <param name="find_pattern" type="text" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > |
0 | 26 <sanitizer> |
27 <valid initial="string.printable"> | |
28 <remove value="'"/> | |
29 </valid> | |
30 </sanitizer> | |
31 </param> | |
3
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
32 <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." > |
0 | 33 <sanitizer> |
34 <valid initial="string.printable"> | |
35 <remove value="'"/> | |
36 </valid> | |
37 </sanitizer> | |
38 </param> | |
39 </inputs> | |
40 <outputs> | |
41 <data name="outfile" format_source="infile" metadata_source="infile" /> | |
42 </outputs> | |
43 <tests> | |
44 <test> | |
45 <param name="infile" value="replace_text_in_column1.txt" ftype="tabular" /> | |
46 <param name="column" value="4" /> | |
47 <param name="find_pattern" value=".+_(R.)" /> | |
48 <param name="replace_pattern" value="\\1" /> | |
49 <output name="outfile" file="replace_text_in_column_results1.txt" /> | |
50 </test> | |
51 </tests> | |
52 <help> | |
53 <![CDATA[ | |
54 **What it does** | |
55 | |
56 This tool performs find & replace operation on a specified column in a given file. | |
57 | |
58 .. class:: infomark | |
59 | |
60 The **pattern to find** uses the **extended regular** expression syntax (same as running 'awk --re-interval'). | |
61 | |
62 .. class:: infomark | |
63 | |
64 **TIP:** If you need more complex patterns, use the *awk* tool. | |
65 | |
66 ----- | |
67 | |
68 | |
69 **Examples of Find Patterns** | |
70 | |
71 - **HELLO** The word 'HELLO' (case sensitive). | |
72 - **AG.T** The letters A,G followed by any single character, followed by the letter T. | |
73 - **A{4,}** Four or more consecutive A's. | |
74 - **chr2[012]\\t** The words 'chr20' or 'chr21' or 'chr22' followed by a tab character. | |
75 - **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. | |
76 | |
77 | |
78 **Examples of Replace Patterns** | |
79 | |
80 - **WORLD** The word 'WORLD' will be placed whereever the find pattern was found. | |
81 - **FOO-&-BAR** Each time the find pattern is found, it will be surrounded with 'FOO-' at the begining and '-BAR' at the end. **&** (ampersand) represents the matched find pattern. | |
82 - **\\1** The text which matched the first parenthesis in the Find Pattern. | |
83 | |
84 | |
85 ----- | |
86 | |
87 **Example 1** | |
88 | |
89 **Find Pattern:** HELLO | |
90 **Replace Pattern:** WORLD | |
91 | |
92 Every time the word HELLO is found, it will be replaced with the word WORLD. This operation affects only the selected column. | |
93 | |
94 ----- | |
95 | |
96 **Example 2** | |
97 | |
98 **Find Pattern:** ^(.{4}) | |
99 **Replace Pattern:** &\\t | |
100 | |
101 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. This operation affects only the selected column. | |
102 | |
103 | |
104 ----- | |
105 | |
106 **Extened Regular Expression Syntax** | |
107 | |
108 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. | |
109 | |
110 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. | |
111 - **^** matches the beginning of a string(but not an internal line). | |
112 - **(** .. **)** groups a particular pattern. | |
113 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. | |
114 | |
115 - **{n}** The preceding item is matched exactly n times. | |
116 - **{n,}** The preceding item ismatched n or more times. | |
117 - **{n,m}** The preceding item is matched at least n times but not more than m times. | |
118 | |
119 - **[** ... **]** 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**. | |
120 - **.** Matches any single character except a newline. | |
121 - ***** The preceding item will be matched zero or more times. | |
122 - **?** The preceding item is optional and matched at most once. | |
123 - **+** The preceding item will be matched one or more times. | |
124 - **^** has two meaning: | |
125 - matches the beginning of a line or string. | |
126 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. | |
127 - **$** matches the end of a line or string. | |
128 - **\|** Separates alternate possibilities. | |
129 | |
130 | |
131 **Note**: AWK uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. | |
132 | |
133 @REFERENCES@ | |
134 ]]> | |
135 </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
|
136 <expand macro="citations" /> |
0 | 137 </tool> |