comparison LipidmapsConn.R @ 1:45e985cd8e9e draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8-dirty
author prog
date Tue, 31 Jan 2017 05:27:24 -0500
parents 3afe41d3e9e7
children
comparison
equal deleted inserted replaced
0:3afe41d3e9e7 1:45e985cd8e9e
1 if ( ! exists('LipdmapsConn')) { # Do not load again if already loaded 1 #####################
2 # CLASS DECLARATION #
3 #####################
2 4
3 source('BiodbConn.R') 5 LipidmapsConn <- methods::setRefClass("LipidmapsConn", contains = "RemotedbConn")
4 source('LipidmapsCompound.R')
5 6
6 ##################### 7 ###############
7 # CLASS DECLARATION # 8 # CONSTRUCTOR #
8 ##################### 9 ###############
9 10
10 LipidmapsConn <- setRefClass("LipidmapsConn", contains = "BiodbConn") 11 LipidmapsConn$methods( initialize = function(...) {
12 # From http://www.lipidmaps.org/data/structure/programmaticaccess.html:
13 # If you write a script to automate calls to LMSD, please be kind and do not hit our server more often than once per 20 seconds. We may have to kill scripts that hit our server more frequently.
14 callSuper(scheduler = UrlRequestScheduler$new(t = 20), ...)
15 })
11 16
12 ############### 17 ##########################
13 # CONSTRUCTOR # 18 # GET ENTRY CONTENT TYPE #
14 ############### 19 ##########################
15 20
16 LipidmapsConn$methods( initialize = function(...) { 21 LipidmapsConn$methods( getEntryContentType = function() {
17 # From http://www.lipidmaps.org/data/structure/programmaticaccess.html: 22 return(BIODB.CSV)
18 # If you write a script to automate calls to LMSD, please be kind and do not hit our server more often than once per 20 seconds. We may have to kill scripts that hit our server more frequently. 23 })
19 callSuper(scheduler = UrlRequestScheduler$new(t = 20), ...)
20 })
21 24
22 ########################## 25 #####################
23 # GET ENTRY CONTENT TYPE # 26 # GET ENTRY CONTENT #
24 ########################## 27 #####################
25 28
26 LipidmapsConn$methods( getEntryContentType = function(type) { 29 LipidmapsConn$methods( getEntryContent = function(id) {
27 return(RBIODB.CSV)
28 })
29 30
30 ##################### 31 # Initialize return values
31 # GET ENTRY CONTENT # 32 content <- rep(NA_character_, length(id))
32 #####################
33 33
34 LipidmapsConn$methods( getEntryContent = function(type, id) { 34 # Request
35 content <- vapply(id, function(x) .self$.get.url(get.entry.url(BIODB.LIPIDMAPS, x, content.type = BIODB.CSV)), FUN.VALUE = '')
35 36
36 if (type == RBIODB.COMPOUND) { 37 return(content)
38 })
37 39
38 # Initialize return values 40 ################
39 content <- rep(NA_character_, length(id)) 41 # CREATE ENTRY #
42 ################
40 43
41 # Request 44 LipidmapsConn$methods( createEntry = function(content, drop = TRUE) {
42 content <- vapply(id, function(x) .self$.scheduler$getUrl(get.entry.url(RBIODB.LIPIDMAPS, x, content.type = RBIODB.CSV)), FUN.VALUE = '') 45 return(createLipidmapsEntryFromCsv(content, drop = drop))
43 46 })
44 return(content)
45 }
46
47 return(NULL)
48 })
49
50 ################
51 # CREATE ENTRY #
52 ################
53
54 LipidmapsConn$methods( createEntry = function(type, content, drop = TRUE) {
55 return(if (type == RBIODB.COMPOUND) createLipidmapsCompoundFromCsv(content, drop = drop) else NULL)
56 })
57 }