0
|
1 <tool id="wc_gnu" name="Line/Word/Character count">
|
|
2 <description>of a dataset</description>
|
|
3 <command>
|
|
4 #set $word_to_arg = { 'characters':'m', 'words':'w', 'lines':'l' }
|
|
5 #set $arg_order = [ 'lines', 'words', 'characters' ]
|
|
6 #if not isinstance( $options.value, list ):
|
|
7 #set $args = [ $options.value ]
|
|
8 #else:
|
|
9 #set $args = $options.value
|
|
10 #end if
|
|
11 #if $include_header.value:
|
|
12 echo "#${ "\t".join( [ i for i in $arg_order if i in $args ] ) }" > $out_file1
|
|
13 &&
|
|
14 #end if
|
|
15 wc
|
|
16 #for $option in $args:
|
|
17 -${ word_to_arg[ str(option) ] }
|
|
18 #end for
|
|
19 $input1 | awk '{ print ${ '"\\t"'.join( [ "$%i" % ( i+1 ) for i in range( len( $args ) ) ] ) } }'
|
|
20 >> $out_file1
|
|
21 </command>
|
|
22 <inputs>
|
|
23 <param format="txt" name="input1" type="data" label="Text file"/>
|
|
24 <param name="options" type="select" multiple="True" display="checkboxes" label="Desired values">
|
|
25 <!-- <option value="bytes" selected="True">Byte count</option> -->
|
|
26 <option value="lines" selected="True">Line count</option>
|
|
27 <option value="words" selected="True">Word count</option>
|
|
28 <option value="characters" selected="True">Character count</option>
|
|
29 <validator type="no_options" message="You must pick at least one attribute to count." />
|
|
30 </param>
|
|
31 <param name="include_header" type="boolean" label="Include Output header" checked="True"/>
|
|
32 </inputs>
|
|
33 <outputs>
|
|
34 <data format="tabular" name="out_file1"/>
|
|
35 </outputs>
|
|
36 <tests>
|
|
37 <test>
|
|
38 <param name="input1" value="1.bed"/>
|
|
39 <param name="options" value="lines,words,characters"/>
|
|
40 <param name="include_header" value="True"/>
|
|
41 <output name="out_file1" file="wc_gnu_out_1.tabular"/>
|
|
42 </test>
|
|
43 <test>
|
|
44 <param name="input1" value="1.bed"/>
|
|
45 <param name="options" value="lines,words,characters"/>
|
|
46 <param name="include_header" value="False"/>
|
|
47 <output name="out_file1" file="wc_gnu_out_2.tabular"/>
|
|
48 </test>
|
|
49 </tests>
|
|
50 <help>
|
|
51
|
|
52 **What it does**
|
|
53
|
|
54 This tool outputs counts of specified attributes (lines, words, characters) of a dataset.
|
|
55
|
|
56 -----
|
|
57
|
|
58 **Example Output**
|
|
59
|
|
60 ::
|
|
61
|
|
62 #lines words characters
|
|
63 7499 41376 624971
|
|
64
|
|
65 </help>
|
|
66 </tool>
|