Mercurial > repos > eric-rasche > apollo
comparison create_features_from_gff3.py @ 0:6002cc0df04e draft
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
author | eric-rasche |
---|---|
date | Tue, 03 May 2016 13:38:55 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6002cc0df04e |
---|---|
1 #!/usr/bin/env python | |
2 import argparse | |
3 from webapollo import WebApolloInstance, featuresToFeatureSchema | |
4 from BCBio import GFF | |
5 import logging | |
6 logging.basicConfig(level=logging.INFO) | |
7 log = logging.getLogger(__name__) | |
8 | |
9 | |
10 if __name__ == '__main__': | |
11 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') | |
12 parser.add_argument('apollo', help='Complete Apollo URL') | |
13 parser.add_argument('username', help='WA Admin Username') | |
14 parser.add_argument('password', help='WA Admin Password') | |
15 | |
16 parser.add_argument('cn', help='Organism Common Name') | |
17 parser.add_argument('email', help='User Email') | |
18 parser.add_argument('gff3', type=file, help='GFF3 file') | |
19 args = parser.parse_args() | |
20 | |
21 wa = WebApolloInstance(args.apollo, args.username, args.password) | |
22 # User must have an account | |
23 gx_user = wa.users.loadUsers(email=args.email) | |
24 if len(gx_user) == 0: | |
25 raise Exception("Unknown user. Please register first") | |
26 | |
27 # TODO: Check user perms on org. | |
28 | |
29 org = wa.organisms.findOrganismByCn(args.cn) | |
30 wa.annotations.setSequence(args.cn, org['id']) | |
31 | |
32 for rec in GFF.parse(args.gff3): | |
33 featureData = featuresToFeatureSchema(rec.features) | |
34 wa.annotations.addFeature( | |
35 { | |
36 'features': featureData | |
37 }, trustme=True | |
38 ) |