upstream/fasta_compute_length/fasta_compute_length.xml
1<tool id="fasta_compute_length" name="Compute sequence length" version="1.0.4" profile="22.04">
2 <description></description>
3 <requirements>
4 <requirement type="package" version="3.12">python</requirement>
5 </requirements>
6 <required_files>
7 <include path="fasta_compute_length.py"/>
8 </required_files>
9 <command>
10 #if $ref.ref_source == 'dbkey':
11 cp '${ref.index.fields.len_path}' '$output'
12 #else:
13 python '$__tool_directory__/fasta_compute_length.py'
14 #if $ref.ref_source == 'history':
15 '$input'
16 #else:
17 '${ref.index.fields.path}'
18 #end if
19 '$output'
20 $ref.keep_first
21 $ref.keep_first_word
22 #end if
23 </command>
24 <inputs>
25 <conditional name="ref">
26 <param name="ref_source" type="select" label="Sequences">
27 <option value="history" selected="True">From History</option>
28 <option value="dbkey">Locally Cached (pre-built length files)</option>
29 <option value="fasta">Locally Cached (full genomes)</option>
30 </param>
31 <when value="history">
32 <param name="input" type="data" format="fasta" label="Compute length for these sequences"/>
33 <param name="keep_first" type="integer" value="0" label="How many title characters to keep?" help="'0' = keep the whole thing"/>
34 <param name="keep_first_word" type="boolean" truevalue="id_only" falsevalue="id_and_desc"
35 label="Strip fasta description from header?"
36 help="Stripping the description will truncate the fasta header to just the sequence ID. Otherwise the header description will be kept. This step is done before the 'How many characters to keep' option."/>
37 </when>
38 <when value="dbkey">
39 <param name="index" type="select" label="Source Genome Build">
40 <options from_data_table="__dbkeys__"/>
41 </param>
42 </when>
43 <when value="fasta">
44 <param name="index" type="select" label="Source Genome Build">
45 <options from_data_table="all_fasta"/>
46 </param>
47 <param name="keep_first" type="integer" value="0" label="How many title characters to keep?" help="'0' = keep the whole thing"/>
48 <param name="keep_first_word" type="boolean" truevalue="id_only" falsevalue="id_and_desc"
49 label="Strip fasta description from header?"
50 help="Stripping the description will truncate the fasta header to just the sequence ID. Otherwise the header description will be kept. This step is done before the 'How many characters to keep' option."/>
51 </when>
52 </conditional>
53
54 </inputs>
55 <outputs>
56 <data name="output" format="tabular"/>
57 </outputs>
58 <tests>
59 <test>
60 <param name="ref|input" value="454.fasta" />
61 <param name="ref|keep_first" value="0"/>
62 <param name="ref|keep_first_word" value="id_and_desc" />
63 <output name="output" file="fasta_tool_compute_length_1.out" />
64 </test>
65
66 <test>
67 <param name="ref|input" value="extract_genomic_dna_out1.fasta" />
68 <param name="ref|keep_first" value="0"/>
69 <param name="ref|keep_first_word" value="id_and_desc" />
70 <output name="output" file="fasta_tool_compute_length_2.out" />
71 </test>
72
73 <test>
74 <param name="ref|input" value="454.fasta" />
75 <param name="ref|keep_first" value="14"/>
76 <param name="ref|keep_first_word" value="id_and_desc" />
77 <output name="output" file="fasta_tool_compute_length_3.out" />
78 </test>
79
80 <test>
81 <param name="ref|ref_source" value="fasta" />
82 <param name="ref|index" value="test_id"/>
83 <param name="ref|keep_first_word" value="id_only" />
84 <output name="output" file="merged.tab" />
85 </test>
86
87 <test>
88 <param name="ref|ref_source" value="dbkey" />
89 <param name="ref|index" value="test_id"/>
90 <output name="output" file="merged.tab" />
91 </test>
92 </tests>
93 <help><![CDATA[
94
95**What it does**
96
97This tool counts the length of each fasta sequence in the file. The output file has two columns per line (separated by tab): fasta titles and lengths of the sequences. The option *How many characters to keep?* allows to select a specified number of letters from the beginning of each FASTA entry.
98
99-----
100
101**Example**
102
103Suppose you have the following FASTA formatted sequences from a Roche (454) FLX sequencing run::
104
105 >EYKX4VC02EQLO5 length=108 xy=1826_0455 region=2 run=R_2007_11_07_16_15_57_
106 TCCGCGCCGAGCATGCCCATCTTGGATTCCGGCGCGATGACCATCGCCCGCTCCACCACG
107 TTCGGCCGGCCCTTCTCGTCGAGGAATGACACCAGCGCTTCGCCCACG
108 >EYKX4VC02D4GS2 length=60 xy=1573_3972 region=2 run=R_2007_11_07_16_15_57_
109 AATAAAACTAAATCAGCAAAGACTGGCAAATACTCACAGGCTTATACAATACAAATGTAAfa
110
111Running this tool while setting **How many characters to keep?** to **14** will produce this::
112
113 EYKX4VC02EQLO5 108
114 EYKX4VC02D4GS2 60
115
116However, if your IDs are not all the same length, you may wish to just keep the fasta ID, and not the description::
117
118 >EYKX4VC02EQLO5 length=108 xy=1826_0455 region=2 run=R_2007_11_07_16_15_57_
119 TCCGCGCCGAGCATGCCCATCTTGGATTCCGGCGCGATGACCATCGCCCGCTCCACCACG
120 TTCGGCCGGCCCTTCTCGTCGAGGAATGACACCAGCGCTTCGCCCACG
121 >EYKX4VC length=60 xy=1573_3972 region=2 run=R_2007_11_07_16_15_57_
122 AATAAAACTAAATCAGCAAAGACTGGCAAATACTCACAGGCTTATACAATACAAATGTAAfa
123
124Running this tool with **Strip fasta description from header** set to **True** and **How many characters to keep?** set to **0** will produce::
125
126 EYKX4VC02EQLO5 108
127 EYKX4VC 60
128
129
130 ]]></help>
131 <citations>
132 <citation type="doi">10.1093/bioinformatics/btq281</citation>
133 </citations>
134</tool>