Mercurial > repos > eric-rasche > apollo
comparison export.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 | d4ae83dedb14 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6002cc0df04e |
---|---|
1 #!/usr/bin/env python | |
2 import StringIO | |
3 import sys | |
4 import json | |
5 import argparse | |
6 from Bio import SeqIO | |
7 from BCBio import GFF | |
8 from webapollo import WebApolloInstance | |
9 | |
10 if __name__ == '__main__': | |
11 json | |
12 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') | |
13 parser.add_argument('apollo', help='Complete Apollo URL') | |
14 parser.add_argument('username', help='WA Username') | |
15 parser.add_argument('password', help='WA Password') | |
16 | |
17 parser.add_argument('commonName', nargs='+', help='Sequence Unique Names') | |
18 | |
19 parser.add_argument('--gff', type=argparse.FileType('w')) | |
20 parser.add_argument('--fasta', type=argparse.FileType('w')) | |
21 | |
22 args = parser.parse_args() | |
23 | |
24 wa = WebApolloInstance(args.apollo, args.username, args.password) | |
25 | |
26 data = StringIO.StringIO(wa.io.write( | |
27 exportType='GFF3', | |
28 seqType='genomic', | |
29 exportAllSequences=False, | |
30 exportGff3Fasta=True, | |
31 output="text", | |
32 exportFormat="text", | |
33 # TODO: CPT specific convention!!!!!!!! | |
34 organism=args.commonName, | |
35 sequences=args.commonName | |
36 )) | |
37 data.seek(0) | |
38 | |
39 for record in GFF.parse(data): | |
40 record.annotations = {} | |
41 GFF.write([record], args.gff) | |
42 record.description = "" | |
43 SeqIO.write([record], args.fasta, 'fasta') | |
44 sys.exit() |