Mercurial > repos > bernhardlutz > rest_tool
diff rest_tool_assay_by_activity_or_target.py @ 6:9ee84d9fd3a7 draft
Uploaded
author | bernhardlutz |
---|---|
date | Thu, 03 Apr 2014 06:50:57 -0400 |
parents | |
children | 3c1e862e8cd6 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rest_tool_assay_by_activity_or_target.py Thu Apr 03 06:50:57 2014 -0400 @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import sys, os +import argparse +import readfile + +def main(args): + #search for acitivity or target + url="http://pubchem.ncbi.nlm.nih.gov/rest/pug/assay/" + if args.activity is None: + #target + url+="target/"+args.targettype+"/"+args.targetid + else: + url+="activity/"+args.activity + url+="/aids/txt" + data=readfile.getresult(url) + args.outfile.write(data) + args.outfile.close() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--activity', type=str, + help="Activities you are looking for") + parser.add_argument('--target-type', dest="target_type", type=str, + help="The target identifier type") + parser.add_argument('--target-id', dest="target_id", type=str, + help="The specific target") + parser.add_argument('--outfile', type=argparse.FileType('w'), required=True, + help="Specify output file") + if len(sys.argv) < 2: + print "Too few arguments..." + parser.print_help() + exit(1) + args = parser.parse_args() + main( args )