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

Annotation of /FigWebServices/pathway.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : dejongh 1.1 # -*- perl -*-
2 : olson 1.2 #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 : dejongh 1.1 ### pathway.cgi ###
20 :     #
21 :     # Web-based interface provided for the KEGG Pathway tools that are in KGMLData.pm
22 :     # subsys_hope.cgi also has built in web interface for the Enzyme Analysis Tool.
23 :     #
24 :     # Author: Kevin Formsma
25 :     # Contact: kevin.formsma@hope.edu
26 :     # Hope College, Summer Research 2005 REU
27 :     ###################
28 :    
29 :     use Subsystem;
30 :     use FIG;
31 :     use CGI;
32 :     use HTML;
33 :    
34 :     use KGMLData;
35 :    
36 :     use strict;
37 :    
38 :     my $fig = new FIG;
39 :     my $cgi = new CGI;
40 :     my $KGML = new KGMLData;
41 :     my $html = [];
42 :    
43 :    
44 :     my @ssa = &existing_subsystem_annotations($fig);
45 :     my @ss_names;
46 :     foreach my $subsystem (@ssa){
47 :     push(@ss_names,$subsystem->[0]);
48 :     }
49 :    
50 :     #for each pathway, get all EC's in it.
51 :    
52 :     ##**PARAMETERS DEBUGGING**##
53 :     #my($name,$value);
54 :     #push(@$html,$cgi->h4("Parameters Passed"));
55 :     #foreach $name ($cgi->param)
56 :     #{
57 :     # push(@$html,"$name: ",$cgi->br);
58 :     # foreach $value ($cgi->param( $name)){
59 :     # push(@$html," $value",$cgi->br);
60 :     # }
61 :     #}
62 :    
63 :     #for each pathway, report how many ec's covered, how many are not.
64 :     push(@$html,$cgi->h1("KGML Pathway Tools"));
65 :    
66 :     if($cgi->param('batch'))
67 :     {
68 :     foreach my $ssa (@ss_names){
69 :     my $subsystem = Subsystem->new($ssa,$fig,0);
70 :     process_subsystem($subsystem,$ssa);
71 :     }
72 :     }
73 :     elsif ($cgi->param('single_ec_relation') && $cgi->param('ssa_name') && $cgi->param('pathway'))
74 :     {
75 :     my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
76 :     $KGML->show_ec_relation_analysis($subsystem,$cgi->param('pathway'),$cgi,$html);
77 :     }
78 :     elsif ($cgi->param('show_match_ss') && $cgi->param('ssa_name'))
79 :     {
80 :     my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
81 :     $KGML->show_matching_pathways($subsystem,$cgi,$html);
82 :     }
83 :     elsif ($cgi->param('single_ss') && $cgi->param('ssa_name'))
84 :     {
85 :     my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
86 :     process_subsystem($subsystem,$cgi->param('ssa_name'));
87 :     }
88 :     elsif ($cgi->param('single_ss') && $cgi->param('pathway') && $cgi->param('ssa_name'))
89 :     {
90 :     my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
91 :     process_subsystem($subsystem,$cgi->param('ssa_name'));
92 :     }
93 :     elsif ($cgi->param('coverage'))
94 :     {
95 :     push(@$html,$cgi->h4("Pathway Coverage Analysis"));
96 :     my $roles_results = $KGML->all_subsystem_roles(@ss_names);
97 :     my $coverage_results = $KGML->pathway_coverage_all($FIG_Config::kgml_dir,$roles_results);
98 :    
99 :     foreach my $pathway (@$coverage_results){
100 :     push(@$html,$cgi->br,"<b>".$pathway->[0]."</b> => ");
101 :     my $array_temp = $pathway->[1];
102 :     foreach my $ss (@$array_temp){
103 :     push(@$html,"<a href=\"$ss->[1]\">$ss->[0]</a>"," , ");
104 :     }
105 :     pop @$html;
106 :     }
107 :     }
108 :     elsif ($cgi->param('single_rx') && $cgi->param('ssa_name'))
109 :     {
110 :     my $subsystem = Subsystem->new($cgi->param('ssa_name'), $fig,0);
111 :     my @ecs = $KGML->roles_to_ec($subsystem->get_roles());
112 :     if(defined @ecs){
113 :    
114 :     #$kgml_dir is set in the FIG_Config perl module giving its location.
115 :     #parse all the KGML xml files and find the best one.
116 :     my ($best_pathway,$most_matches,@match);
117 :     eval { ($best_pathway,$most_matches,@match) = $KGML->best_matching_pathway($FIG_Config::kgml_dir,@ecs) } ;
118 :    
119 :     if($@ || !defined $best_pathway)
120 :     {
121 :     push(@$html, "No Results Found or Error: $@");
122 :     }
123 :    
124 :     else
125 :     {
126 :     my $temp = scalar @ecs;
127 :    
128 :     #print how sucessful we were at matching
129 :     push(@$html,$cgi->br, "Most matches: $most_matches / $temp");
130 :     }
131 :    
132 :     #print the best pathway name we found
133 :     my $temp_link = $KGML->get_pathway_link();
134 :    
135 :     foreach my $ec (@match)
136 :     {
137 :     $temp_link = $temp_link."+".substr($ec,3);
138 :     }
139 :    
140 :     push (@$html, $cgi->br, "Best pathway:","<a href=\"$temp_link\">".$KGML->current_pathway_title()."</a>",$cgi->br);
141 :     my @start_points = split(/,/,$cgi->param('start_points'));
142 :    
143 :     my @end_points = split(/,/,$cgi->param('end_points'));
144 :    
145 :     $KGML -> print_reaction_data($html, $cgi, \@start_points, \@end_points);
146 :     }
147 :     }
148 :     else{
149 :     &show_initial();
150 :     }
151 :    
152 :     &HTML::show_page($cgi,$html);
153 :    
154 :    
155 :     sub process_subsystem
156 :     {
157 :     my($subsystem,$ssa) = @_;
158 :     push(@$html, $cgi->h3("Results of $ssa"));
159 :     $KGML->ec_relation_anlysis_web($fig,$subsystem,$cgi,$html,$ssa);
160 :     }
161 :    
162 :     sub show_initial
163 :     {
164 :     push(@$html,"Choose a Subsystem for options below",$cgi->br,
165 :     $cgi->start_form(-action => "pathway.cgi",
166 :     -method => 'post'),
167 :     $cgi->scrolling_list( -name => 'ssa_name',
168 :     -values => [ @ss_names ],
169 :     -size => 10,
170 :     ), $cgi->br,
171 :     $cgi->br,$cgi->h4("Enzyme Relation Analysis"),
172 :     $cgi->submit(-value => 'Process Single Subsystem', -name => "show_match_ss"),$cgi->br,
173 :     #$cgi->submit(-value => 'Batch Process all Subsystems',-name => "batch"),$cgi->br,
174 :     $cgi->h4("Pathway Coverage Anyalsis"),
175 :     $cgi->submit(-value => 'Pathway Coverage Analysis', -name => "coverage"),$cgi->br,
176 :     #$cgi->h4("Reaction Analasis"),
177 :     #"Start Point(s)",'<br>',$cgi->textfield(-name => 'start_points'), '<br>',
178 :     #"End Point(s)",'<br>',$cgi->textfield(-name => 'end_points'),'<br>',
179 :     #$cgi->submit(-value => 'Process for Single Subsystem', -name => "single_rx"),$cgi->br,
180 :     $cgi->end_form);
181 :     }
182 :    
183 :     # RAE: I think this should be placed as a method in
184 :     # Subsystems.pm and called subsystems I know about or something.
185 :     # Cowardly didn't do though :-)
186 :     sub existing_subsystem_annotations {
187 :     my($fig) = @_;
188 :     my($ssa,$name);
189 :     my @ssa = ();
190 :     if (opendir(SSA,"$FIG_Config::data/Subsystems"))
191 :     {
192 :     @ssa = map { $ssa = $_; $name = $ssa; $ssa =~ s/[ \/]/_/g; [$name,$fig->subsystem_curator($ssa)] } grep { $_ !~ /^\./ } readdir(SSA);
193 :     closedir(SSA);
194 :     }
195 :     return sort { (lc $a->[0]) cmp (lc $b->[0]) } @ssa;
196 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3