diff MirbaseConn.R @ 2:20d69a062da3 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
author prog
date Thu, 02 Mar 2017 08:55:00 -0500
parents 253d531a0193
children
line wrap: on
line diff
--- a/MirbaseConn.R	Sat Sep 03 17:02:01 2016 -0400
+++ b/MirbaseConn.R	Thu Mar 02 08:55:00 2017 -0500
@@ -1,66 +1,54 @@
-if ( ! exists('MirbaseConn')) { # Do not load again if already loaded
-
-	source('RemotedbConn.R')
-	source('MirbaseCompound.R')
+#####################
+# CLASS DECLARATION #
+#####################
 
-	#####################
-	# CLASS DECLARATION #
-	#####################
+MirbaseConn <- methods::setRefClass("MirbaseConn", contains = "RemotedbConn")
 
-	MirbaseConn <- setRefClass("MirbaseConn", contains = "RemotedbConn")
-
-	##########################
-	# GET ENTRY CONTENT TYPE #
-	##########################
+##########################
+# GET ENTRY CONTENT TYPE #
+##########################
 
-	MirbaseConn$methods( getEntryContentType = function(type) {
-		return(BIODB.HTML)
-	})
+MirbaseConn$methods( getEntryContentType = function() {
+	return(BIODB.HTML)
+})
+
+#####################
+# GET ENTRY CONTENT #
+#####################
 
-	#####################
-	# GET ENTRY CONTENT #
-	#####################
-	
-	MirbaseConn$methods( getEntryContent = function(type, id) {
+MirbaseConn$methods( getEntryContent = function(ids) {
 
-		if (type == BIODB.COMPOUND) {
+	# Initialize return values
+	content <- rep(NA_character_, length(ids))
 
-			# Initialize return values
-			content <- rep(NA_character_, length(id))
-
-			# Request
-			content <- vapply(id, function(x) .self$.scheduler$getUrl(get.entry.url(BIODB.MIRBASE, x, content.type = BIODB.HTML)), FUN.VALUE = '')
+	# Request
+	content <- vapply(ids, function(x) .self$.get.url(get.entry.url(BIODB.MIRBASE, x, content.type = BIODB.HTML)), FUN.VALUE = '')
 
-			return(content)
-		}
-
-		return(NULL)
-	})
+	return(content)
+})
 
-	################
-	# CREATE ENTRY #
-	################
-	
-	MirbaseConn$methods( createEntry = function(type, content, drop = TRUE) {
-		return(if (type == BIODB.COMPOUND) createMirbaseCompoundFromHtml(content, drop = drop) else NULL)
-	})
+################
+# CREATE ENTRY #
+################
+
+MirbaseConn$methods( createEntry = function(content, drop = TRUE) {
+	return(createMirbaseEntryFromHtml(content, drop = drop))
+})
 
-	###################
-	# FIND ACCESSIONS #
-	###################
+###################
+# FIND ACCESSIONS #
+###################
 
-	MirbaseConn$methods(
-		findAccessions = function(name) {
+MirbaseConn$methods( findAccessions = function(name) {
 
-			# Get HTML
-			htmlstr <- .self$.scheduler$getUrl('http://www.mirbase.org/cgi-bin/query.pl', params = c(terms = name, submit = 'Search'))
+	# 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)
+	# Parse HTML
+	xml <-  htmlTreeParse(htmlstr, asText = TRUE, useInternalNodes = TRUE)
 
-			# Get accession number
-			acc <- unlist(xpathSApply(xml, "//a[starts-with(.,'MIMAT')]", xmlValue))
+	# Get accession number
+	acc <- unlist(xpathSApply(xml, "//a[starts-with(.,'MIMAT')]", xmlValue))
 
-			return(acc)
-	})
-}
+	return(acc)
+})