Mercurial > repos > eric-rasche > apollo
comparison fetch_organism_jbrowse.py @ 3:d4ae83dedb14 draft
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
author | eric-rasche |
---|---|
date | Thu, 12 Jan 2017 11:52:28 -0500 |
parents | 6002cc0df04e |
children | f9a6e151b3b4 |
comparison
equal
deleted
inserted
replaced
2:c8e16c8eff98 | 3:d4ae83dedb14 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 import os | 2 import os |
3 import json | |
4 import argparse | 3 import argparse |
5 import time | 4 from webapollo import WAAuth, WebApolloInstance, GuessOrg, OrgOrGuess |
6 from webapollo import WebApolloInstance | |
7 import logging | 5 import logging |
8 import subprocess | 6 import subprocess |
9 logging.basicConfig(level=logging.INFO) | 7 logging.basicConfig(level=logging.INFO) |
10 log = logging.getLogger(__name__) | 8 log = logging.getLogger(__name__) |
11 | 9 |
12 | 10 |
13 if __name__ == '__main__': | 11 if __name__ == '__main__': |
14 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') | 12 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') |
15 parser.add_argument('apollo', help='Complete Apollo URL') | 13 WAAuth(parser) |
16 parser.add_argument('username', help='WA Admin Username') | 14 OrgOrGuess(parser) |
17 parser.add_argument('password', help='WA Admin Password') | |
18 parser.add_argument('cn', help='Organism Common Name') | |
19 parser.add_argument('email', help='User Email') | |
20 parser.add_argument('target_dir', help='Target directory') | 15 parser.add_argument('target_dir', help='Target directory') |
21 | 16 |
22 args = parser.parse_args() | 17 args = parser.parse_args() |
23 | 18 |
24 | |
25 wa = WebApolloInstance(args.apollo, args.username, args.password) | 19 wa = WebApolloInstance(args.apollo, args.username, args.password) |
26 # User must have an account | 20 # User must have an account |
27 gx_user = wa.users.loadUsers(email=args.email) | 21 org_cn = GuessOrg(args, wa) |
28 if len(gx_user) == 0: | 22 if isinstance(org_cn, list): |
29 raise Exception("Unknown user. Please register first") | 23 org_cn = org_cn[0] |
30 org = wa.organisms.findOrganismByCn(args.cn) | 24 org = wa.organisms.findOrganismByCn(org_cn) |
31 | |
32 | 25 |
33 if not os.path.exists(args.target_dir): | 26 if not os.path.exists(args.target_dir): |
34 os.makedirs(args.target_dir) | 27 os.makedirs(args.target_dir) |
35 | 28 |
36 cmd = [ | 29 cmd = [ |
37 'cp', '-R', | 30 'cp', '-R', |
38 org['directory'], | 31 org['directory'], |
39 os.path.join(args.target_dir, 'data') | 32 os.path.join(args.target_dir, 'data') |
40 ] | 33 ] |
41 print ' '.join(cmd) | |
42 subprocess.check_call(cmd) | 34 subprocess.check_call(cmd) |