257 |
20 Apr 07 |
mattias |
#! /usr/bin/perl -w |
257 |
20 Apr 07 |
mattias |
2 |
|
258 |
20 Apr 07 |
jari |
# $Id$ |
258 |
20 Apr 07 |
jari |
4 |
|
257 |
20 Apr 07 |
mattias |
5 |
use BaseWebService; |
257 |
20 Apr 07 |
mattias |
6 |
use strict; |
257 |
20 Apr 07 |
mattias |
7 |
use Data::Dumper; |
257 |
20 Apr 07 |
mattias |
8 |
|
257 |
20 Apr 07 |
mattias |
9 |
############################################################# |
257 |
20 Apr 07 |
mattias |
10 |
# |
257 |
20 Apr 07 |
mattias |
# This is small script to test the BaseWebService.pm module |
257 |
20 Apr 07 |
mattias |
12 |
# |
257 |
20 Apr 07 |
mattias |
13 |
############################################################# |
257 |
20 Apr 07 |
mattias |
14 |
|
257 |
20 Apr 07 |
mattias |
# Create the BaseWebService object |
415 |
03 Sep 07 |
jari |
16 |
my $obj = BaseWebService->new(baseUrl => 'http://base2.thep.lu.se/demo'); |
257 |
20 Apr 07 |
mattias |
17 |
my $sessionID = $obj->sessionID(); |
257 |
20 Apr 07 |
mattias |
18 |
print "Session ID = $sessionID \n"; |
257 |
20 Apr 07 |
mattias |
19 |
|
257 |
20 Apr 07 |
mattias |
# Login, change to fit your account |
258 |
20 Apr 07 |
jari |
#$obj->login('userid', 'password'); |
258 |
20 Apr 07 |
jari |
22 |
$obj->login('base2', 'base2'); |
257 |
20 Apr 07 |
mattias |
23 |
|
257 |
20 Apr 07 |
mattias |
# Get all the projects |
257 |
20 Apr 07 |
mattias |
25 |
my $projs = $obj->getProjects(); |
257 |
20 Apr 07 |
mattias |
26 |
print "List of Projects:\n"; |
257 |
20 Apr 07 |
mattias |
27 |
foreach my $proj (@{$projs}) { |
257 |
20 Apr 07 |
mattias |
28 |
print "Id : ", $proj->{id}, "\n"; |
257 |
20 Apr 07 |
mattias |
29 |
print "Name : ", $proj->{name}, "\n"; |
257 |
20 Apr 07 |
mattias |
30 |
print "Description: ", |
257 |
20 Apr 07 |
mattias |
31 |
($proj->{description} ? '' : defined($proj->{description})), "\n\n"; |
257 |
20 Apr 07 |
mattias |
32 |
} |
257 |
20 Apr 07 |
mattias |
# Make an array of all project ID's |
257 |
20 Apr 07 |
mattias |
34 |
my @projID = map { $_->{id} } @{$projs}; |
257 |
20 Apr 07 |
mattias |
35 |
|
257 |
20 Apr 07 |
mattias |
36 |
|
257 |
20 Apr 07 |
mattias |
# Set active project. This is an important step, since |
257 |
20 Apr 07 |
mattias |
# you have to have your project in an active state. |
257 |
20 Apr 07 |
mattias |
# Here I simply select the first project ID. |
257 |
20 Apr 07 |
mattias |
40 |
$obj->setActiveProject($projID[0]); |
257 |
20 Apr 07 |
mattias |
41 |
|
257 |
20 Apr 07 |
mattias |
# Get a listing of all experiments (At the moment you get a list of all |
257 |
20 Apr 07 |
mattias |
# experiments, unfortunately not only for the active project. |
257 |
20 Apr 07 |
mattias |
44 |
my $exps = $obj->getExperiments(); |
257 |
20 Apr 07 |
mattias |
45 |
|
257 |
20 Apr 07 |
mattias |
46 |
print "List of Experiments:\n"; |
257 |
20 Apr 07 |
mattias |
47 |
foreach my $exp (@{$exps}) { |
257 |
20 Apr 07 |
mattias |
48 |
print "Id : ", $exp->{id}, "\n"; |
257 |
20 Apr 07 |
mattias |
49 |
print "Name : ", $exp->{name}, "\n"; |
257 |
20 Apr 07 |
mattias |
50 |
print "Description: ", |
257 |
20 Apr 07 |
mattias |
51 |
($exp->{description} ? '' : defined($exp->{description})), "\n\n"; |
257 |
20 Apr 07 |
mattias |
52 |
} |
257 |
20 Apr 07 |
mattias |
53 |
|
257 |
20 Apr 07 |
mattias |
# Make an array of all experiment ID's |
257 |
20 Apr 07 |
mattias |
55 |
my @expID = map { $_->{id} } @{$exps}; |
257 |
20 Apr 07 |
mattias |
56 |
|
257 |
20 Apr 07 |
mattias |
# Call the getRawBioAssays for the first one (if you have any) |
257 |
20 Apr 07 |
mattias |
58 |
if( @expID ) { |
257 |
20 Apr 07 |
mattias |
59 |
my $useExpID = $expID[0]; |
257 |
20 Apr 07 |
mattias |
60 |
print "Raw bioassays for experiment with ID = $useExpID\n"; |
257 |
20 Apr 07 |
mattias |
61 |
my $files = $obj->getRawBioAssays_by_expID($useExpID); |
257 |
20 Apr 07 |
mattias |
62 |
foreach my $file (@$files) { |
257 |
20 Apr 07 |
mattias |
63 |
print "celfile: $file->{celFile} (design = $file->{cdfFile})\n"; |
257 |
20 Apr 07 |
mattias |
64 |
} |
257 |
20 Apr 07 |
mattias |
65 |
|
257 |
20 Apr 07 |
mattias |
# Download all files to the local directory. Uncomment to apply! |
257 |
20 Apr 07 |
mattias |
#$obj->downloadRawBioAssays($files, './'); |
257 |
20 Apr 07 |
mattias |
68 |
} |
257 |
20 Apr 07 |
mattias |
69 |
|
257 |
20 Apr 07 |
mattias |
# Here you can download all files at once given an experiment ID |
257 |
20 Apr 07 |
mattias |
#if( @expID ) { |
257 |
20 Apr 07 |
mattias |
# $obj->downloadRawBioAssays_by_expID($expID[0], './tmp'); |
257 |
20 Apr 07 |
mattias |
73 |
#} |
257 |
20 Apr 07 |
mattias |
74 |
|
257 |
20 Apr 07 |
mattias |
# Logout |
257 |
20 Apr 07 |
mattias |
76 |
$obj->logout(); |