view ena_upload.xml @ 7:811b7e34b119 draft

Uploaded
author ieguinoa
date Thu, 13 Aug 2020 09:08:00 +0000
parents 202bb21c6090
children 1de9953780eb
line wrap: on
line source

<tool id="ena_upload" name="ENA Upload tool" version="0.1.0" python_template_version="3.5">
  <macros>
    <token name="@VERSION@">0.1.5</token>   
  </macros>    
  <requirements>
    <requirement type="package" version="@VERSION@">ena-upload-cli</requirement>
  </requirements>
  <command detect_errors="exit_code"><![CDATA[
cwd=\$(pwd);
#set webin_id = os.environ.get('WEBIN_ID', None)
#set webin_secret = os.environ.get('WEBIN_SECRET', None)
#set working_dir = os.getcwd()   
#set $dry_run_option = "False"
#if $action_options.input_format_conditional.input_format == "build_tables":
  python $__tool_directory__/extract_tables.py --out_dir \$cwd --studies $studies_json;
  #set $studies_table_path = "$cwd/studies.tsv"
  #set $samples_table_path =   "$cwd/samples.tsv"
  #set $experiments_table_path = "$cwd/experiments.tsv"
  #set $runs_table_path =  "$cwd/runs.tsv"
#end if

#if $action_options.input_format_conditional.input_format != "user_generated_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;
    #if $action_options.input_format_conditional.dry_run == "true":
      #set $dry_run_option = "True"
    #end if
#end if



## create the list of files to upload and make the symlinks 
#set $files_to_upload = list()
#if $action_options.input_format_conditional.input_format == "build_tables":
    #for $study in $action_options.input_format_conditional.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:
                ln -s $file $file.element_identifier;
                $files_to_upload.append(str($file.element_identifier))
            #end for
          #end for
        #end for
      #end for
    #end for
#else:
    #for $file in $action_options.input_format_conditional.data:
        ln -s $file $file.element_identifier;
        $files_to_upload.append(str($file.element_identifier))
    #end for
#end if


#if $dry_run_option == "False":
ena-upload-cli
    --action 'add'
    --center '$action_options.center'
    --webin_id '$webin_id'
    --secret '$webin_secret'
    --data
    #for $dataset in $files_to_upload:
      $dataset
    #end for
#if $action_options.input_format_conditional.input_format == "user_generated_tables":
    --experiment $action_options.input_format_conditional.experiments_users_table
    --study $action_options.input_format_conditional.studies_users_table
    --run $action_options.input_format_conditional.runs_users_table
    --sample $action_options.input_format_conditional.samples_users_table
#else:
    --experiment $experiments_table_path
    --study $studies_table_path
    --run $runs_table_path
    --sample $samples_table_path
#end if
#if $action_options.submit_dev == "true":
    -d
#end if
  > $output  
#end if

    ]]></command>
    <configfiles>
    <configfile name="studies_json">
#import json
#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.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:
              $run_files.append(str($file.element_identifier))
            #end for
            $runs.append($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_strategy),'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
      $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})
    #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 data</option>
                <option value="modify">Modify metadata</option>
            </param>
            <when value="add">
                <param name="submit_dev" type="boolean" label="Submit to test ENA server?"/>
                <conditional name="input_format_conditional">
                    <param name="input_format" type="select" label="Would you like to submit pregenerated table files or interactively define the input structures?">
                        <option value="user_generated_tables" selected="True">User generated tables of studies/experiments/runs/samples</option>
                        <option value="build_tables" selected="False">Interactive generation of studies structure from dataset</option>
                    </param>    
                    <when value="user_generated_tables">
                        <param name="data" type="data" format="fastqsanger.gz,fastqsanger.bz2,fastq.gz,fastq.bz2" multiple="true" label="Select all datasets to upload" help="Compressed reads files listed in the runs table"/>
                        <param name="studies_users_table" type="data" format="tabular" multiple="false" label="Studies table" help="Studies metadata file"/>
                        <param name="samples_users_table" type="data" format="tabular" multiple="false" label="Samples table" help="Samples metadata file"/>
                        <param name="experiments_users_table" type="data" format="tabular" multiple="false" label="Experiments table" help="Experiments metadata file"/>
                        <param name="runs_users_table" type="data" format="tabular" multiple="false" label="Runs table" help="Runs metadata file"/>
                    </when>
                    <when value="build_tables">
                        <param name="dry_run" type="boolean" label="Print the tables but do not submit the datasets"/>
                        <repeat name="rep_study" title="Study" min="1">
                            <param name="study_title" type="text" optional="False" label="Please provide a short descriptive title for the study"/>
                            <param name="study_abstract" type="text" optional="True" label="Please provide an abstract to describe the study in detail"/>
                            <param name="study_type" type="select" label="Please select the type of study">
                                    <options from_file="study_type.txt">
                                        <column name="value" index="0"/>
                                    </options>
                            </param>
                            <param name="study_pubmed_id" type="text" optional="True" value="" label="Please provide the PubMed id if exists (or leave it blank)"/>
                            <repeat name="rep_sample" title="Samples associated with this study" min="1" >
                                <param name="sample_title" type="text" default="Blood sample" label="Sample title"/>
                                <param name="sample_description" type="text" default="liver cells" label="Describe the type of sample"/>
                                <param name="scientific_name" type="text" default="Homo Sapiens" label="Enter the species of the sample" help=""/>
                                <param name="tax_id" type="text" label="Enter the taxonomic ID corresponding to the sample species" help=""/>
                                <repeat name="rep_experiment" title="Sequencing experiments performed with this sample" min="1" >
                                    <param name="experiment_title" type="text" label="Specify an experiment title" />
                                    <param name="experiment_design" type="text" label="Describe the experiment design" />
                                    <param name="library_strategy" type="select" label="Library strategy" help="The library strategy specifies the sequencing technique intended for this library">
                                        <options from_file="library_strategy.txt">
                                            <column name="value" index="0"/>
                                        </options>
                                    </param>
                                    <param name="library_source" type="select" label="Select library source" help="The library source specifies the type of source material that is being sequenced">
                                        <options from_file="library_source.txt">
                                            <column name="value" index="0"/>
                                        </options>
                                    </param>
                                    <param name="library_selection" type="select" label="Library selection" help="The library selection specifies whether any method was used to select for or against, enrich, or screen the material being sequenced">
                                        <options from_file="library_selection.txt">
                                            <column name="value" index="0"/>
                                        </options>
                                    </param>
                                    <param name="library_layout" type="select" label="Library layout">
                                        <options from_file="library_layout.txt">
                                            <column name="value" index="0"/>
                                        </options>
                                    </param>
                                    <param name="insert_size" type="integer" value="0" label="Specify the insert size"/>
                                    <param name="library_construction_protocol" type="text" label="Please describe the library construction protocol"/>
                                    <param name="platform" type="select" label="Select the sequencing platform used">
                                        <option value="LS454">LS454</option>
                                        <option value="ILLUMINA">Illumina</option>
                                        <option value="HELICOS">Helicos</option>
                                        <option value="ABI_SOLID">ABI Solid</option>
                                        <option value="COMPLETE_GENOMICS">Complete Genomics</option>
                                        <option value="BGISEQ">BGI Seq</option>
                                        <option value="OXFORD_NANOPORE">Oxford Nanopore</option>
                                        <option value="PACBIO_SMRT">PacBio</option>
                                        <option value="ION_TORRENT">Ion Torrent</option>
                                        <option value="CAPILLARY">Capillary sequencing</option>
                                    </param>
                                    <param name="instrument_model" type="select" label="Instrument model">
                                        <options from_file="instrument_model.txt">
                                            <column name="value" index="0"/>
                                        </options>
                                    </param>
                                    <repeat name="rep_runs" title="Runs executed within this experiment" min="1" >
                                        <param name="upload_files" type="data" format="fastqsanger.gz,fastqsanger.bz2,fastq.gz,fastq.bz" multiple="true" label="File(s) associated with this run"/>
                                    </repeat>
                                </repeat>
                            </repeat>
                        </repeat>
                    </when>
                </conditional>
            <param name="center" type="text" optional="False" label="Affiliation center"/>
            </when>
            <when value="modify">
                <param name="modify_first" type="text" label="Mofification of submitted data is not yet possible"/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format="data" label="${tool.name} on ${on_string}: Upload summary"/>
        <data name="studies_table_out" format="tabular" label="Studies table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" </filter>
        </data>
        <data name="samples_table_out" format="tabular" label="Samples table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" </filter>
        </data>
        <data name="experiments_table_out" format="tabular" label="Experiments table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" </filter>
        </data>
        <data name="runs_table_out" format="tabular" label="Runs table">
            <filter> action_options['input_format_conditional']['input_format'] == "build_tables" </filter>
        </data>
    </outputs>
    <help><![CDATA[
        TODO: Fill in help.
    ]]></help>
</tool>