changeset 16:c3251541cf2b draft

"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 1f9a5502a7423c78d862e81537b7646c9f4da5d9"
author gga
date Fri, 10 Dec 2021 09:51:08 +0000
parents b503fe85f261
children f6e09a37bc8b
files export.py export.xml macros.xml
diffstat 3 files changed, 59 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/export.py	Tue Jun 08 09:16:01 2021 +0000
+++ b/export.py	Fri Dec 10 09:51:08 2021 +0000
@@ -16,11 +16,13 @@
     parser = argparse.ArgumentParser(description='Script to export data from Apollo via web services')
     CnOrGuess(parser)
     parser.add_argument('--gff', type=argparse.FileType('w'))
+    parser.add_argument('--gff_with_fasta', action='store_true')
     parser.add_argument('--fasta_pep', type=argparse.FileType('w'))
     parser.add_argument('--fasta_cds', type=argparse.FileType('w'))
     parser.add_argument('--fasta_cdna', type=argparse.FileType('w'))
     parser.add_argument('--vcf', type=argparse.FileType('w'))
     parser.add_argument('--json', type=argparse.FileType('w'))
+    parser.add_argument('--die', action='store_true')
     parser.add_argument('email', help='User Email')
     args = parser.parse_args()
 
@@ -39,6 +41,12 @@
         all_orgs = []
     all_orgs = [org['commonName'] for org in all_orgs]
 
+    def error(message):
+        if args.die:
+            raise Exception(message)
+        else:
+            print(message)
+
     org_data = []
     for org_cn in org_cns:
         if org_cn not in all_orgs:
@@ -50,39 +58,58 @@
 
         org = wa.organisms.show_organism(org_cn)
 
-        uuid_gff = wa.io.write_downloadable(org['commonName'], 'GFF3', export_gff3_fasta=True, sequences=seqs)
-        if 'error' in uuid_gff or 'uuid' not in uuid_gff:
-            raise Exception("Apollo failed to prepare the GFF3 file for download: %s" % uuid_gff)
-        args.gff.write(wa.io.download(uuid_gff['uuid'], output_format="text"))
+        # Fetch all the refseqs
+        realSeqs = wa.organisms.get_sequences(org['id'])
 
-        time.sleep(1)
+        # We'll loop over them individually for decreased memory pressure
+        for sequence in realSeqs['sequences']:
+            print("Downloading", sequence)
 
-        uuid_vcf = wa.io.write_downloadable(org['commonName'], 'VCF', sequences=seqs)
-        if 'error' in uuid_vcf or 'uuid' not in uuid_vcf:
-            raise Exception("Apollo failed to prepare the VCF file for download: %s" % uuid_vcf)
-        args.vcf.write(wa.io.download(uuid_vcf['uuid'], output_format="text"))
+            try:
+                uuid_gff = wa.io.write_downloadable(org['commonName'], 'GFF3', export_gff3_fasta=args.gff_with_fasta, sequences=[sequence['name']])
+                if 'error' in uuid_gff or 'uuid' not in uuid_gff:
+                    error("Apollo failed to prepare the GFF3 file for download: %s" % uuid_gff)
+                args.gff.write(wa.io.download(uuid_gff['uuid'], output_format="text"))
+                time.sleep(1)
+            except Exception as e:
+                error(e)
 
-        time.sleep(1)
+            try:
+                uuid_vcf = wa.io.write_downloadable(org['commonName'], 'VCF', sequences=[sequence['name']])
+                if 'error' in uuid_vcf or 'uuid' not in uuid_vcf:
+                    error("Apollo failed to prepare the VCF file for download: %s" % uuid_vcf)
+                args.vcf.write(wa.io.download(uuid_vcf['uuid'], output_format="text"))
+                time.sleep(1)
+            except Exception as e:
+                error(e)
 
-        uuid_fa = wa.io.write_downloadable(org['commonName'], 'FASTA', sequences=seqs, seq_type='cdna')
-        if 'error' in uuid_fa or 'uuid' not in uuid_fa:
-            raise Exception("Apollo failed to prepare the cdna FASTA file for download: %s" % uuid_fa)
-        args.fasta_cdna.write(wa.io.download(uuid_fa['uuid'], output_format="text"))
-
-        time.sleep(1)
+            try:
+                uuid_fa = wa.io.write_downloadable(org['commonName'], 'FASTA', sequences=[sequence['name']], seq_type='cdna')
+                if 'error' in uuid_fa or 'uuid' not in uuid_fa:
+                    error("Apollo failed to prepare the cdna FASTA file for download: %s" % uuid_fa)
+                args.fasta_cdna.write(wa.io.download(uuid_fa['uuid'], output_format="text"))
+                time.sleep(1)
+            except Exception as e:
+                error(e)
 
-        uuid_fa = wa.io.write_downloadable(org['commonName'], 'FASTA', sequences=seqs, seq_type='cds')
-        if 'error' in uuid_fa or 'uuid' not in uuid_fa:
-            raise Exception("Apollo failed to prepare the cds FASTA file for download: %s" % uuid_fa)
-        args.fasta_cds.write(wa.io.download(uuid_fa['uuid'], output_format="text"))
-
-        time.sleep(1)
+            try:
+                uuid_fa = wa.io.write_downloadable(org['commonName'], 'FASTA', sequences=[sequence['name']], seq_type='cds')
+                if 'error' in uuid_fa or 'uuid' not in uuid_fa:
+                    error("Apollo failed to prepare the cds FASTA file for download: %s" % uuid_fa)
+                args.fasta_cds.write(wa.io.download(uuid_fa['uuid'], output_format="text"))
+                time.sleep(1)
+            except Exception as e:
+                error(e)
 
-        uuid_fa = wa.io.write_downloadable(org['commonName'], 'FASTA', sequences=seqs, seq_type='peptide')
-        if 'error' in uuid_fa or 'uuid' not in uuid_fa:
-            raise Exception("Apollo failed to prepare the file for download: %s" % uuid_fa)
-        args.fasta_pep.write(wa.io.download(uuid_fa['uuid'], output_format="text"))
+            try:
+                uuid_fa = wa.io.write_downloadable(org['commonName'], 'FASTA', sequences=[sequence['name']], seq_type='peptide')
+                if 'error' in uuid_fa or 'uuid' not in uuid_fa:
+                    error("Apollo failed to prepare the file for download: %s" % uuid_fa)
+                args.fasta_pep.write(wa.io.download(uuid_fa['uuid'], output_format="text"))
+                time.sleep(1)
+            except Exception as e:
+                error(e)
 
-        org_data.append(org)
+            org_data.append(org)
 
     args.json.write(json.dumps(org_data, indent=2))
--- a/export.xml	Tue Jun 08 09:16:01 2021 +0000
+++ b/export.xml	Fri Dec 10 09:51:08 2021 +0000
@@ -13,17 +13,21 @@
 @ORG_CN_OR_GUESS@
 
 --gff '$gff_out'
+$gff_with_fasta
 --fasta_pep '$fasta_pep'
 --fasta_cds '$fasta_cds'
 --fasta_cdna '$fasta_cdna'
 --vcf '$vcf_out'
 --json '$json_out'
+$die
 
 '$__user_email__'
 
 ]]></command>
   <inputs>
     <expand macro="cn_or_guess" />
+    <param name="gff_with_fasta" type="boolean" truevalue="--gff_with_fasta" falsevalue="" label="Include fasta in the GFF3 file" help="The fasta is available separately in the cDNA sequence file, but some tools might prefer it included in the GFF3 file."/>
+    <param name="die" type="boolean" truevalue="--die" falsevalue="" label="Fail hard if any portion of the export fails" help="By default it will just print a warning message, this causes any error to be fatal."/>
   </inputs>
   <outputs>
     <data format="gff3" name="gff_out" label="Annotations from Apollo"/>
--- a/macros.xml	Tue Jun 08 09:16:01 2021 +0000
+++ b/macros.xml	Fri Dec 10 09:51:08 2021 +0000
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <macros>
-  <token name="@WRAPPER_VERSION@">4.2.13</token>
+  <token name="@WRAPPER_VERSION@">4.2.13+galaxy0</token>
 
   <xml name="requirements">
     <requirements>