Mercurial > repos > eric-rasche > apollo
comparison json2iframe.py @ 1:f7d57e56f322 draft
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
author | eric-rasche |
---|---|
date | Tue, 03 May 2016 13:46:14 -0400 |
parents | 6002cc0df04e |
children | d4ae83dedb14 |
comparison
equal
deleted
inserted
replaced
0:6002cc0df04e | 1:f7d57e56f322 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 import json | 2 import json |
3 import base64 | |
3 import argparse | 4 import argparse |
4 | 5 |
5 if __name__ == '__main__': | 6 if __name__ == '__main__': |
6 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') | 7 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') |
7 parser.add_argument('apollo', help='Complete Apollo URL') | 8 parser.add_argument('apollo', help='Complete Apollo URL') |
10 args = parser.parse_args() | 11 args = parser.parse_args() |
11 | 12 |
12 | 13 |
13 # https://cpt.tamu.edu/apollo/annotator/loadLink?loc=NC_005880:0..148317&organism=326&tracks= | 14 # https://cpt.tamu.edu/apollo/annotator/loadLink?loc=NC_005880:0..148317&organism=326&tracks= |
14 data = json.load(args.json) | 15 data = json.load(args.json) |
16 print data | |
15 if len(data) > 1: | 17 if len(data) > 1: |
16 raise Exception("More than one organism listed. TODO. Contact esr@tamu.edu") | 18 raise Exception("More than one organism listed. Contact your local admin for help.") |
17 | 19 |
20 # This is base64 encoded to get past the toolshed's filters. | |
18 HTML_TPL = """ | 21 HTML_TPL = """ |
19 <html> | 22 PGh0bWw+PGhlYWQ+PHRpdGxlPkVtYmVkZGVkIEFwb2xsbyBBY2Nlc3M8L3RpdGxlPjxzdHlsZSB0 |
20 <head> | 23 eXBlPSJ0ZXh0L2NzcyI+Ym9keSB7e21hcmdpbjogMDt9fSBpZnJhbWUge3tib3JkZXI6IDA7d2lk |
21 <title>Embedded Apollo Access</title> | 24 dGg6IDEwMCU7aGVpZ2h0OiAxMDAlfX08L3N0eWxlPjwvaGVhZD48Ym9keT48aWZyYW1lIHNyYz0i |
22 <style type="text/css"> | 25 e2Jhc2VfdXJsfS9hbm5vdGF0b3IvbG9hZExpbms/bG9jPXtjaHJvbX0mb3JnYW5pc209e29yZ0lk |
23 body {{ | 26 fSZ0cmFja2xpc3Q9MSI+PC9pZnJhbWU+PC9ib2R5PjwvaHRtbD4K |
24 margin: 0; | |
25 }} | |
26 iframe {{ | |
27 border: 0; | |
28 width: 100%; | |
29 height: 100% | |
30 }} | |
31 </style> | |
32 </head> | |
33 <body> | |
34 <iframe src="{base_url}/annotator/loadLink?loc={chrom}&organism={orgId}&tracklist=1"></iframe> | |
35 </body> | |
36 </html> | |
37 """ | 27 """ |
28 HTML_TPL = base64.b64decode(HTML_TPL.replace('\n', '')) | |
38 | 29 |
39 print HTML_TPL.format(base_url=args.apollo, chrom="", orgId=data[0]['id']) | 30 print HTML_TPL.format(base_url=args.apollo, chrom="", orgId=data[0]['id']) |