comparison LipidmapsConn.R @ 0:3afe41d3e9e7 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit bb4d3e23d99828bfee16d31d794c49a17313ec2f
author prog
date Mon, 11 Jul 2016 09:12:03 -0400
parents
children 45e985cd8e9e
comparison
equal deleted inserted replaced
-1:000000000000 0:3afe41d3e9e7
1 if ( ! exists('LipdmapsConn')) { # Do not load again if already loaded
2
3 source('BiodbConn.R')
4 source('LipidmapsCompound.R')
5
6 #####################
7 # CLASS DECLARATION #
8 #####################
9
10 LipidmapsConn <- setRefClass("LipidmapsConn", contains = "BiodbConn")
11
12 ###############
13 # CONSTRUCTOR #
14 ###############
15
16 LipidmapsConn$methods( initialize = function(...) {
17 # From http://www.lipidmaps.org/data/structure/programmaticaccess.html:
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.
19 callSuper(scheduler = UrlRequestScheduler$new(t = 20), ...)
20 })
21
22 ##########################
23 # GET ENTRY CONTENT TYPE #
24 ##########################
25
26 LipidmapsConn$methods( getEntryContentType = function(type) {
27 return(RBIODB.CSV)
28 })
29
30 #####################
31 # GET ENTRY CONTENT #
32 #####################
33
34 LipidmapsConn$methods( getEntryContent = function(type, id) {
35
36 if (type == RBIODB.COMPOUND) {
37
38 # Initialize return values
39 content <- rep(NA_character_, length(id))
40
41 # Request
42 content <- vapply(id, function(x) .self$.scheduler$getUrl(get.entry.url(RBIODB.LIPIDMAPS, x, content.type = RBIODB.CSV)), FUN.VALUE = '')
43
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 }