1 | SearchHMDB(hmdb, info = "Pathways")
|
hmdb |
|
info |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (hmdb, info = "Pathways")
{
switch(info, Pathways = "pathway/name", Biocyc = "biocyc_id",
Synonyms = "synonym", CellularLocation = "cellular_location",
BiofluidLocation = "biofluid", TissueLocation = "tissue")
if (!hmdb == "error" || !is.null(hmdb)) {
url <- paste0("http://www.hmdb.ca/metabolites/", hmdb,
".xml")
xmlhttp <- getURL(url)
if (grepl("metabolite", xmlhttp, ignore.case = TRUE) ==
TRUE) {
if (is.null(xmlhttp)) {
return("error")
}
else {
doc <- (xmlParse(xmlhttp))
src <- tryCatch(xpathSApply(doc, paste0("//",
info), xmlValue), error = function(e) {
NULL
})
if (length(src) > 0) {
src <- unlist(src)
return(src)
}
else (return("error"))
}
}
else {
return("error")
}
}
else {
return("error")
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.