-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathena_consensus_submit.xml
271 lines (261 loc) · 13.1 KB
/
ena_consensus_submit.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<tool id="ena_consensus_submit" name="Submit consensus sequence to ENA" version="@VERSION@" python_template_version="3.5">
<macros>
<token name="@VERSION@">4.3.0</token>
</macros>
<requirements>
<requirement type="package" version="@VERSION@">ena-webin-cli</requirement>
<requirement type="package" version="1.76">biopython</requirement>
<requirement type="package" version="5.3">pyyaml</requirement>
</requirements>
<command detect_errors="exit_code"><![CDATA[
#if $test_submit == "True":
#set $credentials='./test_fake_path';
touch $credentials;
echo "username:test_user" >> $credentials;
echo "password:test_password" >> $credentials;
#end if
webin_id=`grep 'username' $credentials | cut -d':' -f2,2`;
if [ "\$webin_id" = "" ]; then
## No credentials in user defined preferences
## Fallback to global defined credentials (if exist)
#import os
#if os.path.isfile(os.environ.get('GALAXY_ENA_SECRETS', '')):
credentials_path=\${GALAXY_ENA_SECRETS};
webin_id=`grep 'username' \$GALAXY_ENA_SECRETS | cut -d':' -f2,2` | sed -e 's/^[[:space:]]*//'`;
password=`grep 'password' \$GALAXY_ENA_SECRETS | cut -d':' -f2,2` | sed -e 's/^[[:space:]]*//'`;
if [ "\$webin_id" = "" ]; then
echo "No global credentials defined. Check your GALAXY_ENA_SECRETS file or set your credentials via: User -> Preferences -> Manage Information";
exit 1;
fi;
#else:
echo "No ENA credentials defined. Set your credentials via: User -> Preferences -> Manage Information";
exit 1;
#end if
else
password=`grep 'password' $credentials | cut -d':' -f2,2`;
fi;
## create a manifest base file with the parameters that are identical for all sequences that will be submited (if submitting a multifasta)
#set $manifest_base = 'manifest_base.tab'
mkdir manifests;
mkdir fasta;
echo -e 'ASSEMBLY_TYPE\t$assembly_type' > $manifest_base;
echo -e 'COVERAGE\t$coverage' >> $manifest_base;
echo -e 'PROGRAM\t$assembly_program' >> $manifest_base;
#if $min_gap_length:
echo -e 'MINGAPLENGTH\t$min_gap_length' >> $manifest_base;
#end if
echo -e 'MOLECULETYPE\t$molecule_type' >> $manifest_base;
#if $metadata_file_or_form.metadata_format == "file":
#import re
#for $file in $metadata_file_or_form.genome_fasta:
#if $file.is_of_type('fasta'):
#set $full_name = $file.element_identifier + '.gz'
gzip -c $file > './fasta/$full_name';
#else:
ln -s $file './fasta/$file.element_identifier';
#end if
#end for
## process the input tables, this creates an intermediate file with information
python3 '$__tool_directory__/process_input.py' $metadata_file_or_form.ena_receipt $genome_fasta_files './manifests' $manifest_base >> $webin_cli_log;
center_name=`grep 'center_name' $metadata_file_or_form.ena_receipt | cut -f2,2 | tr -d '\n'`;
#else:
#set $generated_manifest='./manifests/generated_manifest.txt'
cp $manifest_base $generated_manifest;
#set $study_id = $metadata_file_or_form.study_accession
#set $sample_id = $metadata_file_or_form.sample_accession
echo -e 'STUDY\t$study_id' >> $generated_manifest;
echo -e 'SAMPLE\t$sample_id' >> $generated_manifest;
center_name='$metadata_file_or_form.center_name';
echo -e 'NAME\t$metadata_file_or_form.assembly_name' >> $generated_manifest;
echo -e 'PLATFORM\t$metadata_file_or_form.sequencing_platform' >> $generated_manifest;
#if $metadata_file_or_form.genome_fasta.is_of_type('fasta'):
gzip -c $metadata_file_or_form.genome_fasta > consensus.fasta.gz;
#else:
ln -s $metadata_file_or_form.genome_fasta consensus.fasta.gz;
#end if
echo -e 'FASTA\tconsensus.fasta.gz' >> $generated_manifest;
#end if
#set $outputs_dir = 'outputs'
mkdir $outputs_dir;
#if $metadata_file_or_form.metadata_format == "file":
## iterate over the list of manifest - fasta generated by the process_input
## in case of errors, this list is empty
while read line; do
manifest=`echo \$line | cut -d' ' -f1,1`;
echo "Submitting manifest \$manifest" >> $webin_cli_log;
ena-webin-cli
-context genome
-userName "'\$webin_id'"
-password "'\$password'"
-centerName "'\$center_name'"
-manifest \$manifest
-inputDir './fasta'
#if $dry_run == "true":
-validate
#end if
-outputDir $outputs_dir
>> $webin_cli_log;
done < submit_list.tab;
#else:
ena-webin-cli
#if $submit_test == "true":
-test
#end if
#if $dry_run == "true":
-validate
#else:
-submit
#end if
-context genome
-manifest $generated_manifest
-password "'\$password'"
-userName "'\$webin_id'"
-inputDir "./"
-centerName "'\$center_name'"
-outputDir $outputs_dir
>> $webin_cli_log ;
##cp ./genome/$metadata_file_or_form.assembly_name/validate/webin-cli.report $validate_output
#end if
tar -cf $webin_cli_outputs $outputs_dir ;
]]></command>
<configfiles>
<configfile name="credentials"><![CDATA[
#set $webin_id = $__user__.extra_preferences.get('ena_webin_account|webin_id', "").strip()
#set $password = $__user__.extra_preferences.get('ena_webin_account|password', "").strip()
#if $webin_id != "":
username:$webin_id
password:$password
#end if
]]></configfile>
<configfile name="genome_fasta_files">
#import json
#import re
#if $metadata_file_or_form.metadata_format == "file":
#set $fasta_files_list = list()
#for $file in $metadata_file_or_form.genome_fasta:
$fasta_files_list.append(str($file.element_identifier))
#end for
#echo json.dumps($fasta_files_list)
#end if
</configfile>
</configfiles>
<inputs>
<param name="test_submit" type="hidden" value="False" />
<param name="submit_test" type="boolean" truevalue="true" falsevalue="false" label="Submit to test server" help="use Webin test service instead of the production service. Please note that the Webin upload area is shared between test and production services, and that test submission files will not be archived." />
<param name="dry_run" type="boolean" truevalue="true" falsevalue="false" label="Validate files and metadata but do not submit" help="Generate input files and run Webin-CLI with -validate option. If 'No' is selected then it will validate and submit (-submit flag)"/>
<param name="assembly_type" type="select" label="Assembly type">
<option value="clone">Clone</option>
<option value="isolate">Isolate</option>
<option value="COVID-19 outbreak">COVID-19 outbreak</option>
</param>
<param name="assembly_program" type="text" optional="False" label="Assembly program"/>
<param name="molecule_type" type="select" label="Molecule type">
<option value="genomic RNA" selected="True">genomic RNA</option>
<option value="viral cRNA">viral cRNA</option>
<option value="genomic DNA">genomic DNA</option>
</param>
<param name="coverage" type="float" optional="False" value="10000" label="Coverage"/>
<conditional name="metadata_file_or_form">
<param name="metadata_format" type="select" label="Select the method to load study and sample metadata">
<option value="form" selected="True">Fill in required submission metadata</option>
<option value="file">(Beta) I used the Galaxy ENA upload tool to submit the raw data: parse the received submission receipt</option>
</param>
<when value="file">
<param type="data" format="txt" name="ena_receipt" label="Submission receipt obtained from ENA upload tool"/>
<param name="genome_fasta" type="data" label="Select the consensus sequence assembly files or a collection of them" format="fasta,fasta.gz" multiple="true"/>
</when>
<when value="form">
<param name="assembly_name" type="text" optional="False" label="Assembly name"/>
<param name="study_accession" type="text" optional="False" label="Study accession"/>
<param name="sample_accession" type="text" optional="False" label="Sample accession"/>
<param name="sequencing_platform" type="text" optional="False" label="Sequencing platform"/>
<param name="description" type="text" optional="True" value="" label="Description" help="Free text description of the genome assembly (optional)"/>
<param name="center_name" type="text" optional="False" label="Center name"/>
<param name="genome_fasta" type="data" label="Select the consensus sequence assembly file" format="fasta,fasta.gz"/>
</when>
</conditional>
<param name="min_gap_length" type="text" optional="True" label="Minimum gap length (optional)"/>
</inputs>
<outputs>
<collection name="generated_manifests" type="list" label="Generated manifests">
<discover_datasets pattern="(?P<designation>.+)\.txt" ext="txt" directory="manifests/"/>
</collection>
<data name="webin_cli_log" label="ENA submission log" format="txt"/>
<data name="webin_cli_outputs" label="Webin cli outputs" format="tar"/>
</outputs>
<tests>
<test>
<param name="submit_test" value="true" />
<param name="dry_run" value="true" />
<param name="test_submit" value="True" />
<param name="assembly_type" value="isolate"/>
<param name="assembly_program" value="Test assembly program"/>
<param name="molecule_type" value="viral cRNA"/>
<param name="coverage" value="10000"/>
<conditional name="metadata_file_or_form">
<param name="metadata_format" value="form"/>
<param name="assembly_name" value="Test assembly name"/>
<param name="study_accession" value="PRJEB49173"/>
<param name="sample_accession" value="SAMEA11953908"/>
<param name="sequencing_platform" value="Nanopore 0011"/>
<param name="description" value="Test Description"/>
<param name="center_name" value="Test center name"/>
<param name="genome_fasta" value="phiX2.fasta"/>
</conditional>
<param name="min_gap_length" value="30"/>
<output name="webin_cli_log">
<assert_contents>
<has_n_lines n="4"/>
<has_text_matching expression="ERROR: Invalid submission account user name or password."/>
</assert_contents>
</output>
</test>
<test>
<param name="submit_test" value="true" />
<param name="dry_run" value="true" />
<param name="test_submit" value="True" />
<param name="assembly_type" value="isolate"/>
<param name="assembly_program" value="Test assembly program"/>
<param name="molecule_type" value="viral cRNA"/>
<param name="coverage" value="10000"/>
<conditional name="metadata_file_or_form">
<param name="metadata_format" value="file"/>
<param name="ena_receipt" value="receipt_sample_noPhiX.txt"/>
<param name="genome_fasta" value="phiX2.fasta.gz,sample_alias_001.fasta.gz"/>
</conditional>
<param name="min_gap_length" value="30"/>
<output name="webin_cli_log">
<assert_contents>
<has_text_matching expression="Processing phiX2"/>
<has_text_matching expression="No metadata found for sample phiX2"/>
<has_text_matching expression="Processing sample_alias_001"/>
<has_text_matching expression="Submitting manifest ./manifests/sample_alias_001.manifest.txt"/>
<has_text_matching expression="ERROR: Invalid submission account user name or password. Please try enclosing your password in single quotes."/>
</assert_contents>
</output>
</test>
<test>
<param name="submit_test" value="true" />
<param name="dry_run" value="true" />
<param name="test_submit" value="True" />
<param name="assembly_type" value="isolate"/>
<param name="assembly_program" value="Test assembly program"/>
<param name="molecule_type" value="viral cRNA"/>
<param name="coverage" value="10000"/>
<conditional name="metadata_file_or_form">
<param name="metadata_format" value="file"/>
<param name="ena_receipt" value="receipt_sample.txt"/>
<param name="genome_fasta" value="sample_alias_001.fasta.gz"/>
</conditional>
<param name="min_gap_length" value="30"/>
<output name="webin_cli_log">
<assert_contents>
<has_text_matching expression="ERROR: Invalid submission account user name or password. Please try enclosing your password in single quotes."/>
</assert_contents>
</output>
</test>
</tests>
<help><![CDATA[
This tool is a wrapper for the ENA Webin CLI submission tool (https://ena-docs.readthedocs.io/en/latest/submit/general-guide/webin-cli.html).
]]></help>
</tool>