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

Annotation of /FigWebServices/close_genome_discrepancies.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : overbeek 1.1 # -*- perl -*-
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 :     use HTML;
20 :     use CGI;
21 :     use CGI::Carp qw(fatalsToBrowser);
22 :     use strict;
23 :     use UnvSubsys;
24 :     my $fig=new FIG;
25 :     use raelib;
26 :     my $raelib=new raelib;
27 :     my $cgi=new CGI;
28 :     my $html=["<TITLE>Discrepancies between close genomes</TITLE>"];
29 :    
30 :    
31 :     my @orgs=sort {$fig->genus_species($a) cmp $fig->genus_species($b)} $cgi->param('korgs');
32 :     unless (@orgs > 1)
33 :     {
34 :     push @$html, (
35 :     $cgi->h1("<center>Discrepancies between close genomes</center>"),
36 :     $cgi->start_form,
37 :     $cgi->p("Please enter your username", $cgi->textfield(-name=>"user", -size=>20)),
38 :     $cgi->p("Please choose more than one genome from the menu, and a list of all discrepant pegs will be generated for you."),
39 :     $raelib->scrolling_org_list($cgi, 1),
40 :     $cgi->p("Maximum pegs per page", $cgi->textfield(-name=>"max", -value=>10, -size=>5)),
41 :     $cgi->p,
42 :     $cgi->submit, $cgi->reset,
43 :     $cgi->end_form);
44 :     &HTML::show_page($cgi, $html, 1);
45 :     exit(0);
46 :     }
47 :    
48 :     my $wanted={map {($_=>1)} @orgs};
49 :    
50 :     my $key_org = $cgi->param('key_org');
51 :     my $first_peg = $cgi->param('first_peg');
52 :     my $maxN = $cgi->param('maxN');
53 :     my $maxP = $cgi->param('maxP');
54 :     my $user = $cgi->param('user');
55 :     my $max = $cgi->param('max');
56 :    
57 :     unless ($key_org) {$key_org=$orgs[0]}
58 : overbeek 1.2 unless ($maxN) {$maxN=10}
59 : overbeek 1.1 unless ($maxP) {$maxP=1e-20}
60 :     unless ($max) {$max=10}
61 :    
62 :     my $keep=0;
63 :     unless ($first_peg) {$keep=1}
64 :    
65 :    
66 :     my $last_peg;
67 :     foreach my $peg (sort {$fig->feature_location($a) cmp $fig->feature_location($b)} $fig->pegs_of($key_org))
68 :     {
69 :     my $tab;
70 :     ($peg eq $first_peg) ? ($keep=1) : 1;
71 :     next unless ($keep);
72 :     $last_peg=$peg;
73 :     last if ($keep > $max);
74 :     my $fn=$fig->function_of($peg, $user);
75 :     my @inc=($peg);
76 :     my %function;
77 :     $function{$fn}=1;
78 :     foreach my $sim ($fig->sims($peg, $maxN, $maxP, "figx"))
79 :     {
80 :     next unless ($wanted->{$fig->genome_of($sim->[1])});
81 :     $fn=$fig->function_of($sim->[1], $user);
82 :     push @inc, $sim->[1];
83 :     $function{$fn}++;
84 :     }
85 :    
86 :     next unless (scalar(keys %function) > 1); # don't keep if they all have the same function
87 :    
88 :     # what are the orders of the functions (for the colors)
89 :     my $cnt=0;
90 :     my %position;
91 :     foreach my $fn (sort {$function{$b} <=> $function{$a}} keys %function) {$position{$fn}=$cnt++}
92 :     my @colors= UnvSubsys::cool_colors();
93 :    
94 :     foreach my $peg (@inc)
95 :     {
96 :     my $user_entry = &HTML::fid_link( $cgi, $peg );
97 :     if ($user)
98 :     {
99 :     $user_entry = $cgi->checkbox(-name => 'checked', -label => '', -value => $peg) . "&nbsp; $user_entry";
100 :     }
101 :    
102 :     my $fn = $fig->function_of($peg,$user);
103 :     # note that %function has the nummber of functions with this annotation
104 :     my $color="#FFFFFF";
105 :     if ($fn) {$color=$colors[$position{$fn}]}
106 :     # add the annotation checkbox
107 :     if ($user && $fn)
108 :     {
109 :     $fn = $cgi->checkbox(-name => 'from', -label => '', -value => $peg) . "&nbsp; $fn";
110 :     }
111 :     # finally add the color
112 :     $fn=[$fn, "td style='background-color: $color'"];
113 :    
114 :     my $in_sub=" &nbsp; ";
115 : overbeek 1.2 my @subs=map {$_->[0]} $fig->subsystems_for_peg($peg);
116 : overbeek 1.1 if (@subs > 0) {
117 :     $in_sub = @subs;
118 :     my $ss_list=join "<br>", map { my $g = $_; $g =~ s/\_/ /g; $_ = $g } sort {$a cmp $b} @subs;
119 :     $in_sub = $cgi->a({id=>"subsystems", onMouseover=>"javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Subsystems', '$ss_list', ''); this.tooltip.addHandler(); return false;"}, $in_sub);
120 :     }
121 :     my $ev = join("<br>", &evidence_codes($fig, $peg));
122 :    
123 :    
124 :     my $row=[
125 :     $keep,
126 :     $fig->abbrev($fig->genus_species($fig->genome_of($peg))),
127 :     $user_entry,
128 :     $in_sub,
129 :     $ev,
130 :     $fig->translation_length($peg),
131 :     $fn,
132 :     ];
133 :    
134 :     push @$tab, $row;
135 :     }
136 :     $keep++;
137 :    
138 :    
139 :    
140 :     if ($user)
141 :     {
142 :     push(@$html,$cgi->start_form(-method => 'post',
143 :     -target => "$$",
144 :     -action => &FIG::cgi_url . "/fid_checked.cgi"),
145 :     $cgi->hidden(-name => 'new_framework'),
146 :     $cgi->hidden(-name => 'user', -value => $user),
147 :     $cgi->hidden(-name => 'maxP', -value => $maxP ),
148 :     $cgi->hidden(-name => 'max', -value => $max),
149 :     $cgi->hidden(-name => 'maxN', -value => $maxN ),
150 :     $cgi->hidden(-name => 'key_org', -value => $key_org ),
151 :     $cgi->hidden(-name => 'first_peg', -value => $last_peg ),
152 :    
153 :    
154 :     );
155 :     }
156 :    
157 :    
158 :    
159 :    
160 :     my $col_hdrs=["Set", "Organism", "PEG", "SS", "EV", "Len", "Function"];
161 :     push( @$html, &HTML::make_table( $col_hdrs, $tab, "Description By Set" ) );
162 :    
163 :     if ($user)
164 :     {
165 :     push(@$html,
166 :     $cgi->submit('assign/annotate'),
167 :     $cgi->end_form,
168 :     );
169 :     }
170 :    
171 :     }
172 :    
173 :     my $link=$cgi->url."?user=$user&max=$max&maxN=$maxN&maxP=$maxP&key_org=$key_org&first_peg=$last_peg&korgs=".(join("&korgs=", @orgs));
174 :     splice(@$html, 1, 0, $cgi->p("<a href='$link'>Next $max pegs</a>"));
175 :    
176 :    
177 :     push @$html, $cgi->p("<a href='$link'>Next $max pegs</a>");
178 :     &HTML::show_page($cgi, $html);
179 :    
180 :    
181 :    
182 :    
183 :    
184 :    
185 :    
186 :    
187 :     sub evidence_codes {
188 :     my($fig,$peg) = @_;
189 :    
190 :     if ($peg !~ /^fig\|\d+\.\d+\.peg\.\d+$/) { return "" }
191 :    
192 :     my @codes = grep { $_->[1] =~ /^evidence_code/i } $fig->get_attributes($peg);
193 :     return (@codes > 0) ? map { $_->[2] } @codes : ();
194 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3