comparison delete_organism.py @ 5:0af4179e6758 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:10 -0400
parents dc738069b5ac
children dd63c6e11a95
comparison
equal deleted inserted replaced
4:a5de2095bd01 5:0af4179e6758
2 from __future__ import print_function 2 from __future__ import print_function
3 3
4 import argparse 4 import argparse
5 import logging 5 import logging
6 6
7 from webapollo import AssertUser, GuessOrg, OrgOrGuess, WAAuth, WebApolloInstance 7 from webapollo import GuessOrg, OrgOrGuess, PermissionCheck, WAAuth, WebApolloInstance
8 logging.basicConfig(level=logging.INFO) 8 logging.basicConfig(level=logging.INFO)
9 log = logging.getLogger(__name__) 9 log = logging.getLogger(__name__)
10 10
11 11
12 if __name__ == '__main__': 12 if __name__ == '__main__':
17 17
18 args = parser.parse_args() 18 args = parser.parse_args()
19 19
20 wa = WebApolloInstance(args.apollo, args.username, args.password) 20 wa = WebApolloInstance(args.apollo, args.username, args.password)
21 # User must have an account 21 # User must have an account
22 gx_user = AssertUser(wa.users.loadUsers(email=args.email)) 22 gx_user = wa.users.assertOrCreateUser(args.email)
23 23
24 # Get organism 24 # Get organism
25 org_cn = GuessOrg(args, wa) 25 org_cn = GuessOrg(args, wa)
26 if isinstance(org_cn, list): 26 if isinstance(org_cn, list):
27 org_cn = org_cn[0] 27 org_cn = org_cn[0]
28 28
29 # TODO: Check user perms on org. 29 if not PermissionCheck(gx_user, org_cn, "WRITE"):
30 raise Exception("You do not have write permission on this organism")
30 org = wa.organisms.findOrganismByCn(org_cn) 31 org = wa.organisms.findOrganismByCn(org_cn)
31 32
32 # Call setSequence to tell apollo which organism we're working with 33 # Call setSequence to tell apollo which organism we're working with
33 wa.annotations.setSequence(org['commonName'], org['id']) 34 wa.annotations.setSequence(org['commonName'], org['id'])
34 # Then get a list of features. 35 # Then get a list of features.
35 features = wa.annotations.getFeatures() 36 features = wa.annotations.getFeatures()
36 # For each feature in the features 37 # For each feature in the features
37 for feature in features['features']: 38 # If it exists
38 # We see that deleteFeatures wants a uniqueName, and so we pass 39 if 'features' in features:
39 # is the uniquename field in the feature. 40 for feature in features['features']:
40 print(wa.annotations.deleteFeatures([feature['uniquename']])) 41 # We see that deleteFeatures wants a uniqueName, and so we pass
42 # is the uniquename field in the feature.
43 print(wa.annotations.deleteFeatures([feature['uniquename']]))