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

Annotation of /FigWebServices/check_subsys.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (view) (download)

1 : overbeek 1.1 # -*- perl -*-
2 : olson 1.10 #
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 : overbeek 1.1
20 :     use FIG;
21 :     my $fig = new FIG;
22 :    
23 :     use Subsystem;
24 :    
25 :     use HTML;
26 :     use strict;
27 :    
28 :     use CGI;
29 :     my $cgi = new CGI;
30 :    
31 :     if (0)
32 :     {
33 :     my $VAR1;
34 :     eval(join("",`cat /tmp/check_ssa_parms`));
35 :     $cgi = $VAR1;
36 :     # print STDERR &Dumper($cgi);
37 :     }
38 :    
39 :     if (0)
40 :     {
41 :     print $cgi->header;
42 :     my @params = $cgi->param;
43 :     print "<pre>\n";
44 :     foreach $_ (@params)
45 :     {
46 :     print "$_\t:",join(",",$cgi->param($_)),":\n";
47 :     }
48 :    
49 :     if (0)
50 :     {
51 :     if (open(TMP,">/tmp/check_ssa_parms"))
52 :     {
53 :     print TMP &Dumper($cgi);
54 :     close(TMP);
55 :     }
56 :     }
57 :     exit;
58 :     }
59 :     my($genome);
60 :    
61 :     my $html = [];
62 :     my $subsys = $cgi->param('subsystem');
63 :     if (! $subsys)
64 :     {
65 :     my @ssa = &existing_subsystem_annotations;
66 :    
67 :     if (@ssa > 0)
68 :     {
69 :     &format_ssa_table($cgi,$html,\@ssa);
70 :     }
71 :     else
72 :     {
73 :     push(@$html,$cgi->h1('Sorry, no subsystems defined'));
74 :     }
75 :     }
76 :     elsif ($subsys && ($cgi->param('request') eq "check_ssa"))
77 :     {
78 :     &check_subsystem($cgi,$fig,$html,$subsys);
79 :     }
80 :     &HTML::show_page($cgi,$html);
81 :    
82 :     sub format_ssa_table {
83 :     my($cgi,$html,$ssaP) = @_;
84 :    
85 : overbeek 1.2 my $user = $cgi->param('user');
86 :     $user = $user ? $user : "";
87 : overbeek 1.1 push(@$html, $cgi->start_form(-action => "check_subsys.cgi",
88 :     -method => 'post'),
89 :     $cgi->hidden(-name => 'request', -value => 'check_ssa', -override => 1),
90 : overbeek 1.2 $cgi->hidden(-name => 'user', -value => "$user", -override => 1),
91 : overbeek 1.1 $cgi->scrolling_list( -name => 'subsystem',
92 :     -values => [ map { $_->[0] } @$ssaP ],
93 :     -size => 10
94 :     ),
95 :     $cgi->br,
96 :     $cgi->submit( 'Pick One' ),
97 :     $cgi->end_form
98 :     );
99 :     }
100 :    
101 :     sub existing_subsystem_annotations {
102 :     my($ssa,$name);
103 :     my @ssa = ();
104 :     if (opendir(SSA,"$FIG_Config::data/Subsystems"))
105 :     {
106 :     @ssa = map { $ssa = $_; $name = $ssa; $ssa =~ s/[ \/]/_/g; [$name,&curator($ssa)] } grep { $_ !~ /^\./ } readdir(SSA);
107 :     closedir(SSA);
108 :     }
109 :     return sort { $a->[0] cmp $b->[0] } @ssa;
110 :     }
111 :    
112 :     sub curator {
113 :     my($ssa) = @_;
114 :     my($who) = "";
115 :    
116 :     if (open(DATA,"<$FIG_Config::data/Subsystems/$ssa/curation.log"))
117 :     {
118 :     $_ = <DATA>;
119 :     if ($_ =~ /^\d+\t(\S+)\s+started/)
120 :     {
121 :     $who = $1;
122 :     }
123 :     close(DATA);
124 :     }
125 :     return $who;
126 :     }
127 :    
128 :     sub check_subsystem {
129 :     my($cgi,$fig,$html,$subsys) = @_;
130 : redwards 1.4 my($col_hdrs1,$col_hdrs2,$tab1,$tab2,$x);
131 : overbeek 1.1
132 : redwards 1.4 my $user=$cgi->param('user');
133 : overbeek 1.12 my @raw_output = &get_check_data($cgi,$subsys);
134 :    
135 :     # my @raw_output = &FIG::run_gathering_output("$FIG_Config::bin/check_subsystems", $subsys);
136 : overbeek 1.11 # warn "Got raw output @raw_output\n";
137 : olson 1.9 my @checked = map { chop; [split(/\t/,$_)] } @raw_output;
138 : overbeek 1.13
139 : redwards 1.4 # RAE: it only makes sense to have Assign Role in column 1, so I duplicate this instead of leaving the column empty. Blah.
140 : redwards 1.6 $col_hdrs1 = ["PEG","Function","Role","Assign Role","Other Subsystems","Genome"];
141 : redwards 1.4 $col_hdrs2 = ["PEG","Function","Role","Other Subsystems","Genome"];
142 : overbeek 1.1 $tab1 = [];
143 :     $tab2 = [];
144 :    
145 :     foreach $x (@checked)
146 :     {
147 : overbeek 1.12 if ($x->[1] =~ /^(mismatch|left-out)/)
148 : overbeek 1.1 {
149 : overbeek 1.13 next if (! $fig->is_real_feature($x->[2]));
150 : overbeek 1.12 my(undef,$code,$peg,$func,$role,$gs) = @$x;
151 :     #RAE added the other subsystems column to the table
152 :     my $othersubsys='';
153 :     if (my @otherss = $fig->subsystems_for_peg($peg))
154 :     {
155 :     foreach my $ssr (@otherss)
156 :     {
157 :     next if ($$ssr[0] eq $subsys);
158 :     $othersubsys .= $cgi->a({href => "subsys.cgi?user=$user&ssa_name=" . $$ssr[0] . "&request=show_ssa"}, $$ssr[0]) . "<br\n";
159 :     }
160 :     }
161 :     my $link = &HTML::fid_link($cgi,$peg);
162 :     my $checkbox=$cgi->checkbox(-name=>"checked", -label=>'', -value=>"to=$peg,from=$role");
163 :     if ($code eq "mismatch")
164 :     {
165 :     push(@$tab1,[$link,$func,$role,$checkbox,$othersubsys,$gs]);
166 :     }
167 :     elsif ($code eq 'left-out')
168 :     {
169 :     push(@$tab2,[$link,$func,$role,$othersubsys,$gs]);
170 :     }
171 : overbeek 1.1 }
172 :     }
173 : redwards 1.4
174 :     # RAE addd the form controls
175 :     push(@$html, $cgi->start_form( -method => 'post', -action => 'fid_checked.cgi', -name => 'fid_checked'), $cgi->hidden(-name => 'user', -value => $user));
176 :     push(@$html,&HTML::make_table($col_hdrs1,$tab1,"PEGs IN Subsystem with MISMATCHING Functions"));
177 : redwards 1.5
178 : redwards 1.6 push(@$html, $cgi->br, &HTML::java_buttons("fid_checked", "checked"), $cgi->br);
179 : redwards 1.7 push(@$html, $cgi->submit(-name=>'batch_assign', -label=>"Assign Roles to Selected PEGs"));
180 : overbeek 1.2 push(@$html,$cgi->hr,$cgi->br,$cgi->br);
181 :    
182 : redwards 1.4 push(@$html,&HTML::make_table($col_hdrs2,$tab2,"PEGs NOT in Subsystem with MATCHING Functions"));
183 : overbeek 1.8 push(@$html,$cgi->end_form);
184 : overbeek 1.13
185 :     my $col_hdrs3 = ['Genome','Genus and Species','Possible Variant Codes','Detected Roles'];
186 :     my $tab3 = [];
187 :     my @to_add = grep { $_->[1] eq 'maybe-add' } @checked;
188 :    
189 :     my($entry,$vcodes,$genome,$gs,@roles);
190 :     foreach $entry (sort { &sort_order($a->[3],$b->[3]) } @to_add)
191 :     {
192 :     (undef,undef,undef,$vcodes,$genome,$gs,@roles) = @$entry;
193 :     push(@$tab3,[$genome,$gs,$vcodes,join("<br>",@roles)]);
194 :     }
195 :     push(@$html,&HTML::make_table($col_hdrs3,$tab3,"Genomes that Should Be Considered For Addition"));
196 :     }
197 :    
198 :     sub sort_order {
199 :     my($a,$b) = @_;
200 :    
201 :     my @c1 = split(/,/,$a);
202 :     my @c2 = split(/,/,$b);
203 :     return $c2[0] <=> $c1[0];
204 : overbeek 1.1 }
205 : overbeek 1.12
206 :     sub get_check_data {
207 :     my($cgi,$subsys) = @_;
208 :     my @raw_output;
209 :    
210 :     if ($cgi->param('fast') && (-e "$FIG_Config::data/Subsystems/$subsys/warnings"))
211 :     {
212 : overbeek 1.13 @raw_output = `cat $FIG_Config::data/Subsystems/$subsys/warnings`;
213 : overbeek 1.12 }
214 :     else
215 :     {
216 :     @raw_output = &FIG::run_gathering_output("$FIG_Config::bin/check_subsystems", $subsys);
217 :     # warn "Got raw output @raw_output\n";
218 :     }
219 :     return @raw_output;
220 :     }
221 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3