Mercurial > repos > prog > lcmsmatching
comparison NcbiGeneConn.R @ 0:e66bb061af06 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
| author | prog |
|---|---|
| date | Tue, 12 Jul 2016 12:02:37 -0400 |
| parents | |
| children | 253d531a0193 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:e66bb061af06 |
|---|---|
| 1 if ( ! exists('NcbigeneConn')) { # Do not load again if already loaded | |
| 2 | |
| 3 source('BiodbConn.R') | |
| 4 source('NcbigeneCompound.R') | |
| 5 | |
| 6 ##################### | |
| 7 # CLASS DECLARATION # | |
| 8 ##################### | |
| 9 | |
| 10 NcbigeneConn <- setRefClass("NcbigeneConn", contains = "BiodbConn") | |
| 11 | |
| 12 ############### | |
| 13 # CONSTRUCTOR # | |
| 14 ############### | |
| 15 | |
| 16 NcbigeneConn$methods( initialize = function(...) { | |
| 17 # From NCBI E-Utility manual: "In order not to overload the E-utility servers, NCBI recommends that users post no more than three URL requests per second and limit large jobs to either weekends or between 9:00 PM and 5:00 AM Eastern time during weekdays". | |
| 18 callSuper(scheduler = UrlRequestScheduler$new(n = 3), ...) | |
| 19 }) | |
| 20 | |
| 21 ########################## | |
| 22 # GET ENTRY CONTENT TYPE # | |
| 23 ########################## | |
| 24 | |
| 25 NcbigeneConn$methods( getEntryContentType = function(type) { | |
| 26 return(RBIODB.XML) | |
| 27 }) | |
| 28 | |
| 29 ##################### | |
| 30 # GET ENTRY CONTENT # | |
| 31 ##################### | |
| 32 | |
| 33 NcbigeneConn$methods( getEntryContent = function(type, id) { | |
| 34 | |
| 35 if (type == RBIODB.COMPOUND) { | |
| 36 | |
| 37 # Initialize return values | |
| 38 content <- rep(NA_character_, length(id)) | |
| 39 | |
| 40 # Request | |
| 41 content <- vapply(id, function(x) .self$.scheduler$getUrl(get.entry.url(RBIODB.NCBIGENE, x)), FUN.VALUE = '') | |
| 42 | |
| 43 return(content) | |
| 44 } | |
| 45 | |
| 46 return(NULL) | |
| 47 }) | |
| 48 | |
| 49 ################ | |
| 50 # CREATE ENTRY # | |
| 51 ################ | |
| 52 | |
| 53 NcbigeneConn$methods( createEntry = function(type, content, drop = TRUE) { | |
| 54 return(if (type == RBIODB.COMPOUND) createNcbigeneCompoundFromXml(content, drop = drop) else NULL) | |
| 55 }) | |
| 56 } |
