Mercurial > repos > bernhardlutz > rest_tool
comparison rest_tool_assay_by_activity_or_target.py @ 4:54358dfa62c0 draft
Uploaded
author | bernhardlutz |
---|---|
date | Fri, 28 Mar 2014 13:41:22 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:0bbb107a2cf2 | 4:54358dfa62c0 |
---|---|
1 #!/usr/bin/env python | |
2 # Aufruf convert_graph.py --aid list of ids --aid-from-file file | |
3 | |
4 import sys, os | |
5 import argparse | |
6 | |
7 | |
8 import readfile | |
9 | |
10 def main(args): | |
11 #search for acitivity or target | |
12 url="http://pubchem.ncbi.nlm.nih.gov/rest/pug/assay/" | |
13 if args.activity is None: | |
14 #target | |
15 url+="target/"+args.targettype+"/"+args.targetid | |
16 else: | |
17 url+="activity/"+args.activity | |
18 url+="/aids/txt" | |
19 data=readfile.getresult(url) | |
20 args.outfile.write(data) | |
21 args.outfile.close() | |
22 | |
23 | |
24 if __name__ == "__main__": | |
25 parser = argparse.ArgumentParser() | |
26 parser.add_argument('--activity', type=str, | |
27 help="Activities you are looking for") | |
28 parser.add_argument('--targettype', type=str, | |
29 help="The target identifier type") | |
30 parser.add_argument('--targetid', type=str, | |
31 help="The specific target") | |
32 parser.add_argument('--outfile', type=argparse.FileType('w'), | |
33 help="Specify output file") | |
34 if len(sys.argv) < 2: | |
35 print "Too few arguments..." | |
36 parser.print_help() | |
37 exit(1) | |
38 args = parser.parse_args() | |
39 main( args ) |