diff ena_consensus_submit.xml @ 0:e25357392813 draft

Uploaded
author ieguinoa
date Tue, 18 May 2021 16:30:52 +0000
parents
children f24eb2f2cb0c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ena_consensus_submit.xml	Tue May 18 16:30:52 2021 +0000
@@ -0,0 +1,159 @@
+<tool id="ena_consensus_submit" name="Submit consensus sequence to ENA" version="0.1.0" python_template_version="3.5">
+    <macros>
+        <token name="@VERSION@">3.7.0</token>
+    </macros>
+    <requirements>
+        <requirement type="package" version="@VERSION@">ena-webin-cli</requirement>
+        <requirement type="package" version="1.76">biopython</requirement>
+        <requirement type="package" version="5.3">pyyaml</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+
+webin_id=`grep 'username' $credentials | cut -f2,2`;
+if [ "\$webin_id" = "" ]; then
+  ## No credentials in user defined preferences    
+  ## Fallback to global defined credentials (if exist)   
+  #import os
+  #if os.path.isfile(os.environ.get('GALAXY_ENA_SECRETS', '')):
+      credentials_path=\${GALAXY_ENA_SECRETS};     
+      webin_id=`grep 'username' \$GALAXY_ENA_SECRETS | cut -d' ' -f2,2`;
+      password=`grep 'password' \$GALAXY_ENA_SECRETS | cut -d' ' -f2,2`;
+      if [ "\$webin_id" = "" ]; then
+          echo "No global credentials defined. Check your GALAXY_ENA_SECRETS file or set your credentials via: User -> Preferences -> Manage Information";
+          exit 1;
+      fi;
+  #else:
+      echo "No ENA credentials defined. Set your credentials via: User -> Preferences -> Manage Information";
+      exit 1;
+  #end if
+else
+  password=`grep 'password' $credentials | cut -f2,2`;
+fi;
+
+## if it is still running at this point then the webin_id and password are set
+
+## create a manifaste base file with the parameters that are identical for all sequences that will be submited (if submitting a multifasta)
+#set $manifest_base = 'manifest_base.tab'
+mkdir manifests;
+mkdir fasta;
+
+echo -e "ASSEMBLY_TYPE\t$assembly_type" >> $manifest_base;
+echo -e "COVERAGE\t$coverage" >> $manifest_base;
+echo -e "PROGRAM\t$assembly_program" >> $manifest_base;
+echo -e "MINGAPLENGTH\t$min_gap_length" >> $manifest_base;
+echo -e "MOLECULETYPE\t$molecule_type" >> $manifest_base;
+        
+#if $metadata_file_or_form.metadata_format == "file":
+    ## process the input tables, this creates an intermediate file with information
+    python3 '$__tool_directory__/process_input.py' $metadata_file_or_form.ena_receipt $genome_fasta './manifests' './fasta' $manifest_base;
+    center_name=`grep 'center_name' $metadata_file_or_form.ena_receipt | cut -f2,2 | tr -d '\n'`;
+#else:
+    #set $generated_manifest='./manifests/generated_manifest.txt'
+    cp $manifest_base $generated_manifest
+    $study_id = $metadata_file_or_form.study_accession
+    $sample_id = $metadata_file_or_form.sample_accession
+    echo "STUDY\t$study_id" > $generated_manifest;
+    echo "SAMPLE\t$sample_id" >> $generated_manifest;
+    center_name=$metadata_file_or_form.center_name;
+    echo "ASSEMBLY_NAME\t$metadata_file_or_form.assembly_name" >> $generated_manifest;
+    echo "PLATFORM\t$platform_name" >> $generated_manifest;
+#end if
+        
+
+#if $metadata_file_or_form.metadata_format == "file":
+    ## iterate over the list of manifest - fasta generated by the process_input
+    ## in case of errors, this list is empty
+    while read line; do
+        manifest=`echo \$line | cut -d' ' -f1,1`;
+        ena-webin-cli
+        -context genome
+        -userName \$webin_id
+        -password \$password
+        -centerName \$center_name 
+        -manifest \$manifest
+        -inputDir "./fasta"
+        #if $dry_run == "true":
+            -validate
+        #end if
+        ;
+    done < submit_list.tab
+
+#else:
+    gzip -c $genome_fasta > consensus.fasta.gz;
+    echo -e "FASTA\tconsensus.fasta.gz" >> $generated_manifest;
+    ena-webin-cli
+    -context genome 
+    -userName \$webin_id
+    -password \$password
+    -centerName '\$center_name' 
+    -manifest $generated_manifest
+    -inputDir "./"
+    #if $submit_test == "true":
+        -test
+    #end if
+    #if $dry_run == "true":
+        -validate
+    #else:
+        -submit
+    #end if
+#end if
+]]></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\t"$webin_id"
+    password\t"$password"
+#end if
+        ]]></configfile>
+    </configfiles>
+<inputs>
+    <param name="submit_test" type="boolean" default="False" label="Submit to test server" help="Suggested to test metadata format" />
+    <param name="dry_run" type="boolean" default="False" label="Validate files and metadata but do not submit" help="Generate input files and run Webin-CLI with -validate option."/>
+    <param name="genome_fasta" type="data" label="Select the consensus sequence assembly file" format="fasta"/>
+    <param name="assembly_type" type="select" label="Assembly type">
+        <option value="clone">Clone</option>
+        <option value="isolate">Isolate</option>
+    </param>
+    <param name="assembly_program" type="text" optional="False" label="Assembly program"/>
+    <param name="molecule_type" type="select" label="Molecule type">
+        <option value="genomic RNA" selected="True">genomic RNA</option>
+        <option value="viral cRNA">viral cRNA</option>
+        <option value="genomic DNA">genomic DNA</option>
+    </param>
+    <param name="min_gap_length" type="text" optional="True" label="Minimum gap length"/>
+    <param name="coverage" type="float" optional="False" value="10000" label="Coverage"/>
+    <conditional name="metadata_file_or_form">
+        <param name="metadata_format" type="select" label="Select the method to load study and sample metadata">
+            <option value="file" selected="True">I used Galaxy ENA upload tool for raw data submission, parse my submission receipt</option>
+            <option value="form">Fill in required metadata for linking</option>
+        </param>
+        <when value="file">
+            <param type="data" format="txt" name="ena_receipt" label="Submission receipt obtained from ENA upload tool"/>
+        </when>
+        <when value="form">
+            <param name="assembly_name" type="text" optional="False" label="Assembly name"/>
+            <param name="study_accession" type="text" optional="False" label="Study accession or unique name (alias)"/>
+            <param name="sample_accession" type="text" optional="False" label="Sample accession or unique name (alias)"/>
+            <param name="sequencing_platform" type="text" optional="False" label="Sequencing platform"/>
+            <param name="description" type="text" optional="True" value="" label="Description" help="Free text description of the genome assembly (optional)"/>
+            <param name="center_name" type="text" optional="False" label="Center name"/>
+        </when>
+    </conditional>
+    </inputs>
+    <outputs>
+        <collection name="generated_manifests" type="list" label="Generated manifests">
+            <!--<discover_datasets pattern="__name_and_ext__" directory="manifests" />-->
+            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.manifest\.txt$" ext="txt" directory="manifests" />
+        </collection>
+        <collection name="manifests_reports" type="list" label="Manifests reports">
+            <!--[><discover_datasets pattern="__name_and_ext__" directory="manifests" /><]-->
+            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.manifest\.txt\.report$" ext="txt" directory="manifests" />
+        </collection>
+        <data name="webin_cli_report" label="ENA submission receipt" format="txt" from_work_dir="manifests/webin-cli.report"/>
+    </outputs>
+    <help><![CDATA[
+        TODO: Fill in help.
+    ]]></help>
+</tool>