Mercurial > repos > gga > apollo_iframe
annotate create_or_update_organism.py @ 10:c6172b538caf draft
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
author | gga |
---|---|
date | Mon, 02 Dec 2019 05:42:52 -0500 |
parents | 860ca63f4a59 |
children | e1346ad005b3 |
rev | line source |
---|---|
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
1 #!/usr/bin/env python |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
2 from __future__ import print_function |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
3 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
4 import argparse |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
5 import glob |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
6 import json |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
7 import logging |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
8 import os |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
9 import shutil |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
10 import stat |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
11 import subprocess |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
12 import sys |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
13 import tarfile |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
14 import tempfile |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
15 import time |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
16 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
17 from apollo import accessible_organisms |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
18 from apollo.util import GuessOrg, OrgOrGuess |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
19 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
20 from arrow.apollo import get_apollo_instance |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
21 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
22 from webapollo import UserObj, handle_credentials |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
23 |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
24 logging.basicConfig(level=logging.INFO) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
25 log = logging.getLogger(__name__) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
26 |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
27 |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
28 def IsBlatEnabled(): |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
29 if 'BLAT_ENABLED' not in os.environ: |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
30 return False |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
31 value = os.environ['BLAT_ENABLED'] |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
32 if value.lower() in ('true', 't', '1'): |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
33 return True |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
34 else: |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
35 return False |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
36 |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
37 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
38 def IsOrgCNSuffixEnabled(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
39 if 'GALAXY_APOLLO_ORG_SUFFIX' not in os.environ: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
40 return False |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
41 value = os.environ['GALAXY_APOLLO_ORG_SUFFIX'].lower() |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
42 if value in ('id', 'email'): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
43 return value |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
44 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
45 return False |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
46 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
47 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
48 def IsRemote(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
49 return 'GALAXY_SHARED_DIR' not in os.environ or len(os.environ['GALAXY_SHARED_DIR'].lower().strip()) == 0 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
50 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
51 |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
52 if __name__ == '__main__': |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
53 parser = argparse.ArgumentParser(description='Create or update an organism in an Apollo instance') |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
54 parser.add_argument('jbrowse_src', help='Source JBrowse Data Directory') |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
55 parser.add_argument('jbrowse', help='Destination JBrowse Data Directory') |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
56 parser.add_argument('email', help='User Email') |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
57 OrgOrGuess(parser) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
58 parser.add_argument('--genus', help='Organism Genus') |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
59 parser.add_argument('--species', help='Organism Species') |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
60 parser.add_argument('--public', action='store_true', help='Make organism public') |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
61 parser.add_argument('--group', help='Give access to a user group') |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
62 parser.add_argument('--remove_old_directory', action='store_true', help='Remove old directory') |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
63 parser.add_argument('--no_reload_sequences', action='store_true', help='Disable update genome sequence') |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
64 parser.add_argument('--userid', help='User unique id') |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
65 args = parser.parse_args() |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
66 CHUNK_SIZE = 2**20 |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
67 blat_db = None |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
68 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
69 path_fasta = args.jbrowse_src + '/seq/genome.fasta' |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
70 |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
71 # Cleanup if existing |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
72 if not IsRemote(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
73 if(os.path.exists(args.jbrowse)): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
74 shutil.rmtree(args.jbrowse) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
75 # Copy files |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
76 shutil.copytree(args.jbrowse_src, args.jbrowse, symlinks=True) |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
77 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
78 path_2bit = args.jbrowse + '/seq/genome.2bit' |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
79 else: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
80 twobittemp = tempfile.NamedTemporaryFile(prefix="genome.2bit") |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
81 path_2bit = twobittemp.name |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
82 os.chmod(path_2bit, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
83 |
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
84 # Convert fasta if existing |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
85 if IsBlatEnabled() and os.path.exists(path_fasta): |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
86 arg = ['faToTwoBit', path_fasta, path_2bit] |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
87 proc = subprocess.Popen(args=arg, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
88 out, err = proc.communicate() |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
89 if proc.returncode: |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
90 print("Error building index:", file=sys.stderr) |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
91 sys.stderr.write(err) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
92 sys.exit(proc.returncode) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
93 if not IsRemote(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
94 # No need to send this in remote mode, it will be in the archive |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
95 blat_db = path_2bit |
7
9305e1881519
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents:
5
diff
changeset
|
96 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
97 wa = get_apollo_instance() |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
98 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
99 # User must have an account, if not, create it |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
100 gx_user = UserObj(**wa.users._assert_or_create_user(args.email)) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
101 handle_credentials(gx_user) |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
102 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
103 org_cn = GuessOrg(args, wa) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
104 if isinstance(org_cn, list): |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
105 org_cn = org_cn[0] |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
106 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
107 if args.org_raw: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
108 suffix = IsOrgCNSuffixEnabled() |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
109 if suffix == 'id' and args.userid: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
110 org_cn += ' (gx%s)' % args.userid |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
111 elif suffix == 'email': |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
112 org_cn += ' (%s)' % args.email |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
113 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
114 log.info("Determining if add or update required") |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
115 try: |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
116 org = wa.organisms.show_organism(org_cn) |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
117 except Exception: |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
118 org = None |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
119 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
120 if org and 'error' not in org: |
3
951ef9b7bafc
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 079b759c21c00200544a6d8d5521617dce8ca70d
gga
parents:
0
diff
changeset
|
121 old_directory = org['directory'] |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
122 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
123 all_orgs = wa.organisms.get_organisms() |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
124 if 'error' in all_orgs: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
125 all_orgs = [] |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
126 all_orgs = [x['commonName'] for x in all_orgs] |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
127 if org_cn not in all_orgs: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
128 raise Exception("Could not find organism %s" % org_cn) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
129 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
130 orgs = accessible_organisms(gx_user, [org_cn], 'WRITE') |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
131 if not orgs: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
132 raise Exception("Naming Conflict. You do not have write permission on this organism. Either request permission from the owner, or choose a different name for your organism.") |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
133 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
134 log.info("\tUpdating Organism") |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
135 if IsRemote(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
136 with tempfile.NamedTemporaryFile(suffix='.tar.gz') as archive: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
137 with tarfile.open(archive.name, mode="w:gz") as tar: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
138 dataset_data_dir = args.jbrowse_src |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
139 for file in glob.glob(dataset_data_dir): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
140 tar.add(file, arcname=file.replace(dataset_data_dir, './')) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
141 if IsBlatEnabled(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
142 tar.add(path_2bit, arcname="./searchDatabaseData/genome.2bit") |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
143 data = wa.remote.update_organism( |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
144 org['id'], |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
145 archive, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
146 # mandatory |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
147 blatdb=blat_db, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
148 genus=args.genus, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
149 species=args.species, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
150 public=args.public, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
151 no_reload_sequences=args.no_reload_sequences |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
152 ) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
153 else: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
154 data = wa.organisms.update_organism( |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
155 org['id'], |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
156 org_cn, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
157 args.jbrowse, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
158 # mandatory |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
159 genus=args.genus, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
160 species=args.species, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
161 public=args.public, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
162 blatdb=blat_db, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
163 no_reload_sequences=args.no_reload_sequences |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
164 ) |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
165 time.sleep(2) |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
166 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
167 if not IsRemote() and args.remove_old_directory and args.jbrowse != old_directory: |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
168 shutil.rmtree(old_directory) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
169 |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
170 data = wa.organisms.show_organism(org_cn) |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
171 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
172 else: |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
173 # New organism |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
174 log.info("\tAdding Organism") |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
175 |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
176 if IsRemote(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
177 with tempfile.NamedTemporaryFile(suffix='.tar.gz') as archive: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
178 with tarfile.open(archive.name, mode="w:gz") as tar: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
179 dataset_data_dir = args.jbrowse_src |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
180 for file in glob.glob(dataset_data_dir): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
181 tar.add(file, arcname=file.replace(dataset_data_dir, './')) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
182 if IsBlatEnabled(): |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
183 with tempfile.TemporaryDirectory() as empty_dir: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
184 os.chmod(empty_dir, stat.S_IRUSR | stat.S_IXUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
185 tar.add(empty_dir, arcname="./searchDatabaseData/") |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
186 tar.add(path_2bit, arcname="./searchDatabaseData/genome.2bit") |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
187 data = wa.remote.add_organism( |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
188 org_cn, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
189 archive, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
190 blatdb=blat_db, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
191 genus=args.genus, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
192 species=args.species, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
193 public=args.public, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
194 metadata=None |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
195 ) |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
196 if isinstance(data, list) and len(data) > 0: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
197 data = data[0] |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
198 else: |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
199 data = wa.organisms.add_organism( |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
200 org_cn, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
201 args.jbrowse, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
202 blatdb=blat_db, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
203 genus=args.genus, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
204 species=args.species, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
205 public=args.public, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
206 metadata=None |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
207 ) |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
208 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
209 # Must sleep before we're ready to handle |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
210 time.sleep(2) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
211 log.info("Updating permissions for %s on %s", gx_user, org_cn) |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
212 wa.users.update_organism_permissions( |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
213 gx_user.username, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
214 org_cn, |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
215 write=True, |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
216 export=True, |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
217 read=True, |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
218 ) |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
219 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
220 # Group access |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
221 if args.group: |
10
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
222 group = wa.groups.get_groups(name=args.group)[0] |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
223 res = wa.groups.update_organism_permissions(group['name'], org_cn, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
224 administrate=False, write=True, read=True, |
c6172b538caf
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents:
8
diff
changeset
|
225 export=True) |
0
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
226 |
99b348a1d355
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
227 print(json.dumps(data, indent=2)) |