view MirbaseConn.R @ 4:b34c14151f25 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 494194bb501d1d7033613131865f7bd68976041c
author prog
date Tue, 14 Mar 2017 12:40:22 -0400
parents 20d69a062da3
children
line wrap: on
line source

#####################
# CLASS DECLARATION #
#####################

MirbaseConn <- methods::setRefClass("MirbaseConn", contains = "RemotedbConn")

##########################
# GET ENTRY CONTENT TYPE #
##########################

MirbaseConn$methods( getEntryContentType = function() {
	return(BIODB.HTML)
})

#####################
# GET ENTRY CONTENT #
#####################

MirbaseConn$methods( getEntryContent = function(ids) {

	# Initialize return values
	content <- rep(NA_character_, length(ids))

	# Request
	content <- vapply(ids, function(x) .self$.get.url(get.entry.url(BIODB.MIRBASE, x, content.type = BIODB.HTML)), FUN.VALUE = '')

	return(content)
})

################
# CREATE ENTRY #
################

MirbaseConn$methods( createEntry = function(content, drop = TRUE) {
	return(createMirbaseEntryFromHtml(content, drop = drop))
})

###################
# FIND ACCESSIONS #
###################

MirbaseConn$methods( findAccessions = function(name) {

	# Get HTML
	htmlstr <- .self$.get.url('http://www.mirbase.org/cgi-bin/query.pl', params = c(terms = name, submit = 'Search'))

	# Parse HTML
	xml <-  htmlTreeParse(htmlstr, asText = TRUE, useInternalNodes = TRUE)

	# Get accession number
	acc <- unlist(xpathSApply(xml, "//a[starts-with(.,'MIMAT')]", xmlValue))

	return(acc)
})