Question: Parse Drugbank XML in R
gravatar for kakukeshi
3.1 years ago by
kakukeshi70 wrote:

Hi guys,

Anybody knows how to parse the complete drugbank database in xml into R. I need the drug mechanism of action, so I can't use the other downloadable files from drugbank.


R drug xml gene • 2.6k views
ADD COMMENTlink modified 18 months ago by mohfcis20 • written 3.1 years ago by kakukeshi70
gravatar for EverInEarnest
3.1 years ago by
EverInEarnest30 wrote:

I successfully used the xmlEventParse() function in R ( to extract selected fields from the DrugBank database. (After experimenting with loading the full 600+ MB database into memory, and finding that that was not working, I ended up using this SAX parsing method.)

I've included a subset of my code to give you a feel for what this looks like:

library(gdata) <- array(dim = 0)

# Define function to extract necessary data from each drug (= each main node)
getDrug <- function(x, ...) {

  # name the current drug for easy reference
  current_drug <- read_xml(toString.XMLNode(x));

  # extract properties related to drug <- xml_text(xml_find_first(current_drug, './name'))

  # remove the current node from memory when finished with it


# Use event-driven SAX parser to process the XML without requiring the full tree structure to be loaded into memory
# Call the function defined above
xmlEventParse(file = filename, handlers = NULL, trim = FALSE, branches = list(drug = getDrug))

Hope this helps.

ADD COMMENTlink modified 3.1 years ago • written 3.1 years ago by EverInEarnest30

hello I am trying this but i am not getting results. and its throwing end of line error. can somoone help in processing this? it would be greatful ? i tried as the above mentioned script but of no luck. please do help me thank you

ADD REPLYlink modified 2.4 years ago • written 2.4 years ago by pampana.akhil0
gravatar for mohfcis
18 months ago by
mohfcis20 wrote:

I know it is an old post, but for anyone how might be having the same question. There is a new package called dbparser to parse drugbank database into several R datasets

ADD COMMENTlink written 18 months ago by mohfcis20
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1435 users visited in the last hour