source: webservices/se.lu.thep.webservices/trunk/websFunc.R @ 636

Last change on this file since 636 was 261, checked in by Jari Häkkinen, 16 years ago

Changed samples and code to refer to the demo server.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1######################################################################
2#
3# $Id: websFunc.R 261 2007-04-20 16:36:47Z jari $
4#
5# Copyright (C) Authors contributing to this file.
6#
7# This file is part of BASE - BioArray Software Environment.
8# Available at http://base.thep.lu.se/
9#
10# BASE is free software; you can redistribute it and/or
11# modify it under the terms of the GNU General Public License
12# as published by the Free Software Foundation; either version 2
13# of the License, or (at your option) any later version.
14#
15# BASE is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 59 Temple Place - Suite 330,
23# Boston, MA  02111-1307, USA.
24######################################################################
25
26######################################################################
27#
28# These R function are just simple wrappers of the
29# methods defined in the BaseWebService perl module.
30#
31# One can use the below functions pretty much in the
32# same ways as the perl module object methods.
33#
34# See the webs-test.R for an example of how to use
35# these R functions.
36######################################################################
37
38# Function to login
39login <- function(url, login, passwd)
40{
41  # obj <- .PerlNew("BaseWebService", "baseUrl", "http://localhost:8080/base2")
42  # obj <- .PerlNew("BaseWebService", "baseUrl", "http://base2.thep.lu.se:8080/demo")
43  obj <- .PerlNew("BaseWebService", "baseUrl", url);
44  obj$login(login, passwd);
45  ret <- obj;
46  ret;
47}
48
49# Logout
50logout <- function(obj)
51{
52  obj$logout();
53}
54
55
56getProjects <- function(obj)
57{
58  # Get the projects
59  projs <- obj$getProjects();
60
61  # Store in better list
62  ret = list();
63  for (i in 1:length(projs)) {
64    name <- as.character(projs[[i]]["name"]);
65    desc <- as.character(projs[[i]]["description"]);
66    id   <- as.integer(projs[[i]]["id"]);
67    ret[[i]] <- list(name=name, description=desc, id=id);
68  }
69 
70  ret;
71  # Note that the 'ret' is a list of lists.
72}
73
74
75setActiveProject <- function(obj, id)
76{
77  obj$setActiveProject(as.integer(id));
78}
79
80
81getExperiments <- function(obj)
82{
83  exps <- obj$getExperiments();
84 
85  # Store in better list
86  ret = list();
87  for (i in 1:length(exps)) {
88    name <- as.character(exps[[i]]["name"]);
89    desc <- as.character(exps[[i]]["description"]);
90    id   <- as.integer(exps[[i]]["id"]);
91    ret[[i]] <- list(name=name, description=desc, id=id);
92  }
93
94  ret;
95  # Note that the 'ret' is a list of lists.
96}
97
98
99getRawBioAssays_by_expID <- function(obj, id)
100{
101  files <- obj$getRawBioAssays_by_expID(as.integer(id));
102 
103  # Store in better list
104  ret = list();
105  for (i in 1:length(files)) {
106    cel <- as.character(files[[i]]["celFile"]);
107    cdf <- as.character(files[[i]]["cdfFile"]);
108    ret[[i]] <- list(celFile=cel, cdfFile=cdf);
109  }
110
111  ret;
112  # Note that the 'ret' is a list of lists.
113}
114
115
116downloadRawBioAssays_by_expID <- function(obj, id, path)
117{
118  obj$downloadRawBioAssays_by_expID(as.integer(id), path);
119 
120}
Note: See TracBrowser for help on using the repository browser.