[Bio] / FigWebServices / rast_submit_server.cgi Repository:
ViewVC logotype

Diff of /FigWebServices/rast_submit_server.cgi

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

revision 1.1, Mon Oct 19 20:12:40 2009 UTC revision 1.8, Fri Nov 20 17:52:32 2009 UTC
# Line 12  Line 12 
12  use FIG_Config;  use FIG_Config;
13  use RAST_submission;  use RAST_submission;
14    
15    $YAML::CompressSeries = 0;
16    
17  #  #
18  # This is the list of supported methods.  # This is the list of supported methods.
19  #  #
20    
21  my @methods = qw(submit_RAST_job status_of_RAST_job);  my @methods = qw(
22                     get_contig_ids_in_project_from_entrez
23                     get_contigs_from_entrez
24                     submit_RAST_job
25                     status_of_RAST_job
26                     kill_RAST_job
27                     delete_RAST_job
28                     get_job_metadata
29                    );
30    
31  my %methods = map { $_ => 1 } @methods;  my %methods = map { $_ => 1 } @methods;
32    
33  use YAML;  use YAML;
34    
 my $ffdir = $FIG_Config::FigfamsData;  
   
35  $| = 1;  $| = 1;
36    
37  my $header = "Content-type: text/plain\n\n";  my $header = "Content-type: text/plain\n\n";
# Line 38  Line 47 
47      while ((my $cgi = new CGI::Fast()) &&      while ((my $cgi = new CGI::Fast()) &&
48             ($max_requests == 0 || $n_requests++ < $max_requests))             ($max_requests == 0 || $n_requests++ < $max_requests))
49      {      {
50            &log("fcgi request received");
51          eval {          eval {
52              &process_request($cgi);              &process_request($cgi);
53          };          };
54          if ($@)          my $had_error = $@;
55            &log("fcgi request completed $had_error");
56            if ($had_error)
57          {          {
58              if (ref($@) ne 'ARRAY')              if (ref($had_error) ne 'ARRAY')
59              {              {
60                  warn "code died, cgi=$cgi returning error\n";                  warn "code died, cgi=$cgi returning error\n";
61                  print $cgi->header(-status => '500 error in body of cgi processing');                  print $cgi->header(-status => '500 error in body of cgi processing');
# Line 56  Line 68 
68  else  else
69  {  {
70      my $cgi = new CGI();      my $cgi = new CGI();
71        &log("request received");
72      &process_request($cgi);      &process_request($cgi);
73        &log("request completed");
74  }  }
75    
76  exit;  exit;
77    
78    sub log
79    {
80        my($msg) = @_;
81        print STDERR strftime("%D %T: $msg\n", localtime);
82    }
83    
84    
85  sub process_request  sub process_request
86  {  {
87      my($cgi) = @_;      my($cgi) = @_;
88    
89      my $function = $cgi->param('function');      my $function = $cgi->param('function');
90  #    print STDERR "got function=$function\n";  #    print STDERR "got function=$function\n";
91        &log("handle $function");
92    
93      my $arg_str = $cgi->param('args');      my $arg_str = $cgi->param('args');
94      my @args;      my @args;
# Line 133  Line 155 
155    
156      my $rast_obj = new RAST_submission($rast_dbmaster, $dbmaster, $user_obj);      my $rast_obj = new RAST_submission($rast_dbmaster, $dbmaster, $user_obj);
157    
158      if ($methods{$function})  
159        #
160        # We handle retrieve in a different manner.
161        #
162        if ($function eq 'retrieve_RAST_job')
163        {
164            my $res;
165            eval {
166                $res = $rast_obj->retrieve_RAST_job(@args);
167            };
168    
169            if ($@)
170            {
171                myerror($cgi, '500 error in method invocation', $@);
172            }
173    
174            if ($res->{status} ne 'ok')
175            {
176                myerror($cgi, "501 retrieve failed: $res->{error_msg}");
177            }
178    
179            if (!open(F, "<", $res->{file}))
180            {
181                myerror($cgi, "501 could not open output file");
182            }
183    
184            print $cgi->header();
185    
186            my $buf;
187    
188            while (read(F, $buf, 4096))
189            {
190                print $buf;
191            }
192            close(F);
193        }
194        elsif ($methods{$function})
195      {      {
196    
197          my @results;          my @results;
# Line 147  Line 205 
205          }          }
206    
207          print $cgi->header();          print $cgi->header();
208          print YAML::Dump(@results);          my $res =  YAML::Dump(@results);
209            #print STDERR $res;
210            print $res;
211    
212      } else {      } else {
213          myerror($cgi,  "500 invalid function", "invalid function $function\n");          myerror($cgi,  "500 invalid function", "invalid function $function\n");
# Line 172  Line 232 
232    
233  }  }
234    
 #  
 #The FIGfam server processes requests of the form:  
 #  
 #    1. PLACE-IN-FAMILY takes as input a list of protein sequences.  It  
 #       returns a list where each element describes the outcome of  
 #       trying to place the corresponding input sequence into a  
 #       FIGfam.  Each output can be either  
 #  
 #                COULD-NOT-PLACE-IN-FAMILY  
 #       or  
 #                ID FUNCTION  
 #  
 #       where ID is of the form FIGxxxxxx and FUNCTION is the family  
 #       function.  
 #  
 #    2. MEMBERS-OF-FAMILIES takes as input a list of FIGfam IDs.  The  
 #       output is a list of functions for those families  
 #       (INVALID-FAMILY will be returned for IDs that do not correspond  
 #       to an active family), as well as a list of the IDs in each family.  
 #  
 #    3. SHOULD-BE-MEMBER takes as input a list of 2-tuples  
 #  
 #             [FIGfam-ID,protein sequence]  
 #  
 #       It returns a list of boolean values indicating whether or not  
 #       the indicated protein sequence can be placed in the designated  
 #       family.  
 #  
 #    4. ALL-FAMILIES returns a list of [FIGfam-ID,function] tuples.  
 #  
 #  
 #    5. ASSIGN-FUNCTION-TO-PROT is similar to PLACE-IN-FAMILY, except  
 #       that the returned list contains either  
 #  
 #                COULD-NOT-PLACE-IN-FAMILY  
 #       or  
 #                ID FUNCTION  
 #  
 #       That is, it does not indicate which FIGfam was used to  
 #       determine the function.  This allows higher-performance  
 #       alternatives for cases in which multiple FIGfams implement the  
 #       same function.  The algorithm supported utilizes the underlying  
 #       FIGfams, but characterizes sets that implement the same  
 #       function and does not support distinguishing which FIGfam  
 #       is actually the right subgrouping.  
 #  
 #       6. ASSIGN-FUNCTIONS-TO-DNA takes as input a list of DNA  
 #       sequences.  It returns a list where each element describes  
 #       a region of DNA that is believed to be part of a gene encoding  
 #       a protein sequence that would be placed into a FIGfam  
 #       successfully, if the whole protein sequence could be  
 #       determined.  That is, the returned list will contain entrties  
 #       of either the form  
 #  
 #                COULD-NOT-PLACE-ANY-REGIONS-IN-FAMILIES  
 #       or  
 #                BEGIN1 END1 FUNCTION1 BEGIN2 END2 FUNCTION2 ...  
 #  
 #       where BEGIN and END specify a region (if BEGIN is greater than  
 #       END, the region described is on the reverse strand) and  
 #       FUNCTION is the family function of the protein sequence that is  
 #       believed to be encoded by DNA including the embedded region.  
 #       Each input sequence can produce an arbitrary number of matched  
 #       regions, there will be 3 fields for each matched region.  Note  
 #       that the described region may include frameshifts and embedded  
 #       stop codons.  The algorithm seeking meaningful sections of DNA  
 #       assumes that it may have an incomplete, low-quality sequence  
 #       (and uses an algorithm that attempts to locate meaningful  
 #       matches even so).  
235    
236  sub myerror  sub myerror
237  {  {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3