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

View of /FigWebServices/comp_MR.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Sun Mar 11 20:37:54 2007 UTC (13 years, 2 months ago) by overbeek
Branch: MAIN
basic stuff for comparing 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);
if ($genome1 =~ /^\d+\.\d+/)
{
    $fig = new FIG;
}
elsif (($genome1 =~ /\d+\.\d+$/) && (-d $genome1))
{
    my $tmp = new FIG;
    $fig    = new FIGV($genome1,$tmp);
}

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

my $html = [];

if ($request eq "common")
{
    &process_common($fig,$cgi,$html,$common);
}

	
unshift @$html, "<TITLE>Compare Metabolic Reconstructions</TITLE>\n";

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

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

    foreach $tuple (@$common)
    {
	($sub,$role,$pegs1,$pegs2) = @$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))
	    {
		$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)
		    {
			$pegL = &HTML::fid_link($cgi,$peg);
			push(@$html,"<li>$pegL\n");
		    }
		    push(@$html,"</ul>\n");
		}
		push(@$html,"</ul>\n");
	    }
	}
    }
}


    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3