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

View of /FigWebServices/comp_MR.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Mon Mar 12 01:13:24 2007 UTC (13 years, 4 months ago) by overbeek
Branch: MAIN
Changes since 1.1: +41 -9 lines
basic ability to compare metabolic reconstructions

# -*- perl -*-
#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#


use HTML;
use strict;

use CGI;
my $cgi = new CGI;

if (0)
{
    my $VAR1;
    eval(join("",`cat /tmp/compMR_parms`));
    $cgi = $VAR1;
#   print STDERR &Dumper($cgi);
}

if (0)
{
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params)
    {
	print "$_\t:",join(",",$cgi->param($_)),":\n";
    }

    if (0)
    {
	if (open(TMP,">/tmp/compMR_parms"))
	{
	    print TMP &Dumper($cgi);
	    close(TMP);
	}
    }
    exit;
}

my $genome1 = $cgi->param('genome1');
my $genome2 = $cgi->param('genome2');
my $request = $cgi->param('request');

use CompareMR;
use FIG;
use FIGV;

my($fig,$use_figV);
if ($genome1 =~ /^\d+\.\d+/)
{
    $fig = new FIG;
    $use_figV = 0;
}
elsif (($genome1 =~ /\d+\.\d+$/) && (-d $genome1))
{
    my $tmp = new FIG;
    $fig    = new FIGV($genome1,$tmp);
    $use_figV = 1;
}

my($common,$in1_not2,$in2_not1) = &CompareMR::compare_genomes_MR($genome1,$genome2);

my $html = [];

if ($request eq "common")
{
    &process_data($fig,$cgi,$html,$common,$use_figV);
}
elsif ($request eq "in1_not2")
{
    &process_data($fig,$cgi,$html,$in1_not2,$use_figV);
}
elsif ($request eq "in2_not1")
{
    &process_data($fig,$cgi,$html,$in2_not1,0);
}
	
unshift @$html, "<TITLE>Compare Metabolic Reconstructions</TITLE>\n";

&HTML::show_page($cgi,$html);

sub process_data {
    my($fig,$cgi,$html,$data,$use_figV) = @_;
    my($tuple,$sub,$role,$pegs1,$pegs2,$classification,$class1,$class2);
    my($key,%subH,$subH1,$subH2,$subH3,@roles,$subL,$pegL,$peg);

    foreach $tuple (@$data)
    {
	($sub,$role,$pegs1) = @$tuple;
	$classification = $fig->subsystem_classification($sub);
	$class1 = $classification->[0] || "Unclassified";
	$class2 = $classification->[1] || "Unclassified";
	$subH{$class1}->{$class2}->{$sub}->{$role} = [$pegs1,$pegs2];
    }

    foreach $class1 (sort keys(%subH))
    {
	$subH1 = $subH{$class1};
	push(@$html,"<h1>$class1</h1>\n");
	foreach $class2 (sort keys(%$subH1))
	{
	    $subH2 = $subH1->{$class2};
	    push(@$html,"<h2>$class2</h2>\n");
	    foreach $sub (sort keys(%$subH2))
	    {
		if ($use_figV)
		{
		    $subL = &sub_P1K_link($cgi,$sub);
		}
		else
		{
		    $subL  = &HTML::sub_link($cgi,$sub);
		}
		$subH3 = $subH2->{$sub};
		push(@$html,"<h3>$subL</h3>\n");
		push(@$html,"<ul>\n");
		foreach $role (sort keys(%$subH3))
		{
		    push(@$html,"<li>$role\n");
		    ($pegs1,$pegs2) = @{$subH3->{$role}};
		    push(@$html,"<ul>\n");

		    foreach $peg (sort { &FIG::by_fig_id($a,$b) } @$pegs1)
		    {
			if ($use_figV)
			{
			    $pegL = &peg_P1K_link($cgi,$fig,$peg);
			}
			else
			{
			    $pegL = &HTML::fid_link($cgi,$peg);
			}
			push(@$html,"<li>$pegL\n");
		    }
		    push(@$html,"</ul>\n");
		}
		push(@$html,"</ul>\n");
	    }
	}
    }
}

sub peg_P1K_link {
    my($cgi,$fig,$peg) = @_;

    return $peg;
}

sub sub_P1K_link {
    my($cgi,$sub) = @_;
    
    return $sub;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3