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

View of /FigWebServices/co_occurs_server.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Fri May 8 21:24:11 2009 UTC (11 years ago) by overbeek
Branch: MAIN
Changes since 1.1: +54 -2 lines
co_occurs functions added

use strict;
use Data::Dumper;

use YAML;

use CGI;
my $cgi = new CGI;

use FIG;
my $fig = new FIG;

use ERDB;
use FC;

my $function = $cgi->param('function');
$function || die "Missing a function in call to co_occurs_server.cgi";

my $db = ERDB::GetDatabase('Sapling');

if ($function eq "conserved_in_neighborhood")
{
    my $pegs = &YAML::Load($cgi->param('args'));
    my $tuples = [];
    foreach my $peg (@$pegs)
    {
	my $group = [];
	my @co_occurs = &FC::co_occurs($db,$peg);
	foreach my $tuple (@co_occurs)
	{
	    my($sc,$fid,$pairset) = @$tuple;
	    push(@$group,[$sc,$fid,scalar $fig->function_of($fid),$pairset]);
	}
	push(@$tuples,$group);
    }
    my $str = &YAML::Dump($tuples);
    print $str;
}
elsif ($function eq "pairsets")
{
    my $pairsets = &YAML::Load($cgi->param('args'));
    my $ans = [];
    foreach my $pairset (@$pairsets)
    {
	push(@$ans,[$pairset,[&FC::co_occurrence_set($db,$pairset)]]);
    }
    print &YAML::Dump($ans);
}
elsif ($function eq "clusters_containing")
{
    my $pegs = &YAML::Load($cgi->param('args'));
    my $ans = [];
    foreach my $peg (@$pegs)
    {
	my $cluster = &FC::in_co_occurrence_cluster($db,$peg);
	if ($cluster)
	{
	    my $func = scalar $fig->function_of($peg);
	    push(@$ans,[$peg,$func,[map { [$_,scalar $fig->function_of($_)] } @$cluster]]);
	}
    }
    print &YAML::Dump($ans);
}
elsif ($function eq "related_clusters")
{
    my $pegs = &YAML::Load($cgi->param('args'));
    my $ans = [];
    foreach my $peg (@$pegs)
    {
	my $one_set = [];
	my @clusters = &FC::largest_co_occurrence_clusters($db,$peg);
	foreach my $cluster (@clusters)
	{
	    my($peg1,$sc,$other_pegs) = @$cluster;
	    my $func1 = $fig->function_of($peg1);
	    my $others = [ map { [$_,scalar $fig->function_of($_)] } @$other_pegs];
	    push(@$one_set,[$peg1,$sc,$others]);
	}
	push(@$ans,$one_set);
    }
    print &YAML::Dump($ans);
}
elsif ($function eq "related_figfams")
{
    my $ffs = &YAML::Load($cgi->param('args'));
    my $ans = [];
    foreach my $ff (@$ffs)
    {
	push(@$ans,[$ff,[&FC::co_occurring_FIGfams($db,$ff)]]);
    }
    print &YAML::Dump($ans);
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3