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

Annotation of /FigWebServices/pathway.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3