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