view ena_upload.xml @ 14:5cb6146337d8 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit ab38fa3d5ec06729c1efa86240ec57b8143b21ed
author iuc
date Wed, 12 Jun 2024 16:01:11 +0000
parents ea5e944f447d
children
line wrap: on
line source

<tool id="ena_upload" name="ENA Upload tool" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05" license="MIT">
    <description>Submission of (meta)data to the European Nucleotide Archive (ENA)</description>
    <macros>
        <token name="@TOOL_VERSION@">0.7.3</token>
        <token name="@VERSION_SUFFIX@">1</token>
        <import>samples_macros.xml</import>
    </macros>
    <requirements>
        <requirement type="package" version="@TOOL_VERSION@">ena-upload-cli</requirement>
    </requirements>
    <stdio>
        <regex match="Oops" source="stderr" level="fatal"/>
        <regex match="different file names between command line and RUN table" source="stderr" level="fatal"/>
    </stdio>
    <command detect_errors="exit_code"><![CDATA[
mkdir ./submission_files; 
#set $studies_table_path = './submission_files/studies.tsv'
#set $samples_table_path =   './submission_files/samples.tsv'
#set $experiments_table_path = './submission_files/experiments.tsv'
#set $runs_table_path =  './submission_files/runs.tsv'
        
#set $studies_table_path_updated = './submission_files/studies_updated.tsv'
#set $samples_table_path_updated =   './submission_files/samples_updated.tsv'
#set $experiments_table_path_updated = './submission_files/experiments_updated.tsv'
#set $runs_table_path_updated =  './submission_files/runs_updated.tsv'

#set working_dir = os.getcwd()
#if $action_options.input_format_conditional.input_format == "build_tables":
  python '$__tool_directory__/extract_tables.py' --action $action_options.action --out_dir ./submission_files --studies $studies_json;
#end if
        
credentials_path='test_fake_path';
echo "username: test_user" > \$credentials_path;
echo "password: test_password" >> \$credentials_path;


#if $action_options.input_format_conditional.input_format == "build_tables":
    cp $studies_table_path $studies_table_out &&
    cp $samples_table_path $samples_table_out &&
    cp $experiments_table_path $experiments_table_out &&
    cp $runs_table_path $runs_table_out &&
#end if
#if $action_options.input_format_conditional.input_format == "user_generated_tables":
    ln -s '$action_options.input_format_conditional.experiments_users_table' $experiments_table_path &&
    ln -s '$action_options.input_format_conditional.studies_users_table' $studies_table_path &&
    ln -s '$action_options.input_format_conditional.runs_users_table' $runs_table_path &&
    ln -s '$action_options.input_format_conditional.samples_users_table' $samples_table_path &&
#end if
#if $action_options.input_format_conditional.input_format == "excel_tables":
    ln -s '$action_options.input_format_conditional.xlsx_file' ./xlsx_input.xlsx &&
#end if
#if $action_options.input_format_conditional.input_format == "isa_json":
    ln -s '$action_options.input_format_conditional.isa_json_file' ./isa_json_input.json &&
#end if
#if $action_options.test_submit_parameters.dry_run == "False":
    webin_id=`grep 'username' $credentials`;
    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`;
          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
      credentials_path='$credentials';
    fi;
#end if


## create the list of files to upload and make the symlinks 
#import re      
#set $files_to_upload = list()
#if $action_options.input_format_conditional.input_format == "build_tables":
    #for $study in $action_options.input_format_conditional.conditional_viral_metadata.rep_study:
      #for $sample in $study.rep_sample:
        #for $experiment in $sample.rep_experiment:
          #for $run in $experiment.rep_runs:
            #for $file in $run.upload_files:
                #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $file.element_identifier)
                #if $action_options.input_format_conditional.add_extension == "True":
                    #set $extension = '.fastq'
                #else
                    #set $extension = ''
                #end if
                #if $file.is_of_type('fastq', 'fastqsanger'):
                    ## compression output is defined as safename_reads_file so no need to symlink
                    #set $safename_reads_file = $safename_reads_file + $extension + '.gz'
                    gzip -c '$file' > $safename_reads_file &&
                #else:
                    #if $action_options.input_format_conditional.add_extension == "True":
                        #if $file.is_of_type('fastq.gz', 'fastqsanger.gz'):
                            #set $compression = '.gz' 
                        #elif $file.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
                            #set $compression = '.bz2' 
                        #end if
                        #set $safename_reads_file = $safename_reads_file + $extension + $compression 
                    #end if
                    ln -s '$file' $safename_reads_file &&
                #end if
                $files_to_upload.append(str($safename_reads_file))
            #end for
          #end for
        #end for
      #end for
    #end for
#else:
    #if $action_options.input_format_conditional.run_input_format_conditional.run_input_format == 'paired_list':
        #for $pair in $action_options.input_format_conditional.run_input_format_conditional.paired_end_collection:
            #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $pair.name)
            ## Always need to add .fastq + compression suffix because the name is based on the pair name which has no extensions
            #if $pair.forward.is_of_type('fastq', 'fastqsanger'):
                ## compress the file, no need to create the link then
                ## always add the compression suffix (.gz)
                #set $safename_fwd_reads_file = $safename_reads_file + '_1' + 'fastq' + '.gz'
                gzip -c '$file' > $safename_fwd_reads_file &&
            #else
                #if $pair.forward.is_of_type('fastq.gz', 'fastqsanger.gz'):
                    #set $compression = '.gz'
                #elif $pair.forward.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
                    #set $compression = '.bz2'
                #end if
                #set $safename_fwd_reads_file = $safename_reads_file + '_1' + '.fastq' + $compression
                ln -s '$pair.forward' $safename_fwd_reads_file &&
            #end if

            #if $pair.reverse.is_of_type('fastq', 'fastqsanger'):
                ## compress the file, no need to create the link then
                #set $safename_reverse_reads_file = $safename_reads_file + '_1' + '.fastq' + '.gz'
                gzip -c '$file' > $safename_rev_reads_file &&
            #else
                #if $pair.reverse.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
                    #set $compression = '.bz2'
                #elif $pair.reverse.is_of_type('fastqsanger.gz', 'fastq.gz'):
                    #set $compression = '.gz'
                #end if
                #set $safename_rev_reads_file = $safename_reads_file + '_2' + '.fastq' + $compression
                ln -s '$pair.reverse' $safename_rev_reads_file &&
            #end if
            $files_to_upload.append(str($safename_fwd_reads_file))
            $files_to_upload.append(str($safename_rev_reads_file))
        #end for
    #end if
    #if $action_options.input_format_conditional.run_input_format_conditional.run_input_format == 'multiple_selection_list':
        #for $file in $action_options.input_format_conditional.run_input_format_conditional.data:
            #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $file.element_identifier)
            #if $file.is_of_type('fastq', 'fastqsanger'):
                ## always compress add the gz extension
                #if $action_options.input_format_conditional.run_input_format_conditional.add_extension == "True":
                    #set $safename_reads_file = $safename_reads_file + '.fastq.gz'
                #else
                    #set $safename_reads_file = $safename_reads_file + '.gz'
                #end if
                gzip -c '$file' > $safename_reads_file &&
            #else
                #if $action_options.input_format_conditional.run_input_format_conditional.add_extension == "True":
                    #if $file.is_of_type('fastq.gz', 'fastqsanger.gz'):
                        #set $extension = '.fastq.gz'
                    #elif $file.is_of_type('fastqsanger.bz2', 'fastq.bz2'):
                        #set $extension = '.fastq.bz2'
                    #end if
                    #set $safename_reads_file = $safename_reads_file + $extension
                #end if
                ln -s '$file' $safename_reads_file &&
            #end if      
            $files_to_upload.append(str($safename_reads_file))
        #end for
    #end if
#end if

ena-upload-cli
    --tool 'ena-upload-cli v@TOOL_VERSION@ @ Galaxy'
    --action '$action_options.action'
    --center '$action_options.test_submit_parameters.center'
    --secret \${credentials_path}
    --data
#for $dataset in $files_to_upload:
    '$dataset'
#end for
#if $action_options.test_submit_parameters.dry_run == "True":
    --draft
#end if
#if $action_options.input_format_conditional.input_format == "excel_tables":
    --xlsx ./xlsx_input.xlsx 
#elif $action_options.input_format_conditional.input_format == "user_generated_tables" or $action_options.input_format_conditional.input_format == "build_tables":
    --experiment '$experiments_table_path'
    --study '$studies_table_path'
    --run '$runs_table_path'
    --sample '$samples_table_path'
#elif $action_options.input_format_conditional.input_format == "isa_json":
    --isa_json ./isa_json_input.json
    --isa_assay_stream '$action_options.input_format_conditional.isa_assay_stream'
#end if
#if $action_options.input_format_conditional.input_format == "build_tables":
    #if $action_options.input_format_conditional.conditional_viral_metadata.viral_sample == "True":
        --checklist ERC000033
    #end if
#elif $action_options.input_format_conditional.input_format == "isa_json":
    --checklist ERC000011
#else:
    --checklist $action_options.input_format_conditional.checklist_id
#end if
#if $action_options.test_submit_parameters.submit_dev == "True":
    -d
#end if
>> '$output';


#if $action_options.test_submit_parameters.dry_run == "False":
    echo -e 'center_name\t$action_options.test_submit_parameters.center' >> '$output';
    echo -e 'action_option\t$action_options.action' >> '$output';
#end if
        
## copy updated files
#if $action_options.input_format_conditional.input_format == "excel_tables" or $action_options.input_format_conditional.input_format == "isa_json":
    ## for the excel/ISA json input case, copy the upload-cli generated tables to the output files
    ## this applies for both draft and real submissions
    cp './ENA_template_experiment_updated.tsv' $experiments_table_out;
    cp './ENA_template_sample_updated.tsv' $samples_table_out;
    cp './ENA_template_study_updated.tsv' $studies_table_out;
    cp './ENA_template_run_updated.tsv' $runs_table_out;
#else
    cp $studies_table_path_updated $studies_table_out 2>/dev/null;
    cp $samples_table_path_updated $samples_table_out 2>/dev/null;
    cp $experiments_table_path_updated $experiments_table_out 2>/dev/null;
    cp $runs_table_path_updated $runs_table_out 2>/dev/null;
#end if

python '$__tool_directory__/dump_yaml.py' $studies_table_out $samples_table_out $experiments_table_out $runs_table_out >> $output;
]]></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="studies_json">
#import json
#import re
#if $action_options.input_format_conditional.input_format == "build_tables":
  #set $files_to_upload = list()
  #set $studies = list()
  #for $study in $action_options.input_format_conditional.conditional_viral_metadata.rep_study:
    #set samples = list()
    #for $sample in $study.rep_sample:
      #set experiments = list()
      #for $experiment in $sample.rep_experiment:
        #set runs = list()
        #for $run in $experiment.rep_runs:
            #set run_files = list()
            #for $file in $run.upload_files:
              #set $safename_reads_file = re.sub('[^\w\-_\.]', '_', $file.element_identifier)
              $run_files.append(str($safename_reads_file))
            #end for
            $runs.append((str($run.run_base_name),$run_files))
        #end for
    
$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})
      #end for
      #if $action_options.input_format_conditional.conditional_viral_metadata.viral_sample == "True":
$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})
      #else:
$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),'experiments':$experiments})
      #end if
    #end for
    $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})
  #end for
  #echo $json.dumps($studies)
#end if
        </configfile>
    </configfiles>
    <inputs>
        <conditional name="action_options">
            <param name="action" type="select" label="Action to execute">
                <option value="add" selected="True">Add new (meta)data</option>
                <option value="modify">Modify metadata</option>
            </param>
            <when value="add">
                <param name="test_submit" type="hidden" value="False" />
                <expand macro="table_inputs_macro" />  
                <expand macro="test_submit_section"/>
            </when>
            <when value="modify">
                <param name="test_submit" type="hidden" value="False" />
                <expand macro="table_inputs_macro" />
                <expand macro="test_submit_section"/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format="txt" label="ENA submission receipt"/>
        <data name="studies_table_out" format="tabular" label="Studies table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables" or action_options['input_format_conditional']['input_format'] == "isa_json"</filter>
        </data>
        <data name="samples_table_out" format="tabular" label="Samples table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables" or action_options['input_format_conditional']['input_format'] == "isa_json"</filter>
        </data>
        <data name="experiments_table_out" format="tabular" label="Experiments table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables" or action_options['input_format_conditional']['input_format'] == "isa_json"</filter>
        </data>
        <data name="runs_table_out" format="tabular" label="Runs table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" or action_options['input_format_conditional']['input_format'] == "excel_tables" or action_options['input_format_conditional']['input_format'] == "isa_json"</filter>
        </data>
    </outputs>
    <tests>
       <!--Test 1:  excel input of VIRAL samples -->
        <test expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="True" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="input_format" value="excel_tables"/>
                    <param name="checklist_id" value="ERC000033"/>
                    <param name="xlsx_file" value="metadata_test_viral.xlsx"/>
                    <conditional name="run_input_format_conditional">
                        <param name="add_extension" value="False"/>
                        <param name="run_input_format" value="multiple_selection_list"/>
                        <param name="data" value="C030_exp5_clean.fastq,C053_exp5_clean.fastq,C026_exp5_clean.fastq,C067_exp5_clean.fastq"/>
                    </conditional>
                </conditional>
            </conditional>
            <output name="experiments_table_out">
                <assert_contents>
                    <has_n_lines n="5"/>
                    <has_n_columns n="17"/>
                    <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"/>
                    <has_line_matching expression="e_(.*)_026\tNanopore sequencing\tSARS-CoV-2_genomes_01\ts_(.*)"/>
                </assert_contents>
            </output>
            <output name="studies_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="7"/>
                    <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(.*)"/>
                </assert_contents>
            </output>
            <output name="samples_table_out">
                <assert_contents>
                    <has_n_lines n="5"/>
                    <has_n_columns n="18"/>
                </assert_contents>
            </output>
            <output name="runs_table_out">
                <assert_contents>
                    <has_n_lines n="5"/>
                    <has_n_columns n="8"/>
                    <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tstatus\tfile_checksum"/>
                    <has_line_matching expression="r_20201007_026\te_20201007_026\tC026_exp5_clean.fastq.gz\tFASTQ(.*)"/>
                </assert_contents>
            </output>
        </test>
        <!--Test 2: excel input of VIRAL samples with extended columns-->
        <test expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="True" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="input_format" value="excel_tables"/>
                    <param name="checklist_id" value="ERC000033"/>
                    <param name="xlsx_file" value="metadata_test_viral_optional_columns.xlsx"/>
                    <conditional name="run_input_format_conditional">
                        <param name="add_extension" value="False"/>
                        <param name="run_input_format" value="multiple_selection_list"/>
                        <param name="data" value="C030_exp5_clean.fastq,C053_exp5_clean.fastq,C026_exp5_clean.fastq,C067_exp5_clean.fastq"/>
                    </conditional>
                </conditional>
            </conditional>
            <output name="experiments_table_out">
                <assert_contents>
                    <has_n_lines n="5"/>
                    <has_n_columns n="17"/>
                    <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"/>
                    <has_line_matching expression="e_(.*)_026\tNanopore sequencing\tSARS-CoV-2_genomes_01\ts_(.*)"/>
                </assert_contents>
            </output>
            <output name="studies_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="7"/>
                    <has_line_matching expression="alias\ttitle\tstudy_type\tstudy_abstract\taccession\tsubmission_date\tstatus"/>
                    <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(.*)"/>
                </assert_contents>
            </output>
            <output name="samples_table_out">
                <assert_contents>
                    <has_n_lines n="5"/>
                    <has_n_columns n="43"/>
                </assert_contents>
            </output>
            <output name="runs_table_out">
                <assert_contents>
                    <has_n_lines n="5"/>
                    <has_n_columns n="8"/>
                    <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tstatus\tfile_checksum"/>
                    <has_line_matching expression="r_20201007_026\te_20201007_026\tC026_exp5_clean.fastq.gz\tFASTQ(.*)"/>
                </assert_contents>
            </output>
            <output name="output">
                <assert_contents>
                    <has_line_matching expression="YAML -------------"/>
                    <has_line_matching expression="ENA_experiment:"/>
                    <has_line_matching expression="ENA_sample:"/>
                    <has_line_matching expression="ENA_study:"/>
                    <has_line_matching expression="ENA_run:"/>
                </assert_contents>
            </output>
        </test>
        <!--Test 3: excel input of NON-VIRAL samples-->
        <test expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="True" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="input_format" value="excel_tables"/>
                    <param name="checklist_id" value="ERC000011"/>
                    <param name="xlsx_file" value="metadata_test_nonviral_1_run.xlsx"/>
                    <conditional name="run_input_format_conditional">
                        <param name="add_extension" value="True"/>
                        <param name="run_input_format" value="multiple_selection_list"/>
                        <param name="data" value="sample_no_extension"/>
                    </conditional>
                </conditional>
            </conditional>
            <output name="experiments_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="17"/>
                    <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"/>
                </assert_contents>
            </output>
            <output name="studies_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="7"/>
                    <has_line_matching expression="alias\ttitle\tstudy_type\tstudy_abstract\taccession\tsubmission_date\tstatus"/>
                </assert_contents>
            </output>
            <output name="samples_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="10"/>
                    <has_line_matching expression="s_20201007_026\tC026\tSaccharomyces cerevisiae\tSample from beer\t2020-03-25\tAntarctica\t\t\tADDED\t"/>
                </assert_contents>
            </output>
            <output name="runs_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="8"/>
                    <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tstatus\tfile_checksum"/>
                    <has_line_matching expression="r_20201007_026\te_20201007_026\tsample_no_extension.fastq.gz\tFASTQ(.*)"/>
                </assert_contents>
            </output>
        </test>
        <!--Test 4: failure on excel input of NON-VIRAL samples with runs PAIRED collection -->
        <test expect_failure="True">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="False" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="add_extension" value="True"/>
                    <param name="input_format" value="excel_tables"/>
                    <param name="checklist_id" value="ERC000011"/>
                    <param name="xlsx_file" value="metadata_test_nonviral.xlsx"/>
                    <conditional name="run_input_format_conditional">
                        <param name="run_input_format" value="paired_list"/>
                        <param name="paired_end_collection">
                            <collection type="list:paired">
                                <element name="paired_run_name">
                                    <collection type="paired">
                                        <element name="forward" value="1.fastqsanger.gz" ftype="fastqsanger.gz" />
                                        <element name="reverse" value="2.fastqsanger.gz" ftype="fastqsanger.gz" />
                                    </collection>
                                </element>
                            </collection>
                        </param>
                    </conditional>
                </conditional>
            </conditional>
            <assert_command>
                <has_text_matching expression="ena-upload-cli"/>
                <has_text_matching expression="--data 'paired_run_name_1.fastq.gz' 'paired_run_name_2.fastq.gz'"/>
                <has_text_matching expression="--action 'add' --center 'Some research center'"/>
            </assert_command>
        </test>
        <!--Test 4b: failure on excel input of NON-VIRAL samples with runs PAIRED collection -->
        <test expect_failure="True">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="False" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="add_extension" value="True"/>
                    <param name="input_format" value="excel_tables"/>
                    <param name="checklist_id" value="ERC000011"/>
                    <param name="xlsx_file" value="metadata_test_nonviral.xlsx"/>
                    <conditional name="run_input_format_conditional">
                        <param name="run_input_format" value="paired_list"/>
                        <param name="paired_end_collection">
                            <collection type="list:paired">
                                <element name="paired_run_name">
                                    <collection type="paired">
                                        <element name="forward" value="1.fastqsanger.gz" ftype="fastqsanger.gz" />
                                        <element name="reverse" value="2.fastqsanger.gz" ftype="fastqsanger.gz" />
                                    </collection>
                                </element>
                            </collection>
                        </param>
                    </conditional>
                </conditional>
            </conditional>
            <assert_command>
                <has_text_matching expression="ena-upload-cli"/>
                <has_text_matching expression="--data 'paired_run_name_1.fastq.gz' 'paired_run_name_2.fastq.gz'"/>
                <has_text_matching expression="--action 'add' --center 'Some research center'"/>
            </assert_command>
        </test>
        <!--Test 5: build tables from user input fields NON-VIRAL samples-->
        <test expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="True" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="input_format" value="build_tables"/>
                    <param name="add_extension" value="False"/>
                    <conditional name="conditional_viral_metadata">
                        <param name="viral_sample" value="False"/>
                        <repeat name="rep_study">
                            <param name="study_title" value="Test study title"/>
                            <param name="study_abstract" value="Test study abstract"/>
                            <param name="study_type" value="Epigenetics"/>
                            <param name="study_pubmed_id" value="Test study pubmedID"/>
                            <repeat name="rep_sample">
                                <param name="sample_title" value="Test Sample title"/>
                                <param name="sample_description" value="Test Sample description"/>
                                <param name="scientific_name" value="Test Sample scientific name"/>
                                <param name="tax_id" value="2697049"/>
                                <param name="collection_date" value="2020"/>
                                <param name="geo_location_country" value="Belgium"/>
                                <repeat name="rep_experiment">
                                    <param name="experiment_title" value="Test experiment title"/>
                                    <param name="experiment_design" value="Test experiment design description"/>
                                    <param name="library_strategy" value="CTS"/>
                                    <param name="library_source" value="GENOMIC"/>
                                    <param name="library_selection" value="PCR"/>
                                    <param name="library_layout" value="SINGLE"/>
                                    <param name="insert_size" value="150"/>
                                    <param name="library_construction_protocol" value="Test library construction"/>
                                    <param name="platform" value="ILLUMINA"/>
                                    <param name="instrument_model" value="Illumina HiSeq 4000"/>
                                    <repeat name="rep_runs">
                                        <param name="upload_files" value="1.fastqsanger.gz,sample.fq" ftype="fastqsanger.gz"/>
                                    </repeat>
                                </repeat>
                            </repeat>
                        </repeat>
                    </conditional>
                </conditional>
            </conditional>
            <output name="experiments_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="17"/>
                </assert_contents>
            </output>
            <output name="studies_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="8"/>
                    <has_line_matching expression="alias\tstatus\ttitle\tstudy_type\tstudy_abstract\tpubmed_id\taccession\tsubmission_date"/>
                </assert_contents>
            </output>
            <output name="samples_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="10"/>
                </assert_contents>
            </output>
            <output name="runs_table_out">
                <assert_contents>
                    <has_n_lines n="3"/>
                    <has_n_columns n="8"/>
                    <has_line_matching expression="alias\tstatus\texperiment_alias\tfile_name\tfile_format\taccession\tsubmission_date\tfile_checksum"/>
                </assert_contents>
            </output>
        </test>
        <!--Test 6: with submit_test to skip credentials checksRUN failing build tables from user input fields NON-VIRAL samples
            also tests compression of uncompressed inputs and adding the .gz suffix -->
        <test expect_failure="False" expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="True" />
                    <param name="dry_run" value="True" />
                </section>
                <param name="test_submit" value="True"/>
                <conditional name="input_format_conditional">
                    <param name="add_extension" value="False"/>
                    <param name="input_format" value="build_tables"/>
                    <conditional name="conditional_viral_metadata">
                        <param name="viral_sample" value="False"/>
                        <repeat name="rep_study">
                            <param name="study_title" value="Test study title"/>
                            <param name="study_abstract" value="Test study abstract"/>
                            <param name="study_type" value="Epigenetics"/>
                            <param name="study_pubmed_id" value="Test study pubmedID"/>
                            <repeat name="rep_sample">
                                <param name="sample_title" value="Test Sample title"/>
                                <param name="sample_description" value="Test Sample description"/>
                                <param name="scientific_name" value="Test Sample scientific name"/>
                                <param name="tax_id" value="2697049"/>
                                <param name="collection_date" value="2020"/>
                                <param name="geo_location_country" value="Belgium"/>
                                <repeat name="rep_experiment">
                                    <param name="experiment_title" value="Test experiment title"/>
                                    <param name="experiment_design" value="Test experiment design description"/>
                                    <param name="library_strategy" value="CTS"/>
                                    <param name="library_source" value="GENOMIC"/>
                                    <param name="library_selection" value="PCR"/>
                                    <param name="library_layout" value="SINGLE"/>
                                    <param name="insert_size" value="150"/>
                                    <param name="library_construction_protocol" value="Test library construction"/>
                                    <param name="platform" value="ILLUMINA"/>
                                    <param name="instrument_model" value="Illumina HiSeq 4000"/>
                                    <repeat name="rep_runs">
                                        <param name="run_base_name" value="run_from_hospital_X"/>
                                        <param name="upload_files" value="1.fastqsanger.gz,2.fastqsanger.gz" ftype="fastqsanger.gz"/>
                                    </repeat>
                                </repeat>
                            </repeat>
                        </repeat>
                    </conditional>
                </conditional>
            </conditional>
            <assert_command>
                <has_text_matching expression="ena-upload-cli"/>
                <has_text_matching expression="--data '1.fastqsanger.gz' '2.fastqsanger.gz'"/>
                <has_text_matching expression="--action 'add' --center 'Some research center'"/>
                <not_has_text text="modify" />
            </assert_command>
        </test>
        <!--Test 7: viral submission - User input metadata - Add extension = False-->
        <test expect_failure="False" expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="True" />
                </section>
                <param name="test_submit" value="True"/>
                <conditional name="input_format_conditional">
                    <param name="add_extension" value="False"/>
                    <param name="input_format" value="build_tables"/>
                    <conditional name="conditional_viral_metadata">
                        <param name="viral_sample" value="True"/>
                        <repeat name="rep_study">
                            <param name="study_title" value="Test study title"/>
                            <param name="study_abstract" value="Test study abstract"/>
                            <param name="study_type" value="Epigenetics"/>
                            <param name="study_pubmed_id" value="Test study pubmedID"/>
                            <repeat name="rep_sample">
                                <param name="sample_title" value="Test Sample title"/>
                                <param name="sample_description" value="Test Sample description"/>
                                <param name="scientific_name" value="Test Sample scientific name"/>
                                <param name="tax_id" value="2697049"/>
                                <param name="collection_date" value="2020"/>
                                <param name="geo_location_country" value="Belgium"/>
                                <param name="host_common_name" value="Human"/>
                                <param name="host_subject_id" value="Patient_001"/>
                                <param name="host_health_state" value="healthy"/>
                                <param name="host_sex" value="female"/>
                                <param name="host_scientific_name" value="homo sapiens"/>
                                <param name="collector_name" value="John The Collector"/>
                                <param name="collecting_institution" value="Hospital 01"/>
                                <param name="isolate" value="sample_001"/>
                                <repeat name="rep_experiment">
                                    <param name="experiment_title" value="Test experiment title"/>
                                    <param name="experiment_design" value="Test experiment design description"/>
                                    <param name="library_strategy" value="CTS"/>
                                    <param name="library_source" value="GENOMIC"/>
                                    <param name="library_selection" value="PCR"/>
                                    <param name="library_layout" value="SINGLE"/>
                                    <param name="insert_size" value="150"/>
                                    <param name="library_construction_protocol" value="Test library construction"/>
                                    <param name="platform" value="ILLUMINA"/>
                                    <param name="instrument_model" value="Illumina HiSeq 4000"/>
                                    <repeat name="rep_runs">
                                        <param name="run_base_name" value="run_from_hospital_X"/>
                                        <param name="upload_files" value="1.fastqsanger.gz,2.fastqsanger.gz" ftype="fastqsanger.gz"/>
                                    </repeat>
                                </repeat>
                            </repeat>
                        </repeat>
                    </conditional>
                </conditional>
            </conditional>
            <assert_command>
                <has_text_matching expression="ena-upload-cli"/>
                <has_text_matching expression="--data '1.fastqsanger.gz' '2.fastqsanger.gz'"/>
                <has_text_matching expression="--action 'add' --center 'Some research center'"/>
                <has_text_matching expression="--checklist ERC000033"/>
            </assert_command>
        </test>
        <!--Test 8: modify option and auto compression - viral submission - User input metadata-->
        <test expect_failure="False" expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="modify"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="False" />
                    <param name="dry_run" value="True" />
                </section>
                <param name="test_submit" value="True"/>
                <conditional name="input_format_conditional">
                    <param name="add_extension" value="False"/>
                    <param name="input_format" value="build_tables"/>
                    <conditional name="conditional_viral_metadata">
                        <param name="viral_sample" value="True"/>
                        <repeat name="rep_study">
                            <param name="study_title" value="Test study title"/>
                            <param name="study_abstract" value="Test study abstract"/>
                            <param name="study_type" value="Epigenetics"/>
                            <param name="study_pubmed_id" value="Test study pubmedID"/>
                            <repeat name="rep_sample">
                                <param name="sample_title" value="Test Sample title"/>
                                <param name="sample_description" value="Test Sample description"/>
                                <param name="scientific_name" value="Test Sample scientific name"/>
                                <param name="tax_id" value="2697049"/>
                                <param name="collection_date" value="2020"/>
                                <param name="geo_location_country" value="Belgium"/>
                                <param name="host_common_name" value="Human"/>
                                <param name="host_subject_id" value="Patient_001"/>
                                <param name="host_health_state" value="healthy"/>
                                <param name="host_sex" value="female"/>
                                <param name="host_scientific_name" value="homo sapiens"/>
                                <param name="collector_name" value="John The Collector"/>
                                <param name="collecting_institution" value="Hospital 01"/>
                                <param name="isolate" value="sample_001"/>
                                <repeat name="rep_experiment">
                                    <param name="experiment_title" value="Test experiment title"/>
                                    <param name="experiment_design" value="Test experiment design description"/>
                                    <param name="library_strategy" value="CTS"/>
                                    <param name="library_source" value="GENOMIC"/>
                                    <param name="library_selection" value="PCR"/>
                                    <param name="library_layout" value="SINGLE"/>
                                    <param name="insert_size" value="150"/>
                                    <param name="library_construction_protocol" value="Test library construction"/>
                                    <param name="platform" value="ILLUMINA"/>
                                    <param name="instrument_model" value="Illumina HiSeq 4000"/>
                                    <repeat name="rep_runs">
                                        <param name="run_base_name" value="run_from_hospital_X"/>
                                        <param name="upload_files" value="1.fastqsanger.gz,2.fastqsanger.gz" ftype="fastqsanger.gz"/>
                                    </repeat>
                                </repeat>
                            </repeat>
                        </repeat>
                    </conditional>
                </conditional>
            </conditional>
            <assert_command>
                <has_text_matching expression="ena-upload-cli"/>
                <has_text_matching expression="--data '1.fastqsanger.gz' '2.fastqsanger.gz'"/>
                <has_text_matching expression="--action 'modify' --center 'Some research center'"/>
                <has_text_matching expression="--checklist ERC000033"/>
                <not_has_text text="--action 'add'" />
            </assert_command>
        </test>
        <!--Test 9: isa JSON input of NON-VIRAL samples-->
        <test expect_num_outputs="5">
            <conditional name="action_options">
                <param name="action" value="add"/>
                <section name="test_submit_parameters">
                    <param name="center" value="Some research center"/>
                    <param name="submit_dev" value="True" />
                    <param name="dry_run" value="True" />
                </section>
                <conditional name="input_format_conditional">
                    <param name="input_format" value="isa_json"/>
                    <param name="isa_json_file" value="simple_test_case_v2.json"/>
                    <param name="isa_assay_stream" value="Ena stream 1"/>
                    <conditional name="run_input_format_conditional">
                        <param name="add_extension" value="False"/>
                        <param name="run_input_format" value="multiple_selection_list"/>
                        <param name="data" value="ENA_TEST1.R1.fastq.gz,ENA_TEST2.R1.fastq.gz,ENA_TEST2.R2.fastq.gz"/>
                    </conditional>
                </conditional>
            </conditional>
            <output name="experiments_table_out">
                <assert_contents>
                    <has_n_lines n="4"/>
                    <has_n_columns n="17"/>
                    <has_line_matching expression="alias\tstudy_alias\tsample_alias\tlibrary_name\ttitle\taccession\tsubmission date\tstatus\tdesign_description\tlibrary_source\tlibrary_strategy\tlibrary_selection\tlibrary_layout\tinsert_size\tplatform\tinstrument_model\tsubmission_date"/>
                </assert_contents>
            </output>
            <output name="studies_table_out">
                <assert_contents>
                    <has_n_lines n="2"/>
                    <has_n_columns n="9"/>
                    <has_line_matching expression="alias\ttitle\tstudy_type\tstudy_abstract\tnew_study_type\tpubmed_id\taccession\tsubmission_date\tstatus"/>
                </assert_contents>
            </output>
            <output name="samples_table_out">
                <assert_contents>
                    <has_n_lines n="3"/>
                    <has_n_columns n="11"/>
                </assert_contents>
            </output>
            <output name="runs_table_out">
                <assert_contents>
                    <has_n_lines n="4"/>
                    <has_n_columns n="10"/>
                    <has_line_matching expression="alias\texperiment_alias\tfile_name\tfile_type\tfile checksum\taccession\tsubmission date\tstatus\tsubmission_date\tfile_checksum"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[This is a wrapper for the ENA upload tool in https://github.com/usegalaxy-eu/ena-upload-cli. The input metadata can be submitted following the tabular format of the templates or their excel spreadsheet equivalent in https://github.com/ELIXIR-Belgium/ENA-metadata-templates. This template repo provides ready to use sheets for every ENA sample checklist and is automatically updated.
    
        .. class:: warningmark
    
            The ENA upload tool won't work unless you have provided an ENA Webin ID in User > Preferences > Manage Information > ENA Webin account details.]]></help>
    <citations>
        <citation type="doi">doi:10.1093/bioinformatics/btab421</citation>
    </citations>
</tool>