comparison delete_organism.py @ 0:1f2e360f7554 draft

planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit f745b23c84a615bf434d717c8c0e553a012f0268
author gga
date Mon, 11 Sep 2017 05:48:05 -0400
parents
children a3000d01c04c
comparison
equal deleted inserted replaced
-1:000000000000 0:1f2e360f7554
1 #!/usr/bin/env python
2 from __future__ import print_function
3
4 import argparse
5 import logging
6
7 from webapollo import AssertUser, GuessOrg, OrgOrGuess, WAAuth, WebApolloInstance
8 logging.basicConfig(level=logging.INFO)
9 log = logging.getLogger(__name__)
10
11
12 if __name__ == '__main__':
13 parser = argparse.ArgumentParser(description='Sample script to completely delete an organism')
14 WAAuth(parser)
15 parser.add_argument('email', help='User Email')
16 OrgOrGuess(parser)
17
18 args = parser.parse_args()
19
20 wa = WebApolloInstance(args.apollo, args.username, args.password)
21 # User must have an account
22 gx_user = AssertUser(wa.users.loadUsers(email=args.email))
23
24 # Get organism
25 org_cn = GuessOrg(args, wa)
26 if isinstance(org_cn, list):
27 org_cn = org_cn[0]
28
29 # TODO: Check user perms on org.
30 org = wa.organisms.findOrganismByCn(org_cn)
31
32 # Call setSequence to tell apollo which organism we're working with
33 wa.annotations.setSequence(org['commonName'], org['id'])
34 # Then get a list of features.
35 features = wa.annotations.getFeatures()
36 # For each feature in the features
37 for feature in features['features']:
38 # We see that deleteFeatures wants a uniqueName, and so we pass
39 # is the uniquename field in the feature.
40 print(wa.annotations.deleteFeatures([feature['uniquename']]))