This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is there way to do batchquery and obtain ATC codes for pubchem CIDs?

Hello,

I have large list of chemicals with common drug names and pubchem CIDs. I want to add the Anatomical Therapeutic Chemical (ATC) Classification System -codes (ATC codes), for each one of them. I notice that pubchem provides this info in the compound summary page. Is there a way to do batch query and obtain ATC codes? (or) is there any website or tool to get this info,i.e., given a pubchem CID obtain ATC codes?

Thanks, Diwan

pubchem cid atc codes

Diwan, were you able to solve this question? The pubchem API doesn't let you retrieve ATC codes as far as I can see

2 answers

Hi RF, My solution is given below. HTH

 
 #install.packages('httr')
  library(httr)
 #install.packages("RCurl")
  library(RCurl)
 #install.packages("RJSONIO")
  library(RJSONIO)
 #install.packages("plyr")
  library(plyr)

getATC <- function(cidnum){ pubchem_url_in<-paste('https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/',cidnum,'/JSON',sep='') pubchempage <- GET(pubchem_url_in) page_text <- content(pubchempage,as='text') page_test2 <- fromJSON(page_text) ATC_parse1 <- grep('www.whocc.no',unlist(page_test2),value=T) ATC_parse2 <- ATC_parse1[2] ATCout1 <-strsplit(strsplit(ATC_parse2,'code=')[[1]][2],'&showdescription')[[1]][1] return(c(cidnum,ATCout1)) }

getATC('3385')

 #For many CID query
cidnum_few<-c('5453','3385','3199')
testout <- lapply(cidnum_few,getATC)
cid_getatc <- do.call(rbind,testout)

Thanks so much for your help, this is very useful!

The pubchem API can do this task.

Log in to answer this question.