comparison ena_upload.xml @ 0:5d59238cd3f4 draft

Uploaded
author ieguinoa
date Wed, 02 Feb 2022 17:16:15 +0000
parents
children 2f7a70c0d3ab
comparison
equal deleted inserted replaced
-1:000000000000 0:5d59238cd3f4
1 <tool id="ena_upload" name="ENA Upload tool" version="@VERSION@" profile="20.01" license="MIT">
2 <macros>
3 <token name="@VERSION@">0.5.3</token>
4 <import>samples_macros.xml</import>
5 </macros>
6 <requirements>
7 <requirement type="package" version="@VERSION@">ena-upload-cli</requirement>
8 </requirements>
9 <stdio>
10 <regex match="Oops" source="stderr" level="fatal"/>
11 <regex match="different file names between command line and RUN table" source="stderr" level="fatal"/>
12 </stdio>
13 <command detect_errors="exit_code"><![CDATA[
14 mkdir ./submission_files;
15 #set $studies_table_path = './submission_files/studies.tsv'
16 #set $samples_table_path = './submission_files/samples.tsv'
17 #set $experiments_table_path = './submission_files/experiments.tsv'
18 #set $runs_table_path = './submission_files/runs.tsv'
19
20 #set $studies_table_path_updated = './submission_files/studies_updated.tsv'
21 #set $samples_table_path_updated = './submission_files/samples_updated.tsv'
22 #set $experiments_table_path_updated = './submission_files/experiments_updated.tsv'
23 #set $runs_table_path_updated = './submission_files/runs_updated.tsv'
24
25 #set working_dir = os.getcwd()
26 #if $action_options.input_format_conditional.input_format == "build_tables":
27 python '$__tool_directory__/extract_tables.py' --action $action_options.action --out_dir ./submission_files --studies $studies_json;
28 #end if
29
30
31 #if $action_options.input_format_conditional.input_format == "build_tables":
32 cp $studies_table_path $studies_table_out &&
33 cp $samples_table_path $samples_table_out &&
34 cp $experiments_table_path $experiments_table_out &&
35 cp $runs_table_path $runs_table_out &&
36 #end if
37 #if $action_options.input_format_conditional.input_format == "user_generated_tables":
38 ln -s '$action_options.input_format_conditional.experiments_users_table' $experiments_table_path &&
39 ln -s '$action_options.input_format_conditional.studies_users_table' $studies_table_path &&
40 ln -s '$action_options.input_format_conditional.runs_users_table' $runs_table_path &&
41 ln -s '$action_options.input_format_conditional.samples_users_table' $samples_table_path &&
42 #end if
43 #if $action_options.input_format_conditional.input_format == "excel_tables":
44 ln -s '$action_options.input_format_conditional.xlsx_file' ./xlsx_input.xlsx &&
45 #end if
46 #if $action_options.test_submit_parameters.dry_run == "false" and $action_options.test_submit == "False":
47 webin_id=`grep 'username' $credentials`;
48 if [ "\$webin_id" = "" ]; then
49 ## No credentials in user defined preferences
50 ## Fallback to global defined credentials (if exist)
51 #import os
52 #if os.path.isfile(os.environ.get('GALAXY_ENA_SECRETS', '')):
53 credentials_path=\${GALAXY_ENA_SECRETS};
54 webin_id=`grep 'username' \$GALAXY_ENA_SECRETS`;
55 if [ "\$webin_id" = "" ]; then
56 echo "No global credentials defined. Check your GALAXY_ENA_SECRETS file or set your credentials via: User -> Preferences -> Manage Information";
57 exit 1;
58 fi;
59 #else:
60 echo "No ENA credentials defined. Set your credentials via: User -> Preferences -> Manage Information";
61 exit 1;
62 #end if
63 else
64 credentials_path='$credentials';
65 fi;
66 #end if
67
68 #if $action_options.test_submit == "True" or $action_options.test_submit_parameters.dry_run == "true":
69 credentials_path='test_fake_path';
70 #if $action_options.test_submit_parameters.dry_run == "true" and $action_options.input_format_conditional.input_format == "excel_tables":
71 echo "username: test_user" > \$credentials_path;
72 echo "password: test_password" >> \$credentials_path;
73 #end if
74 #end if
75
76 ## create the list of files to upload and make the symlinks
77 #import re
78 #set $files_to_upload = list()
79 #if $action_options.input_format_conditional.input_format == "build_tables":
80 #for $study in $action_options.input_format_conditional.conditional_viral_metadata.rep_study:
81 #for $sample in $study.rep_sample:
82 #for $experiment in $sample.rep_experiment:
83 #for $run in $experiment.rep_runs:
84 #for $file in $run.upload_files:
85 #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $file.element_identifier)
86 #if $action_options.input_format_conditional.add_extension == "true":
87 #set $extension = '.fastq'
88 #else
89 #set $extension = ''
90 #end if
91 #if $file.is_of_type('fastq', 'fastqsanger'):
92 ## compression output is defined as safename_reads_file so no need to symlink
93 #set $safename_reads_file = $safename_reads_file + $extension + '.gz'
94 gzip -c '$file' > $safename_reads_file &&
95 #else:
96 #if $action_options.input_format_conditional.add_extension == "true":
97 #if $file.is_of_type('fastq.gz', 'fastqsanger.gz'):
98 #set $compression = '.gz'
99 #elif $file.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
100 #set $compression = '.bz2'
101 #end if
102 #set $safename_reads_file = $safename_reads_file + $extension + $compression
103 #end if
104 ln -s '$file' $safename_reads_file &&
105 #end if
106 $files_to_upload.append(str($safename_reads_file))
107 #end for
108 #end for
109 #end for
110 #end for
111 #end for
112 #else:
113 #if $action_options.input_format_conditional.run_input_format_conditional.run_input_format == 'paired_list':
114 #for $pair in $action_options.input_format_conditional.run_input_format_conditional.paired_end_collection:
115 #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $pair.name)
116 ## Always need to add .fastq + compression suffix because the name is based on the pair name which has no extensions
117 #if $pair.forward.is_of_type('fastq', 'fastqsanger'):
118 ## compress the file, no need to create the link then
119 ## always add the compression suffix (.gz)
120 #set $safename_fwd_reads_file = $safename_reads_file + '_1' + 'fastq' + '.gz'
121 gzip -c '$file' > $safename_fwd_reads_file &&
122 #else
123 #if $pair.forward.is_of_type('fastq.gz', 'fastqsanger.gz'):
124 #set $compression = '.gz'
125 #elif $pair.forward.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
126 #set $compression = '.bz2'
127 #end if
128 #set $safename_fwd_reads_file = $safename_reads_file + '_1' + '.fastq' + $compression
129 ln -s '$pair.forward' $safename_fwd_reads_file &&
130 #end if
131
132 #if $pair.reverse.is_of_type('fastq', 'fastqsanger'):
133 ## compress the file, no need to create the link then
134 #set $safename_reverse_reads_file = $safename_reads_file + '_1' + '.fastq' + '.gz'
135 gzip -c '$file' > $safename_rev_reads_file &&
136 #else
137 #if $pair.reverse.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
138 #set $compression = '.bz2'
139 #elif $pair.reverse.is_of_type('fastqsanger.gz', 'fastq.gz'):
140 #set $compression = '.gz'
141 #end if
142 #set $safename_rev_reads_file = $safename_reads_file + '_2' + '.fastq' + $compression
143 ln -s '$pair.reverse' $safename_rev_reads_file &&
144 #end if
145 $files_to_upload.append(str($safename_fwd_reads_file))
146 $files_to_upload.append(str($safename_rev_reads_file))
147 #end for
148 #end if
149 #if $action_options.input_format_conditional.run_input_format_conditional.run_input_format == 'multiple_selection_list':
150 #for $file in $action_options.input_format_conditional.run_input_format_conditional.data:
151 #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $file.element_identifier)
152 #if $file.is_of_type('fastq', 'fastqsanger'):
153 ## always compress add the gz extension
154 #if $action_options.input_format_conditional.run_input_format_conditional.add_extension == "true":
155 #set $safename_reads_file = $safename_reads_file + '.fastq.gz'
156 #else
157 #set $safename_reads_file = $safename_reads_file + '.gz'
158 #end if
159 gzip -c '$file' > $safename_reads_file &&
160 #else
161 #if $action_options.input_format_conditional.run_input_format_conditional.add_extension == "true":
162 #if $file.is_of_type('fastq.gz', 'fastqsanger.gz'):
163 #set $extension = '.fastq.gz'
164 #elif $file.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
165 #set $extension = '.fastq.bz2'
166 #end if
167 #set $safename_reads_file = $safename_reads_file + $extension
168 #end if
169 ln -s '$file' $safename_reads_file &&
170 #end if
171 $files_to_upload.append(str($safename_reads_file))
172 #end for
173 #end if
174 #end if
175
176
177 #if $action_options.test_submit_parameters.dry_run == "false" or $action_options.input_format_conditional.input_format == "excel_tables":
178 #if $action_options.action == "add":
179 ena-upload-cli
180 --tool 'ena-upload-cli v@VERSION@ @ Galaxy'
181 --action '$action_options.action'
182 --center '$action_options.center'
183 --secret \${credentials_path}
184 --data
185 #for $dataset in $files_to_upload:
186 '$dataset'
187 #end for
188 #if $action_options.test_submit_parameters.dry_run == "true":
189 --draft
190 #end if
191 #if $action_options.input_format_conditional.input_format != "excel_tables":
192 --experiment '$experiments_table_path'
193 --study '$studies_table_path'
194 --run '$runs_table_path'
195 --sample '$samples_table_path'
196 #else
197 --xlsx ./xlsx_input.xlsx
198 #end if
199 --action add
200 #if $action_options.input_format_conditional.input_format == "user_generated_tables":
201 --checklist $action_options.input_format_conditional.checklist_id
202 #else:
203 #if $action_options.input_format_conditional.input_format == "build_tables":
204 #if $action_options.input_format_conditional.conditional_viral_metadata.viral_sample == "true":
205 --checklist ERC000033
206 #end if
207 #else:
208 --checklist $action_options.input_format_conditional.checklist_id
209 #end if
210 #end if
211
212 #if $action_options.test_submit_parameters.submit_dev == "true":
213 -d
214 #end if
215 >> '$output';
216 #end if
217
218 #if $action_options.action == "modify":
219 ena-upload-cli
220 --tool 'ena-upload-cli v@VERSION@ @ Galaxy'
221 --action '$action_options.action'
222 --center '$action_options.center'
223 --secret \${credentials_path}
224 --data
225 #for $dataset in $files_to_upload:
226 '$dataset'
227 #end for
228 #if $action_options.test_submit_parameters.dry_run == "true":
229 --draft
230 #end if
231 #if $action_options.input_format_conditional.input_format != "excel_tables":
232 --experiment '$experiments_table_path'
233 --study '$studies_table_path'
234 --run '$runs_table_path'
235 --sample '$samples_table_path'
236 #else
237 --xlsx ./xlsx_input.xlsx
238 --auto_action
239 #end if
240 --action 'modify'
241 #if $action_options.input_format_conditional.input_format == "user_generated_tables":
242 --checklist $action_options.input_format_conditional.checklist_id
243 #else:
244 #if $action_options.input_format_conditional.input_format == "build_tables":
245 #if $action_options.input_format_conditional.conditional_viral_metadata.viral_sample == "true":
246 --checklist ERC000033
247 #end if
248 #else:
249 --checklist $action_options.input_format_conditional.checklist_id
250 #end if
251 #end if
252 >> '$output';
253 #end if
254 #if $action_options.test_submit_parameters.dry_run == "false":
255 echo -e 'center_name\t$action_options.center' >> '$output';
256 echo -e 'action_option\t$action_options.action' >> '$output';
257 #if $action_options.input_format_conditional.input_format == "build_tables":
258 cp $studies_table_path_updated $studies_table_out 2>/dev/null;
259 cp $samples_table_path_updated $samples_table_out 2>/dev/null;
260 cp $experiments_table_path_updated $experiments_table_out 2>/dev/null;
261 cp $runs_table_path_updated $runs_table_out 2>/dev/null;
262 #end if
263 #else
264 ## for the excel input case, copy the upload-cli generated tables to the output files
265 ## this applies for both draft and real submissions
266 cp './ENA_template_experiment_updated.tsv' $experiments_table_out;
267 cp './ENA_template_sample_updated.tsv' $samples_table_out;
268 cp './ENA_template_study_updated.tsv' $studies_table_out;
269 cp './ENA_template_run_updated.tsv' $runs_table_out;
270 #end if
271 #else:
272 exit 0;
273 #end if
274
275 ]]></command>
276 <configfiles>
277 <configfile name="credentials"><![CDATA[
278 #set $webin_id = $__user__.extra_preferences.get('ena_webin_account|webin_id', "").strip()
279 #set $password = $__user__.extra_preferences.get('ena_webin_account|password', "").strip()
280 #if $webin_id != "":
281 username: "$webin_id"
282 password: "$password"
283 #end if
284 ]]></configfile>
285 <configfile name="studies_json">
286 #import json
287 #import re
288 #if $action_options.input_format_conditional.input_format == "build_tables":
289 #set $files_to_upload = list()
290 #set $studies = list()
291 #for $study in $action_options.input_format_conditional.conditional_viral_metadata.rep_study:
292 #set samples = list()
293 #for $sample in $study.rep_sample:
294 #set experiments = list()
295 #for $experiment in $sample.rep_experiment:
296 #set runs = list()
297 #for $run in $experiment.rep_runs:
298 #set run_files = list()
299 #for $file in $run.upload_files:
300 #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $file.element_identifier)
301 $run_files.append(str($safename_reads_file))
302 #end for
303 $runs.append((str($run.run_base_name),$run_files))
304 #end for
305
306 $experiments.append({'title':str($experiment.experiment_title),'experiment_design':str($experiment.experiment_design),'library_strategy':str($experiment.library_strategy),'library_source':str($experiment.library_source),'library_selection':str($experiment.library_selection),'library_layout':str($experiment.library_layout),'insert_size':str($experiment.insert_size),'library_construction_protocol':str($experiment.library_construction_protocol),'platform':str($experiment.platform),'instrument_model':str($experiment.instrument_model),'runs':$runs})
307 #end for
308 #if $action_options.input_format_conditional.conditional_viral_metadata.viral_sample == "true":
309
310 $samples.append({'title':str($sample.sample_title),'description':str($sample.sample_description),'tax_name':str($sample.scientific_name),'tax_id':str($sample.tax_id),'collection_date':str($sample.collection_date),'geo_location':str($sample.geo_location_country),'host_common_name':str($sample.host_common_name),'host_subject_id':str($sample.host_subject_id),'host_health_state':str($sample.host_health_state),'host_sex':str($sample.host_sex),'host_scientific_name':str($sample.host_scientific_name),'collector_name':str($sample.collector_name),'collecting_institution':str($sample.collecting_institution),'isolate':str($sample.isolate),'experiments':$experiments})
311 #else:
312
313 $samples.append({'title':str($sample.sample_title),'description':str($sample.sample_description),'tax_name':str($sample.scientific_name),'tax_id':str($sample.tax_id),'experiments':$experiments})
314 #end if
315 #end for
316 $studies.append({'title':str($study.study_title),'type':str($study.study_type),'abstract':str($study.study_abstract),'pubmed_id':str($study.study_pubmed_id),'samples':$samples})
317 #end for
318 #echo $json.dumps($studies)
319 #end if
320 </configfile>
321 </configfiles>
322 <inputs>
323 <conditional name="action_options">
324 <param name="action" type="select" label="Action to execute">
325 <option value="add" selected="True">Add new data</option>
326 <option value="modify">Modify metadata</option>
327 </param>
328 <when value="add">
329 <expand macro="test_submit_section"/>
330 <param name="test_submit" type="hidden" value="False" />
331 <expand macro="table_inputs_macro" />
332 </when>
333 <when value="modify">
334 <expand macro="test_submit_section"/>
335 <param name="test_submit" type="hidden" value="False" />
336 <expand macro="table_inputs_macro" />
337 </when>
338 </conditional>
339 </inputs>
340 <outputs>
341 <data name="output" format="txt" label="ENA submission receipt"/>
342 <data name="studies_table_out" format="tabular" label="Studies table">
343 <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables"</filter>
344 </data>
345 <data name="samples_table_out" format="tabular" label="Samples table">
346 <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables"</filter>
347 </data>
348 <data name="experiments_table_out" format="tabular" label="Experiments table">
349 <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables"</filter>
350 </data>
351 <data name="runs_table_out" format="tabular" label="Runs table">
352 <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables"</filter>
353 </data>
354 </outputs>
355 <tests>
356 <!--Test 1: excel input of VIRAL samples -->
357 <test>
358 <conditional name="action_options">
359 <param name="action" value="add"/>
360 <section name="test_submit_parameters">
361 <param name="submit_dev" value="false" />
362 <param name="dry_run" value="true" />
363 </section>
364 <conditional name="input_format_conditional">
365 <param name="input_format" value="excel_tables"/>
366 <param name="checklist_id" value="ERC000033"/>
367 <param name="xlsx_file" value="metadata_test_viral.xlsx"/>
368 <conditional name="run_input_format_conditional">
369 <param name="add_extension" value="false"/>
370 <param name="run_input_format" value="multiple_selection_list"/>
371 <param name="data" value="C030_exp5_clean.fastq,C053_exp5_clean.fastq,C026_exp5_clean.fastq,C067_exp5_clean.fastq"/>
372 </conditional>
373 </conditional>
374 </conditional>
375 <param name="center" value="Some research center"/>
376 <output name="experiments_table_out">
377 <assert_contents>
378 <has_n_lines n="5"/>
379 <has_n_columns n="17"/>
380 <has_line_matching expression="alias\ttitle\tstudy_alias\tsample_alias\tdesign_description\tlibrary_name\tlibrary_strategy\tlibrary_source\tlibrary_selection\tlibrary_layout\tinsert_size\tlibrary_construction_protocol\tplatform\tinstrument_model\taccession\tsubmission_date\tstatus"/>
381 <has_line_matching expression="e_(.*)_026\tNanopore sequencing\tSARS-CoV-2_genomes_01\ts_(.*)"/>
382 </assert_contents>
383 </output>
384 <output name="studies_table_out">
385 <assert_contents>
386 <has_n_lines n="2"/>
387 <has_n_columns n="7"/>
388 <has_line_matching expression="SARS-CoV-2_genomes_01\tWhole-genome sequencing of SARS-CoV-2 from Covid-19 patients\tWhole Genome Sequencing\tWhole-genome sequences of SARS-CoV-2 from oro-pharyngeal swabs obtained from Covid-19 patients(.*)"/>
389 </assert_contents>
390 </output>
391 <output name="samples_table_out">
392 <assert_contents>
393 <has_n_lines n="5"/>
394 <has_n_columns n="18"/>
395 </assert_contents>
396 </output>
397 <output name="runs_table_out">
398 <assert_contents>
399 <has_n_lines n="5"/>
400 <has_n_columns n="8"/>
401 <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tstatus\tfile_checksum"/>
402 <has_line_matching expression="r_20201007_026\te_20201007_026\tC026_exp5_clean.fastq.gz\tFASTQ(.*)"/>
403 </assert_contents>
404 </output>
405 </test>
406 <!--Test 2: excel input of VIRAL samples with extended columns-->
407 <test>
408 <conditional name="action_options">
409 <param name="action" value="add"/>
410 <section name="test_submit_parameters">
411 <param name="submit_dev" value="false" />
412 <param name="dry_run" value="true" />
413 </section>
414 <conditional name="input_format_conditional">
415 <param name="input_format" value="excel_tables"/>
416 <param name="checklist_id" value="ERC000033"/>
417 <param name="xlsx_file" value="metadata_test_viral_optional_columns.xlsx"/>
418 <conditional name="run_input_format_conditional">
419 <param name="add_extension" value="false"/>
420 <param name="run_input_format" value="multiple_selection_list"/>
421 <param name="data" value="C030_exp5_clean.fastq,C053_exp5_clean.fastq,C026_exp5_clean.fastq,C067_exp5_clean.fastq"/>
422 </conditional>
423 </conditional>
424 </conditional>
425 <param name="center" value="Some research center"/>
426 <output name="experiments_table_out">
427 <assert_contents>
428 <has_n_lines n="5"/>
429 <has_n_columns n="17"/>
430 <has_line_matching expression="alias\ttitle\tstudy_alias\tsample_alias\tdesign_description\tlibrary_name\tlibrary_strategy\tlibrary_source\tlibrary_selection\tlibrary_layout\tinsert_size\tlibrary_construction_protocol\tplatform\tinstrument_model\taccession\tsubmission_date\tstatus"/>
431 <has_line_matching expression="e_(.*)_026\tNanopore sequencing\tSARS-CoV-2_genomes_01\ts_(.*)"/>
432 </assert_contents>
433 </output>
434 <output name="studies_table_out">
435 <assert_contents>
436 <has_n_lines n="2"/>
437 <has_n_columns n="7"/>
438 <has_line_matching expression="alias\ttitle\tstudy_type\tstudy_abstract\taccession\tsubmission_date\tstatus"/>
439 <has_line_matching expression="SARS-CoV-2_genomes_01\tWhole-genome sequencing of SARS-CoV-2 from Covid-19 patients\tWhole Genome Sequencing\tWhole-genome sequences of SARS-CoV-2 from oro-pharyngeal swabs obtained from Covid-19 patients(.*)"/>
440 </assert_contents>
441 </output>
442 <output name="samples_table_out">
443 <assert_contents>
444 <has_n_lines n="5"/>
445 <has_n_columns n="43"/>
446 </assert_contents>
447 </output>
448 <output name="runs_table_out">
449 <assert_contents>
450 <has_n_lines n="5"/>
451 <has_n_columns n="8"/>
452 <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tstatus\tfile_checksum"/>
453 <has_line_matching expression="r_20201007_026\te_20201007_026\tC026_exp5_clean.fastq.gz\tFASTQ(.*)"/>
454 </assert_contents>
455 </output>
456 </test>
457 <!--Test 3: excel input of NON-VIRAL samples-->
458 <test>
459 <conditional name="action_options">
460 <param name="action" value="add"/>
461 <section name="test_submit_parameters">
462 <param name="submit_dev" value="false" />
463 <param name="dry_run" value="true" />
464 </section>
465 <conditional name="input_format_conditional">
466 <param name="input_format" value="excel_tables"/>
467 <param name="checklist_id" value="ERC000011"/>
468 <param name="xlsx_file" value="metadata_test_nonviral_1_run.xlsx"/>
469 <conditional name="run_input_format_conditional">
470 <param name="add_extension" value="true"/>
471 <param name="run_input_format" value="multiple_selection_list"/>
472 <param name="data" value="sample_no_extension"/>
473 </conditional>
474 </conditional>
475 </conditional>
476 <param name="center" value="Some research center"/>
477 <output name="experiments_table_out">
478 <assert_contents>
479 <has_n_lines n="2"/>
480 <has_n_columns n="17"/>
481 <has_line_matching expression="alias\ttitle\tstudy_alias\tsample_alias\tdesign_description\tlibrary_name\tlibrary_strategy\tlibrary_source\tlibrary_selection\tlibrary_layout\tinsert_size\tlibrary_construction_protocol\tplatform\tinstrument_model\taccession\tsubmission_date\tstatus"/>
482 </assert_contents>
483 </output>
484 <output name="studies_table_out">
485 <assert_contents>
486 <has_n_lines n="2"/>
487 <has_n_columns n="7"/>
488 <has_line_matching expression="alias\ttitle\tstudy_type\tstudy_abstract\taccession\tsubmission_date\tstatus"/>
489 </assert_contents>
490 </output>
491 <output name="samples_table_out">
492 <assert_contents>
493 <has_n_lines n="2"/>
494 <has_n_columns n="8"/>
495 <has_line_matching expression="alias\ttitle\tscientific_name\tsample_description\taccession\tsubmission_date\tstatus\ttaxon_id"/>
496 </assert_contents>
497 </output>
498 <output name="runs_table_out">
499 <assert_contents>
500 <has_n_lines n="2"/>
501 <has_n_columns n="8"/>
502 <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tstatus\tfile_checksum"/>
503 <has_line_matching expression="r_20201007_026\te_20201007_026\tsample_no_extension.fastq.gz\tFASTQ(.*)"/>
504 </assert_contents>
505 </output>
506 </test>
507 <!--Test 4: failure on excel input of NON-VIRAL samples with runs PAIRED collection -->
508 <test expect_failure="true">
509 <conditional name="action_options">
510 <param name="action" value="add"/>
511 <section name="test_submit_parameters">
512 <param name="submit_dev" value="false" />
513 <param name="dry_run" value="false" />
514 </section>
515 <conditional name="input_format_conditional">
516 <param name="add_extension" value="true"/>
517 <param name="input_format" value="excel_tables"/>
518 <param name="checklist_id" value="ERC000011"/>
519 <param name="xlsx_file" value="metadata_test_nonviral.xlsx"/>
520 <conditional name="run_input_format_conditional">
521 <param name="run_input_format" value="paired_list"/>
522 <param name="paired_end_collection">
523 <collection type="list:paired">
524 <element name="paired_run_name">
525 <collection type="paired">
526 <element name="forward" value="1.fastqsanger.gz" ftype="fastqsanger.gz" />
527 <element name="reverse" value="2.fastqsanger.gz" ftype="fastqsanger.gz" />
528 </collection>
529 </element>
530 </collection>
531 </param>
532 </conditional>
533 </conditional>
534 </conditional>
535 <param name="center" value="Some research center"/>
536 <assert_command>
537 <has_text_matching expression="ena-upload-cli"/>
538 <has_text_matching expression="--data 'paired_run_name_1.fastq.gz' 'paired_run_name_2.fastq.gz'"/>
539 <has_text_matching expression="--action 'add' --center 'Some research center'"/>
540 </assert_command>
541 </test>
542 <!--Test 5: build tables from user input fields NON-VIRAL samples-->
543 <test>
544 <conditional name="action_options">
545 <param name="action" value="add"/>
546 <section name="test_submit_parameters">
547 <param name="submit_dev" value="false" />
548 <param name="dry_run" value="true" />
549 </section>
550 <conditional name="input_format_conditional">
551 <param name="input_format" value="build_tables"/>
552 <param name="add_extension" value="true"/>
553 <conditional name="conditional_viral_metadata">
554 <param name="viral_sample" value="False"/>
555 <repeat name="rep_study">
556 <param name="study_title" value="Test study title"/>
557 <param name="study_abstract" value="Test study abstract"/>
558 <param name="study_type" value="Epigenetics"/>
559 <param name="study_pubmed_id" value="Test study pubmedID"/>
560 <repeat name="rep_sample">
561 <param name="sample_title" value="Test Sample title"/>
562 <param name="sample_description" value="Test Sample description"/>
563 <param name="scientific_name" value="Test Sample scientific name"/>
564 <param name="tax_id" value="Test Sample tax_id"/>
565 <repeat name="rep_experiment">
566 <param name="experiment_title" value="Test experiment title"/>
567 <param name="experiment_design" value="Test experiment design description"/>
568 <param name="library_strategy" value="CTS"/>
569 <param name="library_source" value="GENOMIC"/>
570 <param name="library_selection" value="PCR"/>
571 <param name="library_layout" value="SINGLE"/>
572 <param name="insert_size" value="150"/>
573 <param name="library_construction_protocol" value="Test library construction"/>
574 <param name="platform" value="ILLUMINA"/>
575 <param name="instrument_model" value="Illumina HiSeq 4000"/>
576 <repeat name="rep_runs">
577 <param name="upload_files" value="1.fastqsanger.gz,sample.fq" ftype="fastqsanger"/>
578 </repeat>
579 </repeat>
580 </repeat>
581 </repeat>
582 </conditional>
583 </conditional>
584 </conditional>
585 <param name="center" value="Some research center"/>
586 <output name="experiments_table_out">
587 <assert_contents>
588 <has_n_lines n="2"/>
589 <has_n_columns n="17"/>
590 </assert_contents>
591 </output>
592 <output name="studies_table_out">
593 <assert_contents>
594 <has_n_lines n="2"/>
595 <has_n_columns n="8"/>
596 <has_line_matching expression="alias\tstatus\taccession\ttitle\tstudy_type\tstudy_abstract\tpubmed_id\tsubmission_date"/>
597 </assert_contents>
598 </output>
599 <output name="samples_table_out">
600 <assert_contents>
601 <has_n_lines n="2"/>
602 <has_n_columns n="8"/>
603 </assert_contents>
604 </output>
605 <output name="runs_table_out">
606 <assert_contents>
607 <has_n_lines n="3"/>
608 <has_n_columns n="8"/>
609 <has_line_matching expression="alias\tstatus\taccession\texperiment_alias\tfile_name\tfile_format\tfile_checksum\tsubmission_date"/>
610 </assert_contents>
611 </output>
612 </test>
613 <!--Test 6: RUN failing build tables from user input fields NON-VIRAL samples-->
614 <test expect_failure="true">
615 <conditional name="action_options">
616 <param name="action" value="add"/>
617 <section name="test_submit_parameters">
618 <param name="submit_dev" value="true" />
619 <param name="dry_run" value="false" />
620 </section>
621 <conditional name="input_format_conditional">
622 <param name="input_format" value="build_tables"/>
623 <param name="add_extension" value="true"/>
624 <conditional name="conditional_viral_metadata">
625 <param name="viral_sample" value="false"/>
626 <repeat name="rep_study">
627 <param name="study_title" value="Test study title"/>
628 <param name="study_abstract" value="Test study abstract"/>
629 <param name="study_type" value="Epigenetics"/>
630 <param name="study_pubmed_id" value="Test study pubmedID"/>
631 <repeat name="rep_sample">
632 <param name="sample_title" value="Test Sample title"/>
633 <param name="sample_description" value="Test Sample description"/>
634 <param name="scientific_name" value="Test Sample scientific name"/>
635 <param name="tax_id" value="Test Sample tax_id"/>
636 <repeat name="rep_experiment">
637 <param name="experiment_title" value="Test experiment title"/>
638 <param name="experiment_design" value="Test experiment design description"/>
639 <param name="library_strategy" value="CTS"/>
640 <param name="library_source" value="GENOMIC"/>
641 <param name="library_selection" value="PCR"/>
642 <param name="library_layout" value="SINGLE"/>
643 <param name="insert_size" value="150"/>
644 <param name="library_construction_protocol" value="Test library construction"/>
645 <param name="platform" value="ILLUMINA"/>
646 <param name="instrument_model" value="Illumina HiSeq 4000"/>
647 <repeat name="rep_runs">
648 <param name="upload_files" value="1.fastqsanger.gz,sample.fq" ftype="fastqsanger"/>
649 </repeat>
650 </repeat>
651 </repeat>
652 </repeat>
653 </conditional>
654 </conditional>
655 </conditional>
656 <param name="center" value="Some research center"/>
657 <assert_stdout>
658 <has_text_matching expression="No ENA credentials defined"/>
659 </assert_stdout>
660 </test>
661 <!--Test 7: with submit_test to skip credentials checksRUN failing build tables from user input fields NON-VIRAL samples
662 also tests compression of uncompressed inputs and adding the .gz suffix -->
663 <test expect_failure="true">
664 <conditional name="action_options">
665 <param name="action" value="add"/>
666 <section name="test_submit_parameters">
667 <param name="submit_dev" value="true" />
668 <param name="dry_run" value="false" />
669 </section>
670 <param name="test_submit" value="True"/>
671 <conditional name="input_format_conditional">
672 <param name="add_extension" value="true"/>
673 <param name="input_format" value="build_tables"/>
674 <conditional name="conditional_viral_metadata">
675 <param name="viral_sample" value="false"/>
676 <repeat name="rep_study">
677 <param name="study_title" value="Test study title"/>
678 <param name="study_abstract" value="Test study abstract"/>
679 <param name="study_type" value="Epigenetics"/>
680 <param name="study_pubmed_id" value="Test study pubmedID"/>
681 <repeat name="rep_sample">
682 <param name="sample_title" value="Test Sample title"/>
683 <param name="sample_description" value="Test Sample description"/>
684 <param name="scientific_name" value="Test Sample scientific name"/>
685 <param name="tax_id" value="Test Sample tax_id"/>
686 <repeat name="rep_experiment">
687 <param name="experiment_title" value="Test experiment title"/>
688 <param name="experiment_design" value="Test experiment design description"/>
689 <param name="library_strategy" value="CTS"/>
690 <param name="library_source" value="GENOMIC"/>
691 <param name="library_selection" value="PCR"/>
692 <param name="library_layout" value="SINGLE"/>
693 <param name="insert_size" value="150"/>
694 <param name="library_construction_protocol" value="Test library construction"/>
695 <param name="platform" value="ILLUMINA"/>
696 <param name="instrument_model" value="Illumina HiSeq 4000"/>
697 <repeat name="rep_runs">
698 <param name="run_base_name" value="run_from_hospital_X"/>
699 <param name="upload_files" value="sample.fq,sample.fq" ftype="fastqsanger"/>
700 </repeat>
701 </repeat>
702 </repeat>
703 </repeat>
704 </conditional>
705 </conditional>
706 </conditional>
707 <param name="center" value="Some research center"/>
708 <assert_command>
709 <has_text_matching expression="ena-upload-cli"/>
710 <has_text_matching expression="--data 'sample.fq.fastq.gz' 'sample.fq.fastq.gz'"/>
711 <has_text_matching expression="--action 'add' --center 'Some research center'"/>
712 <not_has_text text="modify" />
713 </assert_command>
714 <assert_stderr>
715 <has_text_matching expression="Oops, the file test_fake_path does not exist"/>
716 </assert_stderr>
717 </test>
718 <!--Test 8: viral submission - User input metadata - Add extension = False-->
719 <test expect_failure="true">
720 <conditional name="action_options">
721 <param name="action" value="add"/>
722 <section name="test_submit_parameters">
723 <param name="submit_dev" value="false" />
724 <param name="dry_run" value="false" />
725 </section>
726 <param name="test_submit" value="True"/>
727 <conditional name="input_format_conditional">
728 <param name="add_extension" value="False"/>
729 <param name="input_format" value="build_tables"/>
730 <conditional name="conditional_viral_metadata">
731 <param name="viral_sample" value="true"/>
732 <repeat name="rep_study">
733 <param name="study_title" value="Test study title"/>
734 <param name="study_abstract" value="Test study abstract"/>
735 <param name="study_type" value="Epigenetics"/>
736 <param name="study_pubmed_id" value="Test study pubmedID"/>
737 <repeat name="rep_sample">
738 <param name="sample_title" value="Test Sample title"/>
739 <param name="sample_description" value="Test Sample description"/>
740 <param name="scientific_name" value="Test Sample scientific name"/>
741 <param name="tax_id" value="Test Sample tax_id"/>
742 <param name="collection_date" value="2020"/>
743 <param name="geo_location_country" value="Belgium"/>
744 <param name="host_common_name" value="Human"/>
745 <param name="host_subject_id" value="Patient_001"/>
746 <param name="host_health_state" value="healthy"/>
747 <param name="host_sex" value="female"/>
748 <param name="host_scientific_name" value="homo sapiens"/>
749 <param name="collector_name" value="John The Collector"/>
750 <param name="collecting_institution" value="Hospital 01"/>
751 <param name="isolate" value="sample_001"/>
752 <repeat name="rep_experiment">
753 <param name="experiment_title" value="Test experiment title"/>
754 <param name="experiment_design" value="Test experiment design description"/>
755 <param name="library_strategy" value="CTS"/>
756 <param name="library_source" value="GENOMIC"/>
757 <param name="library_selection" value="PCR"/>
758 <param name="library_layout" value="SINGLE"/>
759 <param name="insert_size" value="150"/>
760 <param name="library_construction_protocol" value="Test library construction"/>
761 <param name="platform" value="ILLUMINA"/>
762 <param name="instrument_model" value="Illumina HiSeq 4000"/>
763 <repeat name="rep_runs">
764 <param name="run_base_name" value="run_from_hospital_X"/>
765 <param name="upload_files" value="1.fastqsanger.gz,2.fastqsanger.gz" ftype="fastqsanger.gz"/>
766 </repeat>
767 </repeat>
768 </repeat>
769 </repeat>
770 </conditional>
771 </conditional>
772 </conditional>
773 <param name="center" value="Some research center"/>
774 <assert_command>
775 <has_text_matching expression="ena-upload-cli"/>
776 <has_text_matching expression="--data '1.fastqsanger.gz' '2.fastqsanger.gz'"/>
777 <has_text_matching expression="--action 'add' --center 'Some research center'"/>
778 <has_text_matching expression="--checklist ERC000033"/>
779 </assert_command>
780 <assert_stderr>
781 <has_text_matching expression="Oops, the file test_fake_path does not exist"/>
782 </assert_stderr>
783 </test>
784 <!--Test 9: modify option and auto compression - viral submission - User input metadata-->
785 <test expect_failure="true">
786 <conditional name="action_options">
787 <param name="action" value="modify"/>
788 <section name="test_submit_parameters">
789 <param name="submit_dev" value="false" />
790 <param name="dry_run" value="false" />
791 </section>
792 <param name="test_submit" value="True"/>
793 <conditional name="input_format_conditional">
794 <param name="add_extension" value="False"/>
795 <param name="input_format" value="build_tables"/>
796 <conditional name="conditional_viral_metadata">
797 <param name="viral_sample" value="True"/>
798 <repeat name="rep_study">
799 <param name="study_title" value="Test study title"/>
800 <param name="study_abstract" value="Test study abstract"/>
801 <param name="study_type" value="Epigenetics"/>
802 <param name="study_pubmed_id" value="Test study pubmedID"/>
803 <repeat name="rep_sample">
804 <param name="sample_title" value="Test Sample title"/>
805 <param name="sample_description" value="Test Sample description"/>
806 <param name="scientific_name" value="Test Sample scientific name"/>
807 <param name="tax_id" value="Test Sample tax_id"/>
808 <param name="collection_date" value="2020"/>
809 <param name="geo_location_country" value="Belgium"/>
810 <param name="host_common_name" value="Human"/>
811 <param name="host_subject_id" value="Patient_001"/>
812 <param name="host_health_state" value="healthy"/>
813 <param name="host_sex" value="female"/>
814 <param name="host_scientific_name" value="homo sapiens"/>
815 <param name="collector_name" value="John The Collector"/>
816 <param name="collecting_institution" value="Hospital 01"/>
817 <param name="isolate" value="sample_001"/>
818 <repeat name="rep_experiment">
819 <param name="experiment_title" value="Test experiment title"/>
820 <param name="experiment_design" value="Test experiment design description"/>
821 <param name="library_strategy" value="CTS"/>
822 <param name="library_source" value="GENOMIC"/>
823 <param name="library_selection" value="PCR"/>
824 <param name="library_layout" value="SINGLE"/>
825 <param name="insert_size" value="150"/>
826 <param name="library_construction_protocol" value="Test library construction"/>
827 <param name="platform" value="ILLUMINA"/>
828 <param name="instrument_model" value="Illumina HiSeq 4000"/>
829 <repeat name="rep_runs">
830 <param name="run_base_name" value="run_from_hospital_X"/>
831 <param name="upload_files" value="sample.fq" ftype="fastqsanger"/>
832 </repeat>
833 </repeat>
834 </repeat>
835 </repeat>
836 </conditional>
837 </conditional>
838 </conditional>
839 <param name="center" value="Some research center"/>
840 <assert_command>
841 <has_text_matching expression="ena-upload-cli"/>
842 <has_text_matching expression="--data 'sample.fq.gz'"/>
843 <has_text_matching expression="--action 'modify' --center 'Some research center'"/>
844 <has_text_matching expression="--checklist ERC000033"/>
845 <not_has_text text="add" />
846 </assert_command>
847 <assert_stderr>
848 <has_text_matching expression="Oops, the file test_fake_path does not exist"/>
849 </assert_stderr>
850 </test>
851 </tests>
852 <help><![CDATA[
853 This is a wrapper for the ENA upload tool in https://github.com/usegalaxy-eu/ena-upload-cli
854 The input metadata can be submitted following the tabular format of the templates in https://github.com/usegalaxy-eu/ena-upload-cli/tree/master/example_tables
855 It is also possible to submit an excel file by following the template in https://drive.google.com/file/d/1ncC22--tW2v-EI-te_r86sAZujIPAjlX/view?usp=sharing
856 For viral submissions a larger set of metadata is required, you can find the template in https://drive.google.com/file/d/1Gx78GKh58PmRjdmJ05DBbpObAL-3oUFX/view?usp=sharing
857 ]]></help>
858 <citations>
859 </citations>
860 </tool>