annotate create_or_update_organism.py @ 17:1a2404ca43f9 draft default tip

planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 12282c16658b37858f49944796fd95515ef0fc0b
author gga
date Wed, 11 Jan 2023 11:47:13 +0000
parents 3323060ba9a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f889e757ca93 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
f889e757ca93 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
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
3
f889e757ca93 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
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
5 import json
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
6 import logging
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
7 import os
11
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
8 import re
0
f889e757ca93 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
a46a509386d3 "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
0d9cb9e56ca0 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
f889e757ca93 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
a46a509386d3 "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
0d9cb9e56ca0 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
f889e757ca93 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
11
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
16 from pathlib import Path
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
17
10
a46a509386d3 "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 import accessible_organisms
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
19 from apollo.util import GuessOrg, OrgOrGuess
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
20
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
21 from arrow.apollo import get_apollo_instance
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
22
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
23 from webapollo import UserObj, handle_credentials
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
24
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
25 logging.basicConfig(level=logging.INFO)
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
26 log = logging.getLogger(__name__)
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
27
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
28
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
29 def IsBlatEnabled():
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
30 if 'BLAT_ENABLED' not in os.environ:
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
31 return False
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
32 value = os.environ['BLAT_ENABLED']
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
33 if value.lower() in ('true', 't', '1'):
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
34 return True
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
35 else:
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
36 return False
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
37
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
38
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
39 def IsOrgCNSuffixEnabled():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
40 if 'GALAXY_APOLLO_ORG_SUFFIX' not in os.environ:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
41 return False
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
42 value = os.environ['GALAXY_APOLLO_ORG_SUFFIX'].lower()
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
43 if value in ('id', 'email'):
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
44 return value
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
45
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
46 return False
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
47
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
48
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
49 def IsRemote():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
50 return 'GALAXY_SHARED_DIR' not in os.environ or len(os.environ['GALAXY_SHARED_DIR'].lower().strip()) == 0
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
51
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
52
11
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
53 def zip_data_dir(dataset_data_dir, tar):
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
54 tar.add(dataset_data_dir, arcname='./', recursive=False)
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
55 for r, d, f in os.walk(dataset_data_dir):
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
56 for file_name in f:
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
57 abs_file = os.path.join(r, file_name)
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
58 rel_dir = os.path.relpath(r, dataset_data_dir)
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
59 rel_file = os.path.join(rel_dir, file_name)
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
60 if not rel_file.startswith('./'):
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
61 rel_file = './' + rel_file
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
62 if os.path.islink(abs_file):
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
63 target = Path(abs_file).resolve().absolute().as_posix()
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
64 if re.match(r'.*/_metadata_files/[0-9]+/metadata_[0-9]+.dat', target):
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
65 # This is a metadata file generated by galaxy, symlink would certainly be dead on remote host, resolve it
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
66 abs_file = target
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
67 tar.add(abs_file, arcname=rel_file)
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
68
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
69
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
70 if __name__ == '__main__':
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
71 parser = argparse.ArgumentParser(description='Create or update an organism in an Apollo instance')
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
72 parser.add_argument('jbrowse_src', help='Source JBrowse Data Directory')
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
73 parser.add_argument('jbrowse', help='Destination JBrowse Data Directory')
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
74 parser.add_argument('email', help='User Email')
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
75 OrgOrGuess(parser)
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
76 parser.add_argument('--genus', help='Organism Genus')
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
77 parser.add_argument('--species', help='Organism Species')
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
78 parser.add_argument('--public', action='store_true', help='Make organism public')
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
79 parser.add_argument('--group', help='Give access to a user group')
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
80 parser.add_argument('--remove_old_directory', action='store_true', help='Remove old directory')
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
81 parser.add_argument('--no_reload_sequences', action='store_true', help='Disable update genome sequence')
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
82 parser.add_argument('--userid', help='User unique id')
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
83 args = parser.parse_args()
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
84 CHUNK_SIZE = 2**20
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
85 blat_db = None
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
86
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
87 path_fasta = args.jbrowse_src + '/seq/genome.fasta'
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
88
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
89 # Cleanup if existing
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
90 if not IsRemote():
17
1a2404ca43f9 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 12282c16658b37858f49944796fd95515ef0fc0b
gga
parents: 11
diff changeset
91 if os.path.exists(args.jbrowse):
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
92 shutil.rmtree(args.jbrowse)
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
93 # Copy files
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
94 shutil.copytree(args.jbrowse_src, args.jbrowse, symlinks=True)
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
95
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
96 path_2bit = args.jbrowse + '/seq/genome.2bit'
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
97 else:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
98 twobittemp = tempfile.NamedTemporaryFile(prefix="genome.2bit")
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
99 path_2bit = twobittemp.name
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
100 os.chmod(path_2bit, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
101
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
102 # Convert fasta if existing
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
103 if IsBlatEnabled() and os.path.exists(path_fasta):
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
104 arg = ['faToTwoBit', path_fasta, path_2bit]
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
105 proc = subprocess.Popen(args=arg, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
106 out, err = proc.communicate()
a46a509386d3 "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 proc.returncode:
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
108 print("Error building index:", file=sys.stderr)
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
109 sys.stderr.write(err)
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
110 sys.exit(proc.returncode)
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
111 if not IsRemote():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
112 # No need to send this in remote mode, it will be in the archive
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
113 blat_db = path_2bit
7
0d9cb9e56ca0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
114
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
115 wa = get_apollo_instance()
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
116
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
117 # User must have an account, if not, create it
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
118 gx_user = UserObj(**wa.users._assert_or_create_user(args.email))
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
119 handle_credentials(gx_user)
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
120
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
121 org_cn = GuessOrg(args, wa)
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
122 if isinstance(org_cn, list):
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
123 org_cn = org_cn[0]
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
124
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
125 if args.org_raw:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
126 suffix = IsOrgCNSuffixEnabled()
a46a509386d3 "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 suffix == 'id' and args.userid:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
128 org_cn += ' (gx%s)' % args.userid
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
129 elif suffix == 'email':
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
130 org_cn += ' (%s)' % args.email
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
131
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
132 log.info("Determining if add or update required")
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
133 try:
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
134 org = wa.organisms.show_organism(org_cn)
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
135 except Exception:
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
136 org = None
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
137
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
138 if org and 'error' not in org:
3
b8e4642ef5dd planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 079b759c21c00200544a6d8d5521617dce8ca70d
gga
parents: 0
diff changeset
139 old_directory = org['directory']
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
140
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
141 all_orgs = wa.organisms.get_organisms()
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
142 if 'error' in all_orgs:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
143 all_orgs = []
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
144 all_orgs = [x['commonName'] for x in all_orgs]
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
145 if org_cn not in all_orgs:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
146 raise Exception("Could not find organism %s" % org_cn)
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
147
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
148 orgs = accessible_organisms(gx_user, [org_cn], 'WRITE')
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
149 if not orgs:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
150 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
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
151
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
152 log.info("\tUpdating Organism")
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
153 if IsRemote():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
154 with tempfile.NamedTemporaryFile(suffix='.tar.gz') as archive:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
155 with tarfile.open(archive.name, mode="w:gz") as tar:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
156 dataset_data_dir = args.jbrowse_src
11
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
157 zip_data_dir(dataset_data_dir, tar)
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
158 if IsBlatEnabled():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
159 tar.add(path_2bit, arcname="./searchDatabaseData/genome.2bit")
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
160 data = wa.remote.update_organism(
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
161 org['id'],
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
162 archive,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
163 # mandatory
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
164 blatdb=blat_db,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
165 genus=args.genus,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
166 species=args.species,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
167 public=args.public,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
168 no_reload_sequences=args.no_reload_sequences
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
169 )
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
170 else:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
171 data = wa.organisms.update_organism(
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
172 org['id'],
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
173 org_cn,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
174 args.jbrowse,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
175 # mandatory
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
176 genus=args.genus,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
177 species=args.species,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
178 public=args.public,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
179 blatdb=blat_db,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
180 no_reload_sequences=args.no_reload_sequences
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
181 )
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
182 time.sleep(2)
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
183
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
184 if not IsRemote() and args.remove_old_directory and args.jbrowse != old_directory:
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
185 shutil.rmtree(old_directory)
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
186
10
a46a509386d3 "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.organisms.show_organism(org_cn)
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
188
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
189 else:
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
190 # New organism
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
191 log.info("\tAdding Organism")
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
192
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
193 if IsRemote():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
194 with tempfile.NamedTemporaryFile(suffix='.tar.gz') as archive:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
195 with tarfile.open(archive.name, mode="w:gz") as tar:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
196 dataset_data_dir = args.jbrowse_src
11
3323060ba9a6 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
197 zip_data_dir(dataset_data_dir, tar)
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
198 if IsBlatEnabled():
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
199 with tempfile.TemporaryDirectory() as empty_dir:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
200 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)
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
201 tar.add(empty_dir, arcname="./searchDatabaseData/")
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
202 tar.add(path_2bit, arcname="./searchDatabaseData/genome.2bit")
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
203 data = wa.remote.add_organism(
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
204 org_cn,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
205 archive,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
206 blatdb=blat_db,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
207 genus=args.genus,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
208 species=args.species,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
209 public=args.public,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
210 metadata=None
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
211 )
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
212 if isinstance(data, list) and len(data) > 0:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
213 data = data[0]
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
214 else:
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
215 data = wa.organisms.add_organism(
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
216 org_cn,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
217 args.jbrowse,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
218 blatdb=blat_db,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
219 genus=args.genus,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
220 species=args.species,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
221 public=args.public,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
222 metadata=None
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
223 )
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
224
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
225 # Must sleep before we're ready to handle
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
226 time.sleep(2)
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
227 log.info("Updating permissions for %s on %s", gx_user, org_cn)
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
228 wa.users.update_organism_permissions(
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
229 gx_user.username,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
230 org_cn,
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
231 write=True,
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
232 export=True,
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
233 read=True,
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
234 )
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
235
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
236 # Group access
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
237 if args.group:
10
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
238 group = wa.groups.get_groups(name=args.group)[0]
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
239 res = wa.groups.update_organism_permissions(group['name'], org_cn,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
240 administrate=False, write=True, read=True,
a46a509386d3 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
241 export=True)
0
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
242
f889e757ca93 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
243 print(json.dumps(data, indent=2))