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

Diff of /FigKernelPackages/FFserver.pm

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

revision 1.2, Thu Apr 30 20:33:41 2009 UTC revision 1.5, Mon May 11 20:55:05 2009 UTC
# Line 2  Line 2 
2  package FFserver;  package FFserver;
3    
4  use LWP::UserAgent;  use LWP::UserAgent;
 use FIG_Config;  
5  use Data::Dumper;  use Data::Dumper;
6    use YAML;
7    
8  use strict;  use strict;
9    
# Line 11  Line 11 
11  {  {
12      my($class, $server_url) = @_;      my($class, $server_url) = @_;
13    
14      $server_url = $FIG_Config::FFserver_url unless $server_url;      $server_url = "http://servers.nmpdr.org/figfam/server.cgi" unless $server_url;
     $server_url = "http://bio-macpro-1.mcs.anl.gov/~disz/FIG/figfam_server.cgi" unless $server_url;  
15    
16    
17      my $self = {      my $self = {
# Line 23  Line 22 
22      return bless $self, $class;      return bless $self, $class;
23  }  }
24    
25    sub members_of_families
26    {
27        my($self, @ids) = @_;
28        return $self->run_query('members_of_families', @ids);
29    }
30    
31    sub should_be_member
32    {
33        my($self, @id_seq_pairs) = @_;
34        return $self->run_query('should_be_member', @id_seq_pairs);
35    }
36    
37    sub all_families
38    {
39        my($self) = @_;
40        return $self->run_query('all_families');
41    }
42    
43    sub run_query
44    {
45        my($self, $function, @args ) = @_;
46        my $form = [function  => $function,
47                    args => YAML::Dump(@args),
48                    ];
49        return $self->run_query_form($form);
50    }
51    
52    sub run_query_form
53    {
54        my($self, $form) = @_;
55    
56        my $res = $self->{ua}->post($self->{server_url}, $form);
57    
58        if ($res->is_success)
59        {
60            return Load($res->content);
61        }
62        else
63        {
64            die "error on post " . $res->content;
65        }
66    }
67    
68  sub assign_function_to_prot  sub assign_function_to_prot
69  {  {
70      my($self, $input) = @_;      my($self, $input) = @_;
# Line 43  Line 85 
85    
86  sub assign_functions_to_dna  sub assign_functions_to_dna
87  {  {
88      my($self, $input) = @_;      my($self, $input, $min_hits, $max_gap) = @_;
89    
90      my $wq;      my $wq;
91    
# Line 56  Line 98 
98          $wq = FastaWorkQueue->new($input);          $wq = FastaWorkQueue->new($input);
99      }      }
100    
101      return ResultHandler->new($wq, $self->{server_url}, 'assign_function_to_DNA', \&id_seq_pair_bundler, \&tab_delimited_dna_data_output_parser);      return ResultHandler->new($wq, $self->{server_url}, 'assign_functions_to_DNA', \&id_seq_pair_bundler, \&tab_delimited_output_parser, [min_hits => $min_hits, max_gap => $max_gap]);
102  }  }
103    
104  sub id_seq_pair_bundler  sub id_seq_pair_bundler
# Line 90  Line 132 
132    
133  sub new  sub new
134  {  {
135      my($class, $work_queue, $server_url, $function, $input_bundler, $output_parser) = @_;      my($class, $work_queue, $server_url, $function, $input_bundler, $output_parser, $form_vars) = @_;
136    
137      my $self = {      my $self = {
138          work_queue => $work_queue,          work_queue => $work_queue,
# Line 100  Line 142 
142          output_parser => $output_parser,          output_parser => $output_parser,
143          ua => LWP::UserAgent->new(),          ua => LWP::UserAgent->new(),
144          cur_result => undef,          cur_result => undef,
145            form_vars => $form_vars ? $form_vars : [],
146      };      };
147      return bless $self, $class;      return bless $self, $class;
148  }  }
# Line 117  Line 160 
160          my @inp = $self->{work_queue}->get_next_n_bytes(16000);          my @inp = $self->{work_queue}->get_next_n_bytes(16000);
161          if (@inp)          if (@inp)
162          {          {
163              my $form = [function => $self->{function},              my $form = [@{$self->{form_vars}}];
164                          map { &{$self->{input_bundler}}($_) } @inp ];              push(@$form, function => $self->{function},
165              # print "Invoke " .Dumper($form);                           map { &{$self->{input_bundler}}($_) } @inp);
166                print "Invoke " .Dumper($form);
167    
168              my $res = $self->{ua}->post($self->{server_url}, $form);              my $res = $self->{ua}->post($self->{server_url}, $form);
169              if ($res->is_success)              if ($res->is_success)
# Line 130  Line 174 
174              }              }
175              else              else
176              {              {
177                  die "error on post " . $res->content;                  die "error " . $res->status_line . " on post " . $res->content;
178              }              }
179          }          }
180          else          else

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3