Hi all,
I have list of compound names for which i want to retrieve Pubchem CIDs..to acheive this i wrote a biopython script as follows but it doenst seem to working
from Bio import Entrez
Entrez.email = "sainitin7@gmail.com"
infile = open("data", "r")
out_put = open("ids_data.csv","w")
for line in infile.readlines():
single_id = line
#Post list of ids to database
handle= Entrez.epost("pccompound",names=single_id)
record = Entrez.read(handle)
#history
webEnv=record["WebEnv"]
queryKey=record["QueryKey"]
#Retreiving information
data = Entrez.esummary(db="pccompound",webenv=webEnv,query_key=queryKey)
res=Entrez.read(data)
for compound in res:
Name = compound["SynonymList"]
Cid = compound["Id"]
print "%s:%s" %(Name,Cid)
out_put.write("%s:%s\n" %(Name,Cid))
out_put.close()
Ideally i want a output as follows
Biruvidine : 446727
Can any body help
Thanks in advance
Nit
Can you fix the formatting? The example is very hard to read, and you didn't show the current output. It sounds like given an PubChem identifier like SID 74891762 you want to get back 'Brivudine: CID446727' - is that right?
Can you fix the formatting? The example is very hard to read.
And what do you mean by "it doenst seem to working"? What is the error message, if any?
Thanks for fixing the formatting. Could you also include an example of the text in ids_data.csv so we have both sample input AND the desired output?