6
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import sys, os
|
|
4 import argparse
|
|
5 import readfile
|
|
6
|
|
7 def main(args):
|
|
8 #search for acitivity or target
|
|
9 url="http://pubchem.ncbi.nlm.nih.gov/rest/pug/assay/"
|
|
10 if args.activity is None:
|
|
11 #target
|
8
|
12 url+= "target/%s/%s" % ( args.targettype, args.targetid )
|
6
|
13 else:
|
|
14 url+="activity/"+args.activity
|
|
15 url+="/aids/txt"
|
|
16 data=readfile.getresult(url)
|
|
17 args.outfile.write(data)
|
|
18 args.outfile.close()
|
|
19
|
|
20
|
|
21 if __name__ == "__main__":
|
|
22 parser = argparse.ArgumentParser()
|
|
23 parser.add_argument('--activity', type=str,
|
|
24 help="Activities you are looking for")
|
|
25 parser.add_argument('--target-type', dest="target_type", type=str,
|
|
26 help="The target identifier type")
|
|
27 parser.add_argument('--target-id', dest="target_id", type=str,
|
|
28 help="The specific target")
|
|
29 parser.add_argument('--outfile', type=argparse.FileType('w'), required=True,
|
|
30 help="Specify output file")
|
|
31 if len(sys.argv) < 2:
|
|
32 print "Too few arguments..."
|
|
33 parser.print_help()
|
|
34 exit(1)
|
|
35 args = parser.parse_args()
|
|
36 main( args )
|