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

View of /FigWebServices/pathway.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Mon Dec 5 19:12:12 2005 UTC (13 years, 11 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, myrast_rel40, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, caBIG-05Apr06-00, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, caBIG-13Feb06-00, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.1: +17 -0 lines
add license words

# -*- 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.
#

### pathway.cgi ###
#
# Web-based interface provided for the KEGG Pathway tools that are in KGMLData.pm
# subsys_hope.cgi also has built in web interface for the Enzyme Analysis Tool.
#
# Author: Kevin Formsma
# Contact: kevin.formsma@hope.edu
# Hope College, Summer Research 2005 REU
###################

use Subsystem;
use FIG;
use CGI;
use HTML;

use KGMLData;

use strict;

my $fig = new FIG;
my $cgi = new CGI;
my $KGML = new KGMLData;
my $html = [];


my @ssa = &existing_subsystem_annotations($fig);
my @ss_names;
foreach my $subsystem (@ssa){
	push(@ss_names,$subsystem->[0]);
}

#for each pathway, get all EC's in it.

##**PARAMETERS DEBUGGING**##
#my($name,$value);
#push(@$html,$cgi->h4("Parameters Passed"));
#foreach $name ($cgi->param)
#{
#	push(@$html,"$name: ",$cgi->br);
#	foreach $value ($cgi->param( $name)){
#		push(@$html,"   $value",$cgi->br);
#	}
#}

#for each pathway, report how many ec's covered, how many are not.
push(@$html,$cgi->h1("KGML Pathway Tools"));

if($cgi->param('batch'))
{
	foreach my $ssa (@ss_names){
		my $subsystem = Subsystem->new($ssa,$fig,0);
		process_subsystem($subsystem,$ssa);
	}
}
elsif ($cgi->param('single_ec_relation') && $cgi->param('ssa_name') && $cgi->param('pathway'))
{
	my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
	$KGML->show_ec_relation_analysis($subsystem,$cgi->param('pathway'),$cgi,$html);
}
elsif ($cgi->param('show_match_ss') && $cgi->param('ssa_name'))
{
	my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
	$KGML->show_matching_pathways($subsystem,$cgi,$html);
}
elsif ($cgi->param('single_ss') && $cgi->param('ssa_name'))
{
	my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
	process_subsystem($subsystem,$cgi->param('ssa_name'));
}
elsif ($cgi->param('single_ss') && $cgi->param('pathway') && $cgi->param('ssa_name'))
{
	my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
	process_subsystem($subsystem,$cgi->param('ssa_name'));
}
elsif ($cgi->param('coverage'))
{
	push(@$html,$cgi->h4("Pathway Coverage Analysis"));
	my $roles_results = $KGML->all_subsystem_roles(@ss_names);
	my $coverage_results = $KGML->pathway_coverage_all($FIG_Config::kgml_dir,$roles_results);

	foreach my $pathway (@$coverage_results){
		push(@$html,$cgi->br,"<b>".$pathway->[0]."</b> => ");
		my $array_temp = $pathway->[1];
		foreach my $ss (@$array_temp){
			push(@$html,"<a href=\"$ss->[1]\">$ss->[0]</a>","  ,  ");
		}
		pop @$html;
	}
}
elsif ($cgi->param('single_rx') && $cgi->param('ssa_name'))
{
	my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
	my @ecs = $KGML->roles_to_ec($subsystem->get_roles());
	if(defined @ecs){
		
	#$kgml_dir is set in the FIG_Config perl module giving its location.
	#parse all the KGML xml files and find the best one.
	my ($best_pathway,$most_matches,@match);
	eval { ($best_pathway,$most_matches,@match) = $KGML->best_matching_pathway($FIG_Config::kgml_dir,@ecs) } ;

	if($@ || !defined $best_pathway)
	{
		push(@$html, "No Results Found or Error: $@");
	}

	else
	{	
		my $temp = scalar @ecs;

		#print how sucessful we were at matching
		push(@$html,$cgi->br, "Most matches: $most_matches / $temp");
	}

	#print the best pathway name we found
	my $temp_link =  $KGML->get_pathway_link();

	foreach my $ec (@match)
	{
		$temp_link = $temp_link."+".substr($ec,3);
	}

	push (@$html, $cgi->br, "Best pathway:","<a href=\"$temp_link\">".$KGML->current_pathway_title()."</a>",$cgi->br);
	my @start_points = split(/,/,$cgi->param('start_points'));

	my @end_points = split(/,/,$cgi->param('end_points'));

	$KGML -> print_reaction_data($html, $cgi, \@start_points, \@end_points);
    }
}
else{
	&show_initial();
}

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


sub process_subsystem
{
	my($subsystem,$ssa) = @_;
	push(@$html, $cgi->h3("Results of $ssa"));	
	$KGML->ec_relation_anlysis_web($fig,$subsystem,$cgi,$html,$ssa);
}

sub show_initial
{
		push(@$html,"Choose a Subsystem for options below",$cgi->br, 
			 $cgi->start_form(-action => "pathway.cgi",
				  -method => 'post'),
			 $cgi->scrolling_list( -name   => 'ssa_name',
                                        -values => [ @ss_names ],
                                        -size   => 10,
                                      ), $cgi->br,
	         $cgi->br,$cgi->h4("Enzyme Relation Analysis"), 	           
	         $cgi->submit(-value => 'Process Single Subsystem', -name => "show_match_ss"),$cgi->br,
			 #$cgi->submit(-value => 'Batch Process all Subsystems',-name => "batch"),$cgi->br,
			 $cgi->h4("Pathway Coverage Anyalsis"),
			 $cgi->submit(-value => 'Pathway Coverage Analysis', -name => "coverage"),$cgi->br,
			 #$cgi->h4("Reaction Analasis"),
			#"Start Point(s)",'<br>',$cgi->textfield(-name => 'start_points'), '<br>',
			 #"End Point(s)",'<br>',$cgi->textfield(-name => 'end_points'),'<br>',
			 #$cgi->submit(-value => 'Process for Single Subsystem', -name => "single_rx"),$cgi->br,
	         $cgi->end_form);
}

# RAE: I think this should be placed as a method in
# Subsystems.pm and called subsystems I know about or something.
# Cowardly didn't do though :-)
sub existing_subsystem_annotations {
    my($fig) = @_;
    my($ssa,$name);
    my @ssa = ();
    if (opendir(SSA,"$FIG_Config::data/Subsystems"))
    {
	@ssa = map { $ssa = $_; $name = $ssa; $ssa =~ s/[ \/]/_/g; [$name,$fig->subsystem_curator($ssa)] } grep { $_ !~ /^\./ } readdir(SSA);
	closedir(SSA);
    }
    return sort { (lc $a->[0]) cmp (lc $b->[0]) } @ssa;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3