upstream-extended/community/tools/text_processing/text_processing/recurring_lines.xml
1<tool id="tp_text_file_with_recurring_lines" name="Create text file" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
2 <description>with recurring lines</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="creator"/>
7 <expand macro="requirements" />
8 <version_command>yes --version | head -n 1</version_command>
9 <command>
10<![CDATA[
11 #for $token in $token_set:
12 #if str($token.repeat_select.repeat_select_opts) == 'user':
13 times=#echo $token.repeat_select.times#;
14 #else:
15 times=`wc -l $token.repeat_select.infile | awk '{print $1}'`;
16 #end if
17 yes -- '${token.line}' 2>/dev/null | head -n \$times >> '$outfile';
18 #end for
19]]>
20 </command>
21 <inputs>
22 <repeat name="token_set" title=" selection" min="1">
23 <param name="line" type="text"
24 label="Characters to insert" help="Specify the characters that will be inserted X times in every line">
25 <sanitizer>
26 <valid initial="default">
27 <add value="	" /> <!-- 	 is the HTML entity for a tab -->
28 </valid>
29 </sanitizer>
30 </param>
31 <conditional name="repeat_select">
32 <param name="repeat_select_opts" type="select" label="Specify the number of iterations by">
33 <option value="file">File (for each line in file)</option>
34 <option value="user" selected="True">User defined number</option>
35 </param>
36 <when value="user">
37 <param name="times" type="integer" value="10" min="1" label="How many times?"/>
38 </when>
39 <when value="file">
40 <param name="infile" type="data" format="txt" label="Template file"
41 help="For every line, the specified characters will be written once. That means X is the line-number from the given file."/>
42 </when>
43 </conditional>
44 </repeat>
45 </inputs>
46 <outputs>
47 <data format="txt" name="outfile"/>
48 </outputs>
49 <tests>
50 <test>
51 <repeat name="token_set">
52 <param name="line" value="freedom" />
53 <conditional name="repeat_select">
54 <param name="repeat_select_opts" value="file" />
55 <param name="infile" value="multijoin2.txt" />
56 </conditional>
57 </repeat>
58 <output name="outfile" file="recurring_result1.txt" />
59 </test>
60 <test>
61 <repeat name="token_set">
62 <param name="line" value="freedom" />
63 <conditional name="repeat_select">
64 <param name="repeat_select_opts" value="user" />
65 <param name="times" value="10" />
66 </conditional>
67 </repeat>
68 <repeat name="token_set">
69 <param name="line" value="war is over" />
70 <conditional name="repeat_select">
71 <param name="repeat_select_opts" value="user" />
72 <param name="times" value="10" />
73 </conditional>
74 </repeat>
75 <output name="outfile" file="recurring_result2.txt" />
76 </test>
77 <test>
78 <repeat name="token_set">
79 <param name="line" value="a	b	c	d	e	f" />
80 <conditional name="repeat_select">
81 <param name="repeat_select_opts" value="user" />
82 <param name="times" value="2" />
83 </conditional>
84 </repeat>
85 <repeat name="token_set">
86 <param name="line" value="2	3	4	5	6	7" />
87 <conditional name="repeat_select">
88 <param name="repeat_select_opts" value="user" />
89 <param name="times" value="1" />
90 </conditional>
91 </repeat>
92 <repeat name="token_set">
93 <param name="line" value="1	2	3	4	5	6" />
94 <conditional name="repeat_select">
95 <param name="repeat_select_opts" value="user" />
96 <param name="times" value="1" />
97 </conditional>
98 </repeat>
99 <output name="outfile" file="sort_rows_results1.bed" />
100 </test>
101 </tests>
102 <help>
103<![CDATA[
104.. class:: infomark
105
106**What it does**
107
108This tool creates a text file with recurring lines. You can specify a bunch of characters or entire sentences.
109The entire string will be printed X times separated by a line break. X can be either given by the use as a number or calculated by a given file.
110In case the user provides a file, the line number will be used as X.
111
112]]>
113 </help>
114 <expand macro="citations" />
115</tool>