Mercurial > repos > prog > lcmsmatching
comparison HmdbConn.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 |
comparison
equal
deleted
inserted
replaced
1:253d531a0193 | 2:20d69a062da3 |
---|---|
1 if ( ! exists('HmdbConn')) { # Do not load again if already loaded | 1 ##################### |
2 # CLASS DECLARATION # | |
3 ##################### | |
2 | 4 |
3 source('RemotedbConn.R') | 5 HmdbConn <- methods::setRefClass("HmdbConn", contains = "RemotedbConn") |
4 source('HmdbCompound.R') | |
5 | |
6 ##################### | |
7 # CLASS DECLARATION # | |
8 ##################### | |
9 | |
10 HmdbConn <- setRefClass("HmdbConn", contains = "RemotedbConn") | |
11 | 6 |
12 ########################## | 7 ########################## |
13 # GET ENTRY CONTENT TYPE # | 8 # GET ENTRY CONTENT TYPE # |
14 ########################## | 9 ########################## |
15 | 10 |
16 HmdbConn$methods( getEntryContentType = function(type) { | 11 HmdbConn$methods( getEntryContentType = function() { |
17 return(BIODB.XML) | 12 return(BIODB.XML) |
18 }) | 13 }) |
19 | 14 |
20 ##################### | 15 ##################### |
21 # GET ENTRY CONTENT # | 16 # GET ENTRY CONTENT # |
22 ##################### | 17 ##################### |
23 | |
24 HmdbConn$methods( getEntryContent = function(type, id) { | |
25 | 18 |
26 if (type == BIODB.COMPOUND) { | 19 HmdbConn$methods( getEntryContent = function(id) { |
27 | 20 |
28 # Initialize return values | 21 # Initialize return values |
29 content <- rep(NA_character_, length(id)) | 22 content <- rep(NA_character_, length(id)) |
30 | 23 |
31 # Request | 24 # Request |
32 content <- vapply(id, function(x) .self$.scheduler$getUrl(get.entry.url(BIODB.HMDB, x, content.type = BIODB.XML)), FUN.VALUE = '') | 25 content <- vapply(id, function(x) .self$.get.url(get.entry.url(BIODB.HMDB, x, content.type = BIODB.XML)), FUN.VALUE = '') |
33 | 26 |
34 return(content) | 27 return(content) |
35 } | 28 }) |
36 | 29 |
37 return(NULL) | 30 ################ |
38 }) | 31 # CREATE ENTRY # |
39 | 32 ################ |
40 ################ | 33 |
41 # CREATE ENTRY # | 34 HmdbConn$methods( createEntry = function(content, drop = TRUE) { |
42 ################ | 35 return(createHmdbEntryFromXml(content, drop = drop)) |
43 | 36 }) |
44 HmdbConn$methods( createEntry = function(type, content, drop = TRUE) { | |
45 return(if (type == BIODB.COMPOUND) createHmdbCompoundFromXml(content, drop = drop) else NULL) | |
46 }) | |
47 | |
48 } # end of load safe guard |