# superfunction
kegg_conv <- function(source, target) {
url <- sprintf('http://rest.kegg.jp/conv/%s/%s', target, source)
resp <- httr::GET(url)
if (.kegg_check_response(resp)) {
return(kegg_parse_conv(resp, c(source, target)))
}
stop(httr::http_status(resp)$message)
}
# middleware
kegg_is_conv <- function(query) {
if (query %in% c('ncbi-geneid', 'ncbi-proteinid', 'uniprot', 'pubmed', 'pubchem', 'chebi')) {
return(invisible(TRUE))
}
return(invisible(FALSE))
}
kegg_parse_conv <- function(response, cnames = NULL) {
txt <- httr::content(response, encoding = 'utf-8')
res <- read.table(text = txt)
if(length(cnames) == ncol(res)) {
colnames(res) <- cnames
}
return(res)
}
#kegg_conv('pae', 'ncbi-proteinid') |> head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.