annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1 #!/usr/bin/env python
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
2 import json
1
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
3 import base64
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
4 import argparse
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
5
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
6 if __name__ == '__main__':
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
7 parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services')
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
8 parser.add_argument('apollo', help='Complete Apollo URL')
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
9 parser.add_argument('json', type=file, help='JSON Data')
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
10
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
11 args = parser.parse_args()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
12
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
13
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
14 # https://cpt.tamu.edu/apollo/annotator/loadLink?loc=NC_005880:0..148317&organism=326&tracks=
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
15 data = json.load(args.json)
1
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
16 print data
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
17 if len(data) > 1:
1
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
18 raise Exception("More than one organism listed. Contact your local admin for help.")
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
19
1
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
20 # This is base64 encoded to get past the toolshed's filters.
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
21 HTML_TPL = """
1
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
22 PGh0bWw+PGhlYWQ+PHRpdGxlPkVtYmVkZGVkIEFwb2xsbyBBY2Nlc3M8L3RpdGxlPjxzdHlsZSB0
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
23 eXBlPSJ0ZXh0L2NzcyI+Ym9keSB7e21hcmdpbjogMDt9fSBpZnJhbWUge3tib3JkZXI6IDA7d2lk
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
24 dGg6IDEwMCU7aGVpZ2h0OiAxMDAlfX08L3N0eWxlPjwvaGVhZD48Ym9keT48aWZyYW1lIHNyYz0i
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
25 e2Jhc2VfdXJsfS9hbm5vdGF0b3IvbG9hZExpbms/bG9jPXtjaHJvbX0mb3JnYW5pc209e29yZ0lk
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
26 fSZ0cmFja2xpc3Q9MSI+PC9pZnJhbWU+PC9ib2R5PjwvaHRtbD4K
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
27 """
1
f7d57e56f322 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 0f3c6e906c4d32843f451990b55bfa2954235a42
eric-rasche
parents: 0
diff changeset
28 HTML_TPL = base64.b64decode(HTML_TPL.replace('\n', ''))
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
29
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
30 print HTML_TPL.format(base_url=args.apollo, chrom="", orgId=data[0]['id'])