[Bio] / FigKernelPackages / SSserver.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/SSserver.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6, Wed Jun 24 16:24:24 2009 UTC revision 1.15, Mon Nov 30 11:45:22 2009 UTC
# Line 1  Line 1 
   
1  package SSserver;  package SSserver;
2    
3  #  #
4  # This is a SAS Component  # This is a SAS Component
5  #  #
6    
 use LWP::UserAgent;  
 use Data::Dumper;  
 use YAML;  
   
7  use strict;  use strict;
8    use base qw(ClientThing);
9    
10  sub new  =head1 Subsystem Server Helper Object
 {  
     my($class, $server_url) = @_;  
   
     $server_url = "http://servers.nmpdr.org/subsystem/server.cgi" unless $server_url;  
 #    $server_url = "http://bio-macpro-2.mcs.anl.gov/~disz/FIG/subsystem_server_sapling.cgi" unless $server_url;  
 #    $server_url = "http://bio-big.mcs.anl.gov/server/FIG/subsystem_server_sapling.cgi" unless $server_url;  
   
     #$server_url = "http://bio-macpro-1.mcs.anl.gov/ross-proj/FIG/co_occurs_server.cgi" unless $server_url;  
   
     my $self = {  
         server_url => $server_url,  
         ua => LWP::UserAgent->new(),  
     };  
     $self->{ua}->timeout(30*60);  
     return bless $self, $class;  
 }  
11    
12  sub is_in_subsystem {  =head2 Description
         my ($self, @args) = @_;  
         return $self->run_query("is_in_subsystem", @args);  
 }  
 sub is_in_subsystem_with {  
         my ($self, @args) = @_;  
         return $self->run_query("is_in_subsystem_with", @args);  
 }  
13    
14  sub all_subsystems {  This module is used to call the Subsystem Server, which is a special-purpose
15          my ($self, @args) = @_;  server for manipulating subsystem data from the Sapling database. Each Subsystem
16          return $self->run_query("all_subsystems", @args);  Server function corresponds to a method of this object.
 }  
17    
18  sub subsystem_spreadsheet {  This package deliberately uses no internal SEED packages or scripts, only common
19          my ($self, @args) = @_;  PERL modules.
         return $self->run_query("subsystem_spreadsheet", @args);  
 }  
20    
21    The fields in this object are as follows.
22    
23  sub metabolic_reconstruction {  =over 4
         my ($self, @args) = @_;  
         return $self->run_query("metabolic_reconstruction", @args);  
 }  
24    
25  sub run_query  =item server_url
 {  
     my($self, $function, @args ) = @_;  
   
             my $arg_string = Dump(@args);  
             my $form = [function => $function,  
                         args => "$arg_string"];  
   
             my $res = $self->{ua}->post($self->{server_url}, $form);  
             if ($res->is_success)  
             {  
                 return Load($res->content);  
             }  
             else  
             {  
                 die "error on post " . $res->content;  
             }  
 }  
26    
27    The URL used to request data from the subsystem server.
28    
29  1;  =item ua
30    
31    The user agent for communication with the server.
32    
33    =item singleton
34    
35    Indicates whether or not results are to be returned in singleton mode. In
36    singleton mode, if the return document is a hash reference with only one
37    entry, the entry value is returned rather than the hash.
38    
39    =back
40    
41    =cut
42    
43    =head3 new
44    
45        my $ss = SSserver->new(%options);
46    
47    Construct a new server object. The
48    following options are supported.
49    
50    =over 4
51    
52    =item url
53    
54    URL for the server. This option is required.
55    
56    =item singleton (optional)
57    
58    If TRUE, results from methods will be returned in singleton mode. In singleton
59    mode, if a single result comes back, it will come back as a scalar rather than
60    as a hash value accessible via an incoming ID.
61    
62    =back
63    
64    =cut
65    
66    sub new {
67        # Get the parameters.
68        my ($class, %options) = @_;
69        # Compute the URL.
70        $options{url} = 'http://servers.nmpdr.org/subsystem/server.cgi' if ! defined $options{url};
71        # Construct the subclass.
72        return $class->SUPER::new(SS => %options);
73    }
74    
75    1;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3