Mercurial > repos > eric-rasche > apollo
annotate delete_features.py @ 5:7610987e0c48 draft
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
author | eric-rasche |
---|---|
date | Wed, 01 Mar 2017 22:39:58 -0500 |
parents | |
children | f9a6e151b3b4 |
rev | line source |
---|---|
5
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
1 #!/usr/bin/env python |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
2 import argparse |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
3 from webapollo import WebApolloInstance |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
4 from webapollo import WAAuth, OrgOrGuess, GuessOrg, AssertUser |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
5 import logging |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
6 logging.basicConfig(level=logging.INFO) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
7 log = logging.getLogger(__name__) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
8 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
9 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
10 if __name__ == '__main__': |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
11 parser = argparse.ArgumentParser(description='Sample script to delete all features from an organism') |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
12 WAAuth(parser) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
13 parser.add_argument('email', help='User Email') |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
14 OrgOrGuess(parser) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
15 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
16 args = parser.parse_args() |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
17 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
18 wa = WebApolloInstance(args.apollo, args.username, args.password) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
19 # User must have an account |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
20 gx_user = AssertUser(wa.users.loadUsers(email=args.email)) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
21 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
22 # Get organism |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
23 org_cn = GuessOrg(args, wa) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
24 if isinstance(org_cn, list): |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
25 org_cn = org_cn[0] |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
26 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
27 # TODO: Check user perms on org. |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
28 org = wa.organisms.findOrganismByCn(org_cn) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
29 |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
30 # Call setSequence to tell apollo which organism we're working with |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
31 wa.annotations.setSequence(org['commonName'], org['id']) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
32 # Then get a list of features. |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
33 features = wa.annotations.getFeatures() |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
34 # For each feature in the features |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
35 for feature in features['features']: |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
36 # We see that deleteFeatures wants a uniqueName, and so we pass |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
37 # is the uniquename field in the feature. |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
38 print(wa.annotations.deleteFeatures([feature['uniquename']])) |
7610987e0c48
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents:
diff
changeset
|
39 |