annotate create_or_update_organism.py @ 11:56b9a26694c0 draft

"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
author gga
date Tue, 14 Apr 2020 10:39:32 -0400
parents c3b5bc8b4080
children f6e09a37bc8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b4a85d0c85b8 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
b4a85d0c85b8 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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
3
b4a85d0c85b8 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
b4a85d0c85b8 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
b4a85d0c85b8 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
db216690cbbf 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
56b9a26694c0 "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
b4a85d0c85b8 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
c3b5bc8b4080 "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
db216690cbbf 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
b4a85d0c85b8 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
c3b5bc8b4080 "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
db216690cbbf 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
b4a85d0c85b8 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
56b9a26694c0 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
17
10
c3b5bc8b4080 "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
c3b5bc8b4080 "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
db216690cbbf 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
c3b5bc8b4080 "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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
22
c3b5bc8b4080 "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
c3b5bc8b4080 "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
b4a85d0c85b8 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)
b4a85d0c85b8 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__)
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
27
7
db216690cbbf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
28
db216690cbbf 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():
db216690cbbf 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:
db216690cbbf 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
db216690cbbf 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']
db216690cbbf 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'):
db216690cbbf 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
db216690cbbf 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:
db216690cbbf 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
db216690cbbf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
37
db216690cbbf 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
c3b5bc8b4080 "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():
c3b5bc8b4080 "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:
c3b5bc8b4080 "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
c3b5bc8b4080 "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()
c3b5bc8b4080 "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'):
c3b5bc8b4080 "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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
45
c3b5bc8b4080 "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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
47
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
48
c3b5bc8b4080 "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():
c3b5bc8b4080 "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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
51
c3b5bc8b4080 "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
56b9a26694c0 "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):
56b9a26694c0 "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)
56b9a26694c0 "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):
56b9a26694c0 "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:
56b9a26694c0 "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)
56b9a26694c0 "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)
56b9a26694c0 "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)
56b9a26694c0 "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('./'):
56b9a26694c0 "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
56b9a26694c0 "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):
56b9a26694c0 "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()
56b9a26694c0 "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):
56b9a26694c0 "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
56b9a26694c0 "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
56b9a26694c0 "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)
56b9a26694c0 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 81492a9c8b9e5649a3867bc30afe617a30fb47a1"
gga
parents: 10
diff changeset
68
56b9a26694c0 "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
b4a85d0c85b8 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__':
b4a85d0c85b8 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
c3b5bc8b4080 "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')
c3b5bc8b4080 "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
b4a85d0c85b8 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')
b4a85d0c85b8 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)
b4a85d0c85b8 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')
b4a85d0c85b8 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')
b4a85d0c85b8 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')
b4a85d0c85b8 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')
b4a85d0c85b8 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
c3b5bc8b4080 "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')
c3b5bc8b4080 "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
db216690cbbf 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()
db216690cbbf 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
db216690cbbf 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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
86
10
c3b5bc8b4080 "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'
c3b5bc8b4080 "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
db216690cbbf 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
c3b5bc8b4080 "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():
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
91 if(os.path.exists(args.jbrowse)):
c3b5bc8b4080 "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)
c3b5bc8b4080 "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
c3b5bc8b4080 "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
db216690cbbf 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
c3b5bc8b4080 "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'
c3b5bc8b4080 "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:
c3b5bc8b4080 "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")
c3b5bc8b4080 "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
c3b5bc8b4080 "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
db216690cbbf planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit b9143221aee2cd09e1334ee56ff9651550b1797a
gga
parents: 5
diff changeset
101
db216690cbbf 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
c3b5bc8b4080 "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
db216690cbbf 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
c3b5bc8b4080 "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)
c3b5bc8b4080 "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()
c3b5bc8b4080 "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
db216690cbbf 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
c3b5bc8b4080 "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)
c3b5bc8b4080 "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)
c3b5bc8b4080 "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():
c3b5bc8b4080 "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
c3b5bc8b4080 "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
db216690cbbf 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
c3b5bc8b4080 "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()
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
116
c3b5bc8b4080 "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
c3b5bc8b4080 "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))
c3b5bc8b4080 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
120
b4a85d0c85b8 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)
b4a85d0c85b8 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):
b4a85d0c85b8 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]
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
124
10
c3b5bc8b4080 "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:
c3b5bc8b4080 "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()
c3b5bc8b4080 "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:
c3b5bc8b4080 "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
c3b5bc8b4080 "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':
c3b5bc8b4080 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
131
b4a85d0c85b8 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")
b4a85d0c85b8 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
c3b5bc8b4080 "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
b4a85d0c85b8 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:
b4a85d0c85b8 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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
137
10
c3b5bc8b4080 "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
236155b4e5f9 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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
140
10
c3b5bc8b4080 "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()
c3b5bc8b4080 "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:
c3b5bc8b4080 "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 = []
c3b5bc8b4080 "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]
c3b5bc8b4080 "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:
c3b5bc8b4080 "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)
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
147
c3b5bc8b4080 "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')
c3b5bc8b4080 "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:
c3b5bc8b4080 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
151
b4a85d0c85b8 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
c3b5bc8b4080 "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():
c3b5bc8b4080 "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:
c3b5bc8b4080 "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:
c3b5bc8b4080 "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
56b9a26694c0 "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
c3b5bc8b4080 "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():
c3b5bc8b4080 "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")
c3b5bc8b4080 "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(
c3b5bc8b4080 "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'],
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
169 )
c3b5bc8b4080 "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:
c3b5bc8b4080 "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(
c3b5bc8b4080 "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'],
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
c3b5bc8b4080 "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
b4a85d0c85b8 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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
183
c3b5bc8b4080 "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
b4a85d0c85b8 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)
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
186
10
c3b5bc8b4080 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
188
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
189 else:
b4a85d0c85b8 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
b4a85d0c85b8 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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
192
c3b5bc8b4080 "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():
c3b5bc8b4080 "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:
c3b5bc8b4080 "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:
c3b5bc8b4080 "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
56b9a26694c0 "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
c3b5bc8b4080 "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():
c3b5bc8b4080 "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:
c3b5bc8b4080 "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)
c3b5bc8b4080 "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/")
c3b5bc8b4080 "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")
c3b5bc8b4080 "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(
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
c3b5bc8b4080 "planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
gga
parents: 8
diff changeset
211 )
c3b5bc8b4080 "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:
c3b5bc8b4080 "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]
c3b5bc8b4080 "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:
c3b5bc8b4080 "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(
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
c3b5bc8b4080 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
224
b4a85d0c85b8 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
b4a85d0c85b8 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)
b4a85d0c85b8 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
c3b5bc8b4080 "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(
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
b4a85d0c85b8 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,
b4a85d0c85b8 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,
b4a85d0c85b8 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,
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
234 )
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
235
b4a85d0c85b8 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
b4a85d0c85b8 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
c3b5bc8b4080 "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]
c3b5bc8b4080 "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,
c3b5bc8b4080 "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,
c3b5bc8b4080 "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
b4a85d0c85b8 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
242
b4a85d0c85b8 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))