Mercurial > repos > gga > apollo_create_account
diff delete_organism.py @ 5:356b43302b16 draft
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 85194fa009ead2c34720faab61a4143fc29d17c2
author | gga |
---|---|
date | Fri, 31 Aug 2018 09:34:20 -0400 |
parents | f889e757ca93 |
children | a46a509386d3 |
line wrap: on
line diff
--- a/delete_organism.py Mon Mar 12 06:32:42 2018 -0400 +++ b/delete_organism.py Fri Aug 31 09:34:20 2018 -0400 @@ -4,7 +4,7 @@ import argparse import logging -from webapollo import AssertUser, GuessOrg, OrgOrGuess, WAAuth, WebApolloInstance +from webapollo import GuessOrg, OrgOrGuess, PermissionCheck, WAAuth, WebApolloInstance logging.basicConfig(level=logging.INFO) log = logging.getLogger(__name__) @@ -19,14 +19,15 @@ wa = WebApolloInstance(args.apollo, args.username, args.password) # User must have an account - gx_user = AssertUser(wa.users.loadUsers(email=args.email)) + gx_user = wa.users.assertOrCreateUser(args.email) # Get organism org_cn = GuessOrg(args, wa) if isinstance(org_cn, list): org_cn = org_cn[0] - # TODO: Check user perms on org. + if not PermissionCheck(gx_user, org_cn, "WRITE"): + raise Exception("You do not have write permission on this organism") org = wa.organisms.findOrganismByCn(org_cn) # Call setSequence to tell apollo which organism we're working with @@ -34,7 +35,9 @@ # Then get a list of features. features = wa.annotations.getFeatures() # For each feature in the features - for feature in features['features']: - # We see that deleteFeatures wants a uniqueName, and so we pass - # is the uniquename field in the feature. - print(wa.annotations.deleteFeatures([feature['uniquename']])) + # If it exists + if 'features' in features: + for feature in features['features']: + # We see that deleteFeatures wants a uniqueName, and so we pass + # is the uniquename field in the feature. + print(wa.annotations.deleteFeatures([feature['uniquename']]))