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

Diff of /FigWebServices/co_occurs_server.cgi

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

revision 1.3, Mon May 11 19:50:26 2009 UTC revision 1.4, Mon May 11 20:36:16 2009 UTC
# Line 1  Line 1 
1  use strict;  use strict;
2  use Data::Dumper;  use Data::Dumper;
3    use CGI::Fast;
4    use CGI;
5    use ERDB;
6    use FC;
7    
 use YAML;  
8    
9  use CGI;  use YAML;
 my $cgi = new CGI;  
10    
11  use FIG;  use FIG;
12    
13  my $fig = new FIG;  my $fig = new FIG;
14    
15  use ERDB;  my $db = ERDB::GetDatabase('Sapling');
 use FC;  
16    
17    #
18    # If no CGI vars, assume we are invoked as a fastcgi service.
19    #
20    if ($ENV{REQUEST_METHOD} eq '')
21    {
22        while (my $cgi = new CGI::Fast())
23        {
24            eval {
25                &process($cgi);
26            };
27            if ($@)
28            {
29                if (ref($@) ne 'ARRAY')
30                {
31                    warn "code died, returning error\n";
32                    print $cgi->header(-status => '500 error in body of cgi processing');
33                    print $@;
34                }
35            }
36        }
37    }
38    else
39    {
40        my $cgi = new CGI();
41  print $cgi->header();  print $cgi->header();
42  my $function = $cgi->param('function');      &process($cgi);
43  $function || die "Missing a function in call to co_occurs_server.cgi";  }
44    
45  my $db = ERDB::GetDatabase('Sapling');  exit;
46    
47    sub myerror
48    {
49        my($cgi, $stat, $msg) = @_;
50        print $cgi->header(-status =>  $stat);
51        print "$msg\n";
52        die ['cgi error returned'];
53    }
54    
55    sub process
56    {
57        my($cgi) = @_;
58    
59        my $function = $cgi->param('function');
60        $function || myerror($cgi, "500 missing function", "Missing a function in call to co_occurs_server.cgi");
61    
62  if ($function eq "conserved_in_neighborhood")  if ($function eq "conserved_in_neighborhood")
63  {  {
# Line 31  Line 72 
72              my($sc,$fid,$pairset) = @$tuple;              my($sc,$fid,$pairset) = @$tuple;
73              push(@$group,[$sc,$fid,scalar $fig->function_of($fid),$pairset]);              push(@$group,[$sc,$fid,scalar $fig->function_of($fid),$pairset]);
74          }          }
   
75          push(@$tuples,$group);          push(@$tuples,$group);
76      }      }
77    
78            print $cgi->header();
79      my $str = &YAML::Dump($tuples);      my $str = &YAML::Dump($tuples);
80      print $str;      print $str;
81  }  }
# Line 45  Line 87 
87      {      {
88          push(@$ans,[$pairset,[&FC::co_occurrence_set($db,$pairset)]]);          push(@$ans,[$pairset,[&FC::co_occurrence_set($db,$pairset)]]);
89      }      }
90            print $cgi->header();
91      print &YAML::Dump($ans);      print &YAML::Dump($ans);
92  }  }
93  elsif ($function eq "clusters_containing")  elsif ($function eq "clusters_containing")
# Line 60  Line 103 
103              push(@$ans,[$peg,$func,[map { [$_,scalar $fig->function_of($_)] } @$cluster]]);              push(@$ans,[$peg,$func,[map { [$_,scalar $fig->function_of($_)] } @$cluster]]);
104          }          }
105      }      }
106            print $cgi->header();
107      print &YAML::Dump($ans);      print &YAML::Dump($ans);
108  }  }
109  elsif ($function eq "related_clusters")  elsif ($function eq "related_clusters")
# Line 79  Line 123 
123          }          }
124          push(@$ans,$one_set);          push(@$ans,$one_set);
125      }      }
126            print $cgi->header();
127      print &YAML::Dump($ans);      print &YAML::Dump($ans);
128  }  }
129  elsif ($function eq "related_figfams")  elsif ($function eq "related_figfams")
# Line 89  Line 134 
134      {      {
135          push(@$ans,[$ff,[&FC::co_occurring_FIGfams($db,$ff)]]);          push(@$ans,[$ff,[&FC::co_occurring_FIGfams($db,$ff)]]);
136      }      }
137            print $cgi->header();
138      print &YAML::Dump($ans);      print &YAML::Dump($ans);
139  }  }
140    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3