Mercurial > repos > gga > apollo_delete_features
diff fetch_organism_jbrowse.py @ 10:df0e4eb2dfa5 draft
"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
author | gga |
---|---|
date | Mon, 02 Dec 2019 05:44:41 -0500 |
parents | f7e9c792047b |
children | 21a8cad7dfa5 |
line wrap: on
line diff
--- a/fetch_organism_jbrowse.py Mon Jul 29 10:09:19 2019 -0400 +++ b/fetch_organism_jbrowse.py Mon Dec 02 05:44:41 2019 -0500 @@ -9,7 +9,13 @@ import sys import time -from webapollo import GuessOrg, OrgOrGuess, PermissionCheck, WAAuth, WebApolloInstance +from apollo import accessible_organisms +from apollo.util import GuessOrg, OrgOrGuess + +from arrow.apollo import get_apollo_instance + +from webapollo import UserObj, handle_credentials + logging.basicConfig(level=logging.INFO) log = logging.getLogger(__name__) @@ -52,27 +58,34 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') - WAAuth(parser) OrgOrGuess(parser) parser.add_argument('target_dir', help='Target directory') parser.add_argument('email', help='User Email') args = parser.parse_args() - wa = WebApolloInstance(args.apollo, args.username, args.password) + wa = get_apollo_instance() # User must have an account org_cn = GuessOrg(args, wa) if isinstance(org_cn, list): org_cn = org_cn[0] - org = wa.organisms.findOrganismByCn(org_cn) # User must have an account, if not, create it - gx_user = wa.users.assertOrCreateUser(args.email) + gx_user = UserObj(**wa.users._assert_or_create_user(args.email)) + handle_credentials(gx_user) + + all_orgs = wa.organisms.get_organisms() + if 'error' in all_orgs: + all_orgs = [] + all_orgs = [org['commonName'] for org in all_orgs] + if org_cn not in all_orgs: + raise Exception("Could not find organism %s" % org_cn) # User must have READ access - - if not PermissionCheck(gx_user, org_cn, "READ"): - raise Exception("READ permissions are required for this action") + orgs = accessible_organisms(gx_user, [org_cn], 'READ') + if not orgs: + raise Exception("You do not have write permission on this organism") + org = wa.organisms.show_organism(org_cn) if not os.path.exists(args.target_dir): os.makedirs(args.target_dir) @@ -94,7 +107,7 @@ # files / folders before and after. sys.stderr.write(' '.join(cmd)) sys.stderr.write('\n') - sys.stderr.write(subprocess.check_output(cmd)) + sys.stderr.write(subprocess.check_output(cmd).decode(sys.stderr.encoding)) if not are_dir_trees_equal( os.path.join(org['directory'].rstrip('/')), os.path.join(args.target_dir, 'data') @@ -104,7 +117,7 @@ sys.stderr.write('\n') sys.stderr.write(' '.join(cmd)) sys.stderr.write('\n') - sys.stderr.write(subprocess.check_output(cmd)) + sys.stderr.write(subprocess.check_output(cmd).decode(sys.stderr.encoding)) if not are_dir_trees_equal( os.path.join(org['directory'].rstrip('/'), 'data'), os.path.join(args.target_dir, 'data') @@ -113,7 +126,7 @@ sys.stderr.write('\n') sys.stderr.write(' '.join(cmd)) sys.stderr.write('\n') - sys.stderr.write(subprocess.check_output(cmd)) + sys.stderr.write(subprocess.check_output(cmd).decode(sys.stderr.encoding)) if not are_dir_trees_equal( os.path.join(org['directory'].rstrip('/'), 'data'), os.path.join(args.target_dir, 'data')