def main(args): url="http://pubchem.ncbi.nlm.nih.gov/rest/pug/"+args.type+"/" if args.type == "assay": url+="aid/" elif args.type == "compound": url+="cid/" elif args.type == "substance": url+="sid/" if args.id_file is None: idstring=str(args.id) else: idlist=readfile.getListFromFile(args.id_file) idstring=",".join(idlist) url+=idstring+"/"+args.operation+"/" if args.operation == "property": url+=args.property_value+"/" if args.operation in csv_output: url+="csv" elif args.operation in txt_output: url+="txt" else: url+="xml" if args.operation in check_for_id_type and not args.id_type is None: url+="?"+args.operation+"_type="+args.id_type print('The constructed REST URL is: %s' % url) data=readfile.getresult(url) outfile=args.outfile outfile.write(data) outfile.close()
def main(args): url = "http://pubchem.ncbi.nlm.nih.gov/rest/pug/" + args.type + "/" if args.type == "assay": url += "aid/" elif args.type == "compound": url += "cid/" elif args.type == "substance": url += "sid/" if args.id_file is None: idstring = str(args.id) else: idlist = readfile.getListFromFile(args.id_file) idstring = ",".join(idlist) url += idstring + "/" + args.operation + "/" if args.operation == "property": url += args.property_value + "/" if args.operation in csv_output: url += "csv" elif args.operation in txt_output: url += "txt" else: url += "xml" if args.operation in check_for_id_type and not args.id_type is None: url += "?" + args.operation + "_type=" + args.id_type print(url) data = readfile.getresult(url) outfile = args.outfile outfile.write(data) outfile.close()
def main(args): if args.aid_file is None: aidlist = args.aid.split(",") else: aidlist = readfile.getListFromFile(args.aid_file) aidliststring = ",".join(aidlist) url = "http://pubchem.ncbi.nlm.nih.gov/rest/pug/assay/aid/" + aidliststring + "/cids/xml" print('The constructed REST URL is: %s' % url) dic = rest_tool_functions.get_dict_key_value(url, "AID", "CID") rest_tool_functions.write_to_sf(dic, args.outfile, "\t")
def main(args): if args.aid_file is None: aidlist = args.aid.split(",") else: aidlist = readfile.getListFromFile(args.aid_file) aidliststring = ",".join(aidlist) url = "http://pubchem.ncbi.nlm.nih.gov/rest/pug/assay/aid/"+aidliststring+"/cids/xml" print('The constructed REST URL is: %s' % url) dic = rest_tool_functions.get_dict_key_value(url, "AID", "CID") rest_tool_functions.write_to_sf(dic, args.outfile, "\t")