comparison ChebiConn.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('ChebiConn')) { # Do not load again if already loaded 1 #####################
2 # CLASS DECLARATION #
3 #####################
2 4
3 source('BiodbConn.R') 5 ChebiConn <- methods::setRefClass("ChebiConn", contains = "RemotedbConn")
4 source('ChebiCompound.R')
5
6 #####################
7 # CLASS DECLARATION #
8 #####################
9
10 ChebiConn <- setRefClass("ChebiConn", contains = "BiodbConn")
11 6
12 ########################## 7 ##########################
13 # GET ENTRY CONTENT TYPE # 8 # GET ENTRY CONTENT TYPE #
14 ########################## 9 ##########################
15 10
16 ChebiConn$methods( getEntryContentType = function(type) { 11 ChebiConn$methods( getEntryContentType = function() {
17 return(RBIODB.HTML) 12 return(BIODB.HTML)
18 }) 13 })
19 14
20 ##################### 15 #####################
21 # GET ENTRY CONTENT # 16 # GET ENTRY CONTENT #
22 ##################### 17 #####################
23
24 ChebiConn$methods( getEntryContent = function(type, id) {
25 18
26 if (type == RBIODB.COMPOUND) { 19 ChebiConn$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(RBIODB.CHEBI, x)), FUN.VALUE = '') 25 content <- vapply(id, function(x) .self$.get.url(get.entry.url(BIODB.CHEBI, x)), 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 ################
41 # CREATE ENTRY #
42 ################
43
44 ChebiConn$methods( createEntry = function(type, content, drop = TRUE) {
45 return(if (type == RBIODB.COMPOUND) createChebiCompoundFromHtml(content, drop = drop) else NULL)
46 })
47 33
48 } # end of load safe guard 34 ChebiConn$methods( createEntry = function(content, drop = TRUE) {
35 return(createChebiEntryFromHtml(content, drop = drop))
36 })
37
38 ##################
39 # GET NB ENTRIES #
40 ##################
41
42 ChebiConn$methods( getNbEntries = function() {
43 return(NA_integer_)
44 })
45
46 #################
47 # GET ENTRY IDS #
48 #################
49
50 ChebiConn$methods( getEntryIds = function(max.results = NA_integer_) {
51 request <- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://www.ebi.ac.uk/webservices/chebi\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ><SOAP-ENV:Body><tns:getLiteEntity xmlns:tns=\"http://www.ebi.ac.uk/webservices/chebi\"><tns:search>1*</tns:search><tns:searchCategory>CHEBI ID</tns:searchCategory><tns:maximumResults>100</tns:maximumResults><tns:stars></tns:stars></tns:getLiteEntity></SOAP-ENV:Body></SOAP-ENV:Envelope>"
52 print('********************************************************************************')
53 print('********************************************************************************')
54 results <- .self$.scheduler$sendSoapRequest('http://www.ebi.ac.uk:80/webservices/chebi/2.0/webservice', request)
55 print(results)
56 print('********************************************************************************')
57 print('********************************************************************************')
58 return(NULL)
59 })