Mercurial > repos > bernhardlutz > rest_tool
comparison rest_tool.py @ 8:3c1e862e8cd6 draft
Uploaded
author | bernhardlutz |
---|---|
date | Fri, 02 May 2014 05:40:28 -0400 |
parents | 9ee84d9fd3a7 |
children |
comparison
equal
deleted
inserted
replaced
7:35b41070c20d | 8:3c1e862e8cd6 |
---|---|
4 import argparse | 4 import argparse |
5 | 5 |
6 import readfile | 6 import readfile |
7 | 7 |
8 txt_output=["cids", "aids", "sids", "synonyms" ] | 8 txt_output=["cids", "aids", "sids", "synonyms" ] |
9 csv_output=["assaysummary"] | 9 csv_output=["assaysummary", "property"] |
10 check_for_id_type=["cids", "aids", "sids"] | 10 check_for_id_type=["cids", "aids", "sids"] |
11 | 11 |
12 def main(args): | 12 def main(args): |
13 url="http://pubchem.ncbi.nlm.nih.gov/rest/pug/"+args.type+"/" | 13 url="http://pubchem.ncbi.nlm.nih.gov/rest/pug/"+args.type+"/" |
14 if args.type == "assay": | 14 if args.type == "assay": |
21 idstring=str(args.id) | 21 idstring=str(args.id) |
22 else: | 22 else: |
23 idlist=readfile.getListFromFile(args.id_file) | 23 idlist=readfile.getListFromFile(args.id_file) |
24 idstring=",".join(idlist) | 24 idstring=",".join(idlist) |
25 url+=idstring+"/"+args.operation+"/" | 25 url+=idstring+"/"+args.operation+"/" |
26 if args.operation == "property": | |
27 url+=args.property_value+"/" | |
26 if args.operation in csv_output: | 28 if args.operation in csv_output: |
27 url+="csv" | 29 url+="csv" |
28 elif args.operation in txt_output: | 30 elif args.operation in txt_output: |
29 url+="txt" | 31 url+="txt" |
30 else: | 32 else: |