[Bio] / FigKernelPackages / Observation.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/Observation.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.74 - (view) (download) (as text)

1 : mkubal 1.1 package Observation;
2 :    
3 : paczian 1.54 #use lib '/vol/ontologies';
4 : mkubal 1.19 use DBMaster;
5 : mkubal 1.34 use Data::Dumper;
6 : mkubal 1.19
7 : mkubal 1.1 require Exporter;
8 : parrello 1.59 @EXPORT_OK = qw(get_objects get_sims_objects);
9 : mkubal 1.1
10 : paczian 1.44 use WebColors;
11 : paczian 1.52 use WebConfig;
12 : paczian 1.44
13 : arodri7 1.16 use FIG_Config;
14 : arodri7 1.74 use LWP::Simple;
15 : mkubal 1.30 #use strict;
16 : arodri7 1.16 #use warnings;
17 : arodri7 1.9 use HTML;
18 : arodri7 1.55 use FFs;
19 : mkubal 1.1
20 :     1;
21 :    
22 :     =head1 NAME
23 :    
24 :     Observation -- A presentation layer for observations in SEED.
25 :    
26 :     =head1 DESCRIPTION
27 :    
28 :     The SEED environment contains various sources of information for sequence features. The purpose of this library is to provide a
29 :     single interface to this data.
30 :    
31 :     The data can be used to display information for a given sequence feature (protein or other, but primarily information is computed for proteins).
32 :    
33 :     =cut
34 :    
35 :     =head1 BACKGROUND
36 :    
37 :     =head2 Data incorporated in the Observations
38 :    
39 :     As the goal of this library is to provide an integrated view, we combine diverse sources of evidence.
40 :    
41 :     =head3 SEED core evidence
42 :    
43 :     The core SEED data structures provided by FIG.pm. These are Similarities, BBHs and PCHs.
44 :    
45 :     =head3 Attribute based Evidence
46 :    
47 :     We use the SEED attribute infrastructure to store information computed by a variety of computational procedures.
48 :    
49 :     These are e.g. InterPro hits via InterProScan (ipr), NCBI Conserved Domain Database Hits via PSSM(cdd),
50 :     PFAM hits via HMM(pfam), SignalP results(signalp), and various others.
51 :    
52 :     =head1 METHODS
53 :    
54 :     The public methods this package provides are listed below:
55 :    
56 :    
57 : mkubal 1.24 =head3 context()
58 :    
59 :     Returns close or diverse for purposes of displaying genomic context
60 : mkubal 1.1
61 :     =cut
62 :    
63 : mkubal 1.24 sub context {
64 : mkubal 1.1 my ($self) = @_;
65 :    
66 : mkubal 1.24 return $self->{context};
67 : mkubal 1.1 }
68 :    
69 : mkubal 1.24 =head3 rows()
70 : mkubal 1.1
71 : mkubal 1.24 each row in a displayed table
72 : mkubal 1.1
73 : mkubal 1.24 =cut
74 :    
75 :     sub rows {
76 :     my ($self) = @_;
77 :    
78 :     return $self->{rows};
79 :     }
80 :    
81 :     =head3 acc()
82 :    
83 :     A valid accession or remote ID (in the style of a db_xref) or a valid local ID (FID) in case this is supported.
84 : mkubal 1.1
85 :     =cut
86 :    
87 : mkubal 1.24 sub acc {
88 : mkubal 1.1 my ($self) = @_;
89 : mkubal 1.24 return $self->{acc};
90 : mkubal 1.1 }
91 :    
92 : arodri7 1.40 =head3 query()
93 :    
94 :     The query id
95 :    
96 :     =cut
97 :    
98 :     sub query {
99 :     my ($self) = @_;
100 :     return $self->{query};
101 :     }
102 :    
103 :    
104 : mkubal 1.1 =head3 class()
105 :    
106 :     The class of evidence (required). This is usually simply the name of the tool or the name of the SEED data structure.
107 :     B<Please note> the connection of class and display_method and URL.
108 : mkubal 1.7
109 : mkubal 1.1 Current valid classes are:
110 :    
111 :     =over 9
112 :    
113 : arodri7 1.9 =item IDENTICAL (seq)
114 :    
115 : mkubal 1.3 =item SIM (seq)
116 : mkubal 1.1
117 : mkubal 1.3 =item BBH (seq)
118 : mkubal 1.1
119 : mkubal 1.3 =item PCH (fc)
120 : mkubal 1.1
121 : mkubal 1.3 =item FIGFAM (seq)
122 : mkubal 1.1
123 : mkubal 1.3 =item IPR (dom)
124 : mkubal 1.1
125 : mkubal 1.3 =item CDD (dom)
126 : mkubal 1.1
127 : mkubal 1.3 =item PFAM (dom)
128 : mkubal 1.1
129 : mkubal 1.12 =item SIGNALP_CELLO_TMPRED (loc)
130 : mkubal 1.1
131 : mkubal 1.20 =item PDB (seq)
132 :    
133 : mkubal 1.3 =item TMHMM (loc)
134 : mkubal 1.1
135 : mkubal 1.3 =item HMMTOP (loc)
136 : mkubal 1.1
137 :     =back
138 :    
139 :     =cut
140 :    
141 :     sub class {
142 :     my ($self) = @_;
143 :    
144 :     return $self->{class};
145 :     }
146 :    
147 :     =head3 type()
148 :    
149 :     The type of evidence (required).
150 :    
151 :     Where type is one of the following:
152 :    
153 :     =over 8
154 :    
155 :     =item seq=Sequence similarity
156 :    
157 :     =item dom=domain based match
158 :    
159 :     =item loc=Localization of the feature
160 :    
161 :     =item fc=Functional coupling.
162 :    
163 :     =back
164 :    
165 :     =cut
166 :    
167 :     sub type {
168 :     my ($self) = @_;
169 :    
170 : arodri7 1.26 return $self->{type};
171 : mkubal 1.1 }
172 :    
173 :     =head3 start()
174 :    
175 :     Start of hit in query sequence.
176 :    
177 :     =cut
178 :    
179 :     sub start {
180 :     my ($self) = @_;
181 :    
182 :     return $self->{start};
183 :     }
184 :    
185 :     =head3 end()
186 :    
187 :     End of the hit in query sequence.
188 :    
189 :     =cut
190 :    
191 :     sub stop {
192 :     my ($self) = @_;
193 :    
194 :     return $self->{stop};
195 :     }
196 :    
197 : arodri7 1.11 =head3 start()
198 :    
199 :     Start of hit in query sequence.
200 :    
201 :     =cut
202 :    
203 :     sub qstart {
204 :     my ($self) = @_;
205 :    
206 :     return $self->{qstart};
207 :     }
208 :    
209 :     =head3 qstop()
210 :    
211 :     End of the hit in query sequence.
212 :    
213 :     =cut
214 :    
215 :     sub qstop {
216 :     my ($self) = @_;
217 :    
218 :     return $self->{qstop};
219 :     }
220 :    
221 :     =head3 hstart()
222 :    
223 :     Start of hit in hit sequence.
224 :    
225 :     =cut
226 :    
227 :     sub hstart {
228 :     my ($self) = @_;
229 :    
230 :     return $self->{hstart};
231 :     }
232 :    
233 :     =head3 end()
234 :    
235 :     End of the hit in hit sequence.
236 :    
237 :     =cut
238 :    
239 :     sub hstop {
240 :     my ($self) = @_;
241 :    
242 :     return $self->{hstop};
243 :     }
244 :    
245 :     =head3 qlength()
246 :    
247 :     length of the query sequence in similarities
248 :    
249 :     =cut
250 :    
251 :     sub qlength {
252 :     my ($self) = @_;
253 :    
254 :     return $self->{qlength};
255 :     }
256 :    
257 :     =head3 hlength()
258 :    
259 :     length of the hit sequence in similarities
260 :    
261 :     =cut
262 :    
263 :     sub hlength {
264 :     my ($self) = @_;
265 :    
266 :     return $self->{hlength};
267 :     }
268 :    
269 : mkubal 1.1 =head3 evalue()
270 :    
271 :     E-value or P-Value if present.
272 :    
273 :     =cut
274 :    
275 :     sub evalue {
276 :     my ($self) = @_;
277 :    
278 :     return $self->{evalue};
279 :     }
280 :    
281 :     =head3 score()
282 :    
283 :     Score if present.
284 :    
285 :     =cut
286 :    
287 :     sub score {
288 :     my ($self) = @_;
289 :     return $self->{score};
290 :     }
291 :    
292 : mkubal 1.12 =head3 display()
293 : mkubal 1.1
294 : mkubal 1.12 will be different for each type
295 : mkubal 1.1
296 :     =cut
297 :    
298 : mkubal 1.7 sub display {
299 : mkubal 1.1
300 : mkubal 1.7 die "Abstract Method Called\n";
301 : mkubal 1.1
302 :     }
303 :    
304 : mkubal 1.24 =head3 display_table()
305 : mkubal 1.7
306 : mkubal 1.24 will be different for each type
307 : mkubal 1.1
308 : mkubal 1.24 =cut
309 : mkubal 1.1
310 : mkubal 1.24 sub display_table {
311 :    
312 :     die "Abstract Table Method Called\n";
313 : mkubal 1.1
314 :     }
315 :    
316 :     =head3 get_objects()
317 :    
318 :     This is the B<REAL WORKHORSE> method of this Package.
319 :    
320 :     =cut
321 :    
322 :     sub get_objects {
323 : arodri7 1.67 my ($self,$fid,$fig,$parameters,$scope) = @_;
324 : paczian 1.44
325 : mkubal 1.7 my $objects = [];
326 :     my @matched_datasets=();
327 : mkubal 1.1
328 : mkubal 1.7 # call function that fetches attribute based observations
329 :     # returns an array of arrays of hashes
330 :    
331 : mkubal 1.24 if($scope){
332 :     get_cluster_observations($fid,\@matched_datasets,$scope);
333 : mkubal 1.7 }
334 :     else{
335 :     my %domain_classes;
336 : arodri7 1.28 my @attributes = $fig->get_attributes($fid);
337 : arodri7 1.74 #$domain_classes{'CDD'} = 1;
338 : arodri7 1.41 $domain_classes{'PFAM'} = 1;
339 :     get_identical_proteins($fid,\@matched_datasets,$fig);
340 :     get_attribute_based_domain_observations($fid,\%domain_classes,\@matched_datasets,\@attributes,$fig);
341 : arodri7 1.67 get_sims_observations($fid,\@matched_datasets,$fig,$parameters);
342 : arodri7 1.41 get_functional_coupling($fid,\@matched_datasets,$fig);
343 :     get_attribute_based_location_observations($fid,\@matched_datasets,\@attributes,$fig);
344 :     get_pdb_observations($fid,\@matched_datasets,\@attributes,$fig);
345 : mkubal 1.1 }
346 : mkubal 1.7
347 :     foreach my $dataset (@matched_datasets) {
348 :     my $object;
349 :     if($dataset->{'type'} eq "dom"){
350 :     $object = Observation::Domain->new($dataset);
351 :     }
352 : arodri7 1.41 elsif($dataset->{'class'} eq "PCH"){
353 : arodri7 1.9 $object = Observation::FC->new($dataset);
354 :     }
355 : arodri7 1.41 elsif ($dataset->{'class'} eq "IDENTICAL"){
356 : arodri7 1.9 $object = Observation::Identical->new($dataset);
357 :     }
358 : arodri7 1.41 elsif ($dataset->{'class'} eq "SIGNALP_CELLO_TMPRED"){
359 : mkubal 1.12 $object = Observation::Location->new($dataset);
360 :     }
361 : arodri7 1.41 elsif ($dataset->{'class'} eq "SIM"){
362 : arodri7 1.10 $object = Observation::Sims->new($dataset);
363 :     }
364 : arodri7 1.41 elsif ($dataset->{'class'} eq "CLUSTER"){
365 : arodri7 1.15 $object = Observation::Cluster->new($dataset);
366 :     }
367 : arodri7 1.41 elsif ($dataset->{'class'} eq "PDB"){
368 : mkubal 1.20 $object = Observation::PDB->new($dataset);
369 :     }
370 :    
371 : mkubal 1.7 push (@$objects, $object);
372 : mkubal 1.1 }
373 : mkubal 1.7
374 :     return $objects;
375 : mkubal 1.1
376 :     }
377 :    
378 : parrello 1.70 =head3 get_attributes
379 : mkubal 1.61 provides layer of abstraction between tools and underlying access method to Attribute Server
380 :     =cut
381 :    
382 :     sub get_attributes{
383 :     my ($self,$fig,$search_set,$search_term,$value_array_ref) = @_;
384 :     my @attributes = $fig->get_attributes($search_set,$search_term,@$value_array_ref);
385 :     return @attributes;
386 :     }
387 :    
388 : arodri7 1.58 =head3 get_sims_objects()
389 :    
390 :     This is the B<REAL WORKHORSE> method of this Package.
391 :    
392 :     =cut
393 :    
394 :     sub get_sims_objects {
395 :     my ($self,$fid,$fig,$parameters) = @_;
396 :    
397 :     my $objects = [];
398 :     my @matched_datasets=();
399 :    
400 :     # call function that fetches attribute based observations
401 :     # returns an array of arrays of hashes
402 :     get_sims_observations($fid,\@matched_datasets,$fig,$parameters);
403 :    
404 :     foreach my $dataset (@matched_datasets) {
405 :     my $object;
406 :     if ($dataset->{'class'} eq "SIM"){
407 :     $object = Observation::Sims->new($dataset);
408 :     }
409 :     push (@$objects, $object);
410 :     }
411 :     return $objects;
412 :     }
413 :    
414 :    
415 : arodri7 1.28 =head3 display_housekeeping
416 :     This method returns the housekeeping data for a given peg in a table format
417 :    
418 :     =cut
419 :     sub display_housekeeping {
420 : arodri7 1.41 my ($self,$fid,$fig) = @_;
421 :     my $content = [];
422 :     my $row = [];
423 : arodri7 1.28
424 : arodri7 1.66 my $org_name = "Data not available";
425 :     if ( $fig->org_of($fid)){
426 :     $org_name = $fig->org_of($fid);
427 :     }
428 : arodri7 1.45 my $org_id = $fig->genome_of($fid);
429 : arodri7 1.28 my $function = $fig->function_of($fid);
430 : arodri7 1.41 #my $taxonomy = $fig->taxonomy_of($org_id);
431 :     my $length = $fig->translation_length($fid);
432 :    
433 :     push (@$row, $org_name);
434 :     push (@$row, $fid);
435 :     push (@$row, $length);
436 :     push (@$row, $function);
437 :    
438 :     # initialize the table for commentary and annotations
439 :     #$content .= qq(<b>My Sequence Data</b><br><table border="0">);
440 :     #$content .= qq(<tr width=15%><td >FIG ID</td><td>$fid</td></tr>\n);
441 :     #$content .= qq(<tr width=15%><td >Organism Name</td><td>$org_name</td></tr>\n);
442 :     #$content .= qq(<tr><td width=15%>Taxonomy</td><td>$taxonomy</td></tr>\n);
443 :     #$content .= qq(<tr width=15%><td>Function</td><td>$function</td></tr>\n);
444 :     #$content .= qq(<tr width=15%><td>Sequence Length</td><td>$length aa</td></tr>\n);
445 :     #$content .= qq(</table><p>\n);
446 :    
447 :     push(@$content, $row);
448 : arodri7 1.28
449 :     return ($content);
450 :     }
451 :    
452 :     =head3 get_sims_summary
453 :     This method uses as input the similarities of a peg and creates a tree view of their taxonomy
454 :    
455 :     =cut
456 :    
457 :     sub get_sims_summary {
458 : arodri7 1.53 my ($observation, $dataset, $fig) = @_;
459 : arodri7 1.28 my %families;
460 : arodri7 1.53 my $taxes = $fig->taxonomy_list();
461 :    
462 : arodri7 1.42 foreach my $thing (@$dataset) {
463 : arodri7 1.53 my ($id, $evalue);
464 :     if ($thing =~ /fig\|/){
465 :     $id = $thing;
466 :     $evalue = -1;
467 :     }
468 :     else{
469 :     next if ($thing->class ne "SIM");
470 :     $id = $thing->acc;
471 :     $evalue = $thing->evalue;
472 :     }
473 : arodri7 1.42 next if ($id !~ /fig\|/);
474 :     next if ($fig->is_deleted_fid($id));
475 : arodri7 1.53
476 : arodri7 1.42 my $genome = $fig->genome_of($id);
477 : arodri7 1.45 #my ($genome1) = ($genome) =~ /(.*)\./;
478 : arodri7 1.53 my $taxonomy = $taxes->{$genome};
479 : arodri7 1.28 my $parent_tax = "Root";
480 : arodri7 1.38 my @currLineage = ($parent_tax);
481 : arodri7 1.53 push (@{$families{figs}{$parent_tax}}, $id);
482 :     my $level = 2;
483 : arodri7 1.69
484 : arodri7 1.68 foreach my $tax (split(/\; /, $taxonomy),$id){
485 : arodri7 1.69 next if ($tax eq $parent_tax);
486 :     push (@{$families{children}{$parent_tax}}, $tax) if ($tax ne $parent_tax);
487 :     push (@{$families{figs}{$tax}}, $id) if ($tax ne $parent_tax);
488 :     $families{level}{$tax} = $level;
489 :     push (@currLineage, $tax);
490 :     $families{parent}{$tax} = $parent_tax;
491 :     $families{lineage}{$tax} = join(";", @currLineage);
492 :     if (defined ($families{evalue}{$tax})){
493 :     if ($evalue < $families{evalue}{$tax}){
494 :     $families{evalue}{$tax} = $evalue;
495 :     $families{color}{$tax} = &get_taxcolor($evalue);
496 : arodri7 1.39 }
497 : arodri7 1.69 }
498 :     else{
499 :     $families{evalue}{$tax} = $evalue;
500 :     $families{color}{$tax} = &get_taxcolor($evalue);
501 :     }
502 :    
503 :     $parent_tax = $tax;
504 :     $level++;
505 : arodri7 1.28 }
506 :     }
507 :    
508 :     foreach my $key (keys %{$families{children}}){
509 :     $families{count}{$key} = @{$families{children}{$key}};
510 :    
511 :     my %saw;
512 :     my @out = grep(!$saw{$_}++, @{$families{children}{$key}});
513 :     $families{children}{$key} = \@out;
514 :     }
515 : arodri7 1.53
516 :     return \%families;
517 : arodri7 1.28 }
518 :    
519 : mkubal 1.1 =head1 Internal Methods
520 :    
521 :     These methods are not meant to be used outside of this package.
522 :    
523 :     B<Please do not use them outside of this package!>
524 :    
525 :     =cut
526 :    
527 : arodri7 1.39 sub get_taxcolor{
528 :     my ($evalue) = @_;
529 :     my $color;
530 : arodri7 1.53 if ($evalue == -1){ $color = "black"; }
531 :     elsif (($evalue <= 1e-170) && ($evalue >= 0)){ $color = "#FF2000"; }
532 : arodri7 1.39 elsif (($evalue <= 1e-120) && ($evalue > 1e-170)){ $color = "#FF3300"; }
533 :     elsif (($evalue <= 1e-90) && ($evalue > 1e-120)){ $color = "#FF6600"; }
534 :     elsif (($evalue <= 1e-70) && ($evalue > 1e-90)){ $color = "#FF9900"; }
535 :     elsif (($evalue <= 1e-40) && ($evalue > 1e-70)){ $color = "#FFCC00"; }
536 :     elsif (($evalue <= 1e-20) && ($evalue > 1e-40)){ $color = "#FFFF00"; }
537 :     elsif (($evalue <= 1e-5) && ($evalue > 1e-20)){ $color = "#CCFF00"; }
538 :     elsif (($evalue <= 1) && ($evalue > 1e-5)){ $color = "#66FF00"; }
539 :     elsif (($evalue <= 10) && ($evalue > 1)){ $color = "#00FF00"; }
540 :     else{ $color = "#6666FF"; }
541 :     return ($color);
542 :     }
543 :    
544 :    
545 : mkubal 1.7 sub get_attribute_based_domain_observations{
546 :    
547 :     # we read a FIG ID and a reference to an array (of arrays of hashes, see above)
548 : arodri7 1.41 my ($fid,$domain_classes,$datasets_ref,$attributes_ref,$fig) = (@_);
549 : arodri7 1.66 my $seen = {};
550 : arodri7 1.28 foreach my $attr_ref (@$attributes_ref) {
551 : mkubal 1.7 my $key = @$attr_ref[1];
552 :     my @parts = split("::",$key);
553 :     my $class = $parts[0];
554 : arodri7 1.50 my $name = $parts[1];
555 : arodri7 1.66 next if ($seen->{$name});
556 :     $seen->{$name}++;
557 : arodri7 1.56 #next if (($class eq "PFAM") && ($name !~ /interpro/));
558 : arodri7 1.50
559 : mkubal 1.7 if($domain_classes->{$parts[0]}){
560 :     my $val = @$attr_ref[2];
561 : mkubal 1.8 if($val =~/^(\d+\.\d+|0\.0);(\d+)-(\d+)/){
562 : mkubal 1.7 my $raw_evalue = $1;
563 : mkubal 1.8 my $from = $2;
564 :     my $to = $3;
565 : mkubal 1.7 my $evalue;
566 : arodri7 1.50 if(($raw_evalue =~/(\d+)\.(\d+)/) && ($class ne "PFAM")){
567 : mkubal 1.7 my $part2 = 1000 - $1;
568 :     my $part1 = $2/100;
569 :     $evalue = $part1."e-".$part2;
570 :     }
571 : arodri7 1.50 elsif(($raw_evalue =~/(\d+)\.(\d+)/) && ($class eq "PFAM")){
572 :     $evalue=$raw_evalue;
573 :     }
574 : mkubal 1.7 else{
575 : mkubal 1.8 $evalue = "0.0";
576 : mkubal 1.7 }
577 : arodri7 1.66
578 : mkubal 1.7 my $dataset = {'class' => $class,
579 :     'acc' => $key,
580 :     'type' => "dom" ,
581 :     'evalue' => $evalue,
582 :     'start' => $from,
583 : mkubal 1.24 'stop' => $to,
584 :     'fig_id' => $fid,
585 :     'score' => $raw_evalue
586 : mkubal 1.7 };
587 :    
588 :     push (@{$datasets_ref} ,$dataset);
589 :     }
590 :     }
591 :     }
592 :     }
593 : mkubal 1.12
594 :     sub get_attribute_based_location_observations{
595 :    
596 : arodri7 1.41 my ($fid,$datasets_ref, $attributes_ref,$fig) = (@_);
597 :     #my $fig = new FIG;
598 : mkubal 1.12
599 : mkubal 1.30 my $location_attributes = ['SignalP','CELLO','TMPRED','Phobius'];
600 : mkubal 1.12
601 : arodri7 1.26 my $dataset = {'type' => "loc",
602 :     'class' => 'SIGNALP_CELLO_TMPRED',
603 :     'fig_id' => $fid
604 :     };
605 :    
606 : arodri7 1.28 foreach my $attr_ref (@$attributes_ref){
607 : mkubal 1.12 my $key = @$attr_ref[1];
608 : mkubal 1.30 next if (($key !~ /SignalP/) && ($key !~ /CELLO/) && ($key !~ /TMPRED/) && ($key !~/Phobius/) );
609 : mkubal 1.12 my @parts = split("::",$key);
610 :     my $sub_class = $parts[0];
611 :     my $sub_key = $parts[1];
612 :     my $value = @$attr_ref[2];
613 :     if($sub_class eq "SignalP"){
614 :     if($sub_key eq "cleavage_site"){
615 :     my @value_parts = split(";",$value);
616 :     $dataset->{'cleavage_prob'} = $value_parts[0];
617 :     $dataset->{'cleavage_loc'} = $value_parts[1];
618 :     }
619 :     elsif($sub_key eq "signal_peptide"){
620 :     $dataset->{'signal_peptide_score'} = $value;
621 :     }
622 :     }
623 : mkubal 1.30
624 : mkubal 1.12 elsif($sub_class eq "CELLO"){
625 :     $dataset->{'cello_location'} = $sub_key;
626 :     $dataset->{'cello_score'} = $value;
627 :     }
628 : mkubal 1.30
629 :     elsif($sub_class eq "Phobius"){
630 :     if($sub_key eq "transmembrane"){
631 :     $dataset->{'phobius_tm_locations'} = $value;
632 :     }
633 :     elsif($sub_key eq "signal"){
634 :     $dataset->{'phobius_signal_location'} = $value;
635 :     }
636 :     }
637 :    
638 : mkubal 1.12 elsif($sub_class eq "TMPRED"){
639 : arodri7 1.26 my @value_parts = split(/\;/,$value);
640 : mkubal 1.12 $dataset->{'tmpred_score'} = $value_parts[0];
641 :     $dataset->{'tmpred_locations'} = $value_parts[1];
642 :     }
643 :     }
644 :    
645 :     push (@{$datasets_ref} ,$dataset);
646 :    
647 :     }
648 :    
649 : mkubal 1.20 =head3 get_pdb_observations() (internal)
650 :    
651 :     This methods sets the type and class for pdb observations
652 :    
653 :     =cut
654 :    
655 :     sub get_pdb_observations{
656 : arodri7 1.41 my ($fid,$datasets_ref, $attributes_ref,$fig) = (@_);
657 : mkubal 1.20
658 : arodri7 1.41 #my $fig = new FIG;
659 : mkubal 1.20
660 : arodri7 1.28 foreach my $attr_ref (@$attributes_ref){
661 : mkubal 1.20 my $key = @$attr_ref[1];
662 : arodri7 1.28 next if ( ($key !~ /PDB/));
663 : mkubal 1.20 my($key1,$key2) =split("::",$key);
664 :     my $value = @$attr_ref[2];
665 :     my ($evalue,$location) = split(";",$value);
666 :    
667 :     if($evalue =~/(\d+)\.(\d+)/){
668 :     my $part2 = 1000 - $1;
669 :     my $part1 = $2/100;
670 :     $evalue = $part1."e-".$part2;
671 :     }
672 :    
673 :     my($start,$stop) =split("-",$location);
674 :    
675 :     my $url = @$attr_ref[3];
676 :     my $dataset = {'class' => 'PDB',
677 :     'type' => 'seq' ,
678 :     'acc' => $key2,
679 :     'evalue' => $evalue,
680 :     'start' => $start,
681 : mkubal 1.24 'stop' => $stop,
682 :     'fig_id' => $fid
683 : mkubal 1.20 };
684 :    
685 :     push (@{$datasets_ref} ,$dataset);
686 :     }
687 :     }
688 :    
689 : arodri7 1.15 =head3 get_cluster_observations() (internal)
690 :    
691 :     This methods sets the type and class for cluster observations
692 :    
693 :     =cut
694 :    
695 :     sub get_cluster_observations{
696 : mkubal 1.24 my ($fid,$datasets_ref,$scope) = (@_);
697 : arodri7 1.15
698 : arodri7 1.16 my $dataset = {'class' => 'CLUSTER',
699 : mkubal 1.24 'type' => 'fc',
700 :     'context' => $scope,
701 :     'fig_id' => $fid
702 : arodri7 1.16 };
703 : arodri7 1.15 push (@{$datasets_ref} ,$dataset);
704 :     }
705 :    
706 :    
707 : mkubal 1.3 =head3 get_sims_observations() (internal)
708 :    
709 :     This methods retrieves sims fills the internal data structures.
710 :    
711 :     =cut
712 :    
713 :     sub get_sims_observations{
714 : arodri7 1.58 my ($fid,$datasets_ref,$fig,$parameters) = (@_);
715 : mkubal 1.3
716 : arodri7 1.62 my ($max_sims, $max_expand, $max_eval, $sim_order, $db_filter, $sim_filters);
717 : arodri7 1.67 if ( (defined $parameters->{flag}) && ($parameters->{flag})){
718 : arodri7 1.58 $max_sims = $parameters->{max_sims};
719 :     $max_expand = $parameters->{max_expand};
720 :     $max_eval = $parameters->{max_eval};
721 :     $db_filter = $parameters->{db_filter};
722 : arodri7 1.62 $sim_filters->{ sort_by } = $parameters->{sim_order};
723 :     #$sim_order = $parameters->{sim_order};
724 : arodri7 1.58 $group_by_genome = 1 if (defined ($parameters->{group_genome}));
725 :     }
726 : arodri7 1.67 elsif ( (defined $parameters->{sims_db}) && ($parameters->{sims_db} eq 'all')){
727 :     $max_sims = 50;
728 :     $max_expand = 5;
729 :     $max_eval = 1e-5;
730 :     $db_filter = "all";
731 :     $sim_filters->{ sort_by } = 'id';
732 :     }
733 : arodri7 1.58 else{
734 :     $max_sims = 50;
735 :     $max_expand = 5;
736 :     $max_eval = 1e-5;
737 :     $db_filter = "figx";
738 : arodri7 1.62 $sim_filters->{ sort_by } = 'id';
739 :     #$sim_order = "id";
740 : arodri7 1.58 }
741 :    
742 : parrello 1.59 my($id, $genome, @genomes, %sims);
743 : arodri7 1.62 my @tmp= $fig->sims($fid,$max_sims,$max_eval,$db_filter,$max_expand,$sim_filters);
744 : arodri7 1.58 @tmp = grep { !($_->id2 =~ /^fig\|/ and $fig->is_deleted_fid($_->id2)) } @tmp;
745 : mkubal 1.4 my ($dataset);
746 : arodri7 1.26
747 : arodri7 1.58 if ($group_by_genome){
748 :     # Collect all sims from genome with the first occurance of the genome:
749 :     foreach $sim ( @tmp ){
750 :     $id = $sim->id2;
751 :     $genome = ($id =~ /^fig\|(\d+\.\d+)\.peg\.\d+/) ? $1 : $id;
752 :     if (! defined( $sims{ $genome } ) ) { push @genomes, $genome }
753 :     push @{ $sims{ $genome } }, $sim;
754 :     }
755 :     @tmp = map { @{ $sims{$_} } } @genomes;
756 :     }
757 : arodri7 1.66
758 :     my $seen_sims={};
759 : arodri7 1.58 foreach my $sim (@tmp){
760 : arodri7 1.26 my $hit = $sim->[1];
761 : arodri7 1.66 next if ($seen_sims->{$hit});
762 :     $seen_sims->{$hit}++;
763 : arodri7 1.11 my $percent = $sim->[2];
764 : mkubal 1.4 my $evalue = $sim->[10];
765 : arodri7 1.11 my $qfrom = $sim->[6];
766 :     my $qto = $sim->[7];
767 :     my $hfrom = $sim->[8];
768 :     my $hto = $sim->[9];
769 :     my $qlength = $sim->[12];
770 :     my $hlength = $sim->[13];
771 :     my $db = get_database($hit);
772 :     my $func = $fig->function_of($hit);
773 : arodri7 1.66 my $organism;
774 :     if ($fig->org_of($hit)){
775 :     $organism = $fig->org_of($hit);
776 :     }
777 :     else{
778 :     $organism = "Data not available";
779 :     }
780 : arodri7 1.11
781 : arodri7 1.10 $dataset = {'class' => 'SIM',
782 : arodri7 1.40 'query' => $sim->[0],
783 : arodri7 1.10 'acc' => $hit,
784 : arodri7 1.11 'identity' => $percent,
785 : arodri7 1.10 'type' => 'seq',
786 :     'evalue' => $evalue,
787 : arodri7 1.11 'qstart' => $qfrom,
788 :     'qstop' => $qto,
789 :     'hstart' => $hfrom,
790 :     'hstop' => $hto,
791 :     'database' => $db,
792 :     'organism' => $organism,
793 :     'function' => $func,
794 :     'qlength' => $qlength,
795 : mkubal 1.24 'hlength' => $hlength,
796 :     'fig_id' => $fid
797 : arodri7 1.10 };
798 :    
799 :     push (@{$datasets_ref} ,$dataset);
800 : mkubal 1.3 }
801 :     }
802 :    
803 : arodri7 1.11 =head3 get_database (internal)
804 :     This method gets the database association from the sequence id
805 :    
806 :     =cut
807 :    
808 :     sub get_database{
809 :     my ($id) = (@_);
810 :    
811 :     my ($db);
812 : arodri7 1.58 if ($id =~ /^fig\|/) { $db = "SEED" }
813 : arodri7 1.11 elsif ($id =~ /^gi\|/) { $db = "NCBI" }
814 : arodri7 1.58 elsif ($id =~ /^gb\|/) { $db = "GenBank" }
815 : arodri7 1.11 elsif ($id =~ /^^[NXYZA]P_/) { $db = "RefSeq" }
816 : arodri7 1.58 elsif ($id =~ /^ref\|/) { $db = "RefSeq" }
817 : arodri7 1.11 elsif ($id =~ /^sp\|/) { $db = "SwissProt" }
818 :     elsif ($id =~ /^uni\|/) { $db = "UniProt" }
819 :     elsif ($id =~ /^tigr\|/) { $db = "TIGR" }
820 :     elsif ($id =~ /^pir\|/) { $db = "PIR" }
821 : arodri7 1.28 elsif (($id =~ /^kegg\|/) || ($id =~ /Spy/)) { $db = "KEGG" }
822 :     elsif ($id =~ /^tr\|/) { $db = "TrEMBL" }
823 : arodri7 1.11 elsif ($id =~ /^eric\|/) { $db = "ASAP" }
824 :     elsif ($id =~ /^img\|/) { $db = "JGI" }
825 : arodri7 1.58 elsif ($id =~ /^pdb\|/) { $db = "PDB" }
826 :     elsif ($id =~ /^img\|/) { $db = "IMG" }
827 :     elsif ($id =~ /^cmr\|/) { $db = "CMR" }
828 :     elsif ($id =~ /^dbj\|/) { $db = "DBJ" }
829 : arodri7 1.11
830 :     return ($db);
831 :    
832 :     }
833 :    
834 : mkubal 1.24
835 : arodri7 1.5 =head3 get_identical_proteins() (internal)
836 :    
837 :     This methods retrieves sims fills the internal data structures.
838 :    
839 :     =cut
840 :    
841 :     sub get_identical_proteins{
842 :    
843 : arodri7 1.41 my ($fid,$datasets_ref,$fig) = (@_);
844 :     #my $fig = new FIG;
845 : mkubal 1.24 my $funcs_ref;
846 : arodri7 1.5
847 :     my @maps_to = grep { $_ ne $fid and $_ !~ /^xxx/ } map { $_->[0] } $fig->mapped_prot_ids($fid);
848 :     foreach my $id (@maps_to) {
849 :     my ($tmp, $who);
850 : arodri7 1.33 if (($id ne $fid) && ($tmp = $fig->function_of($id))) {
851 : arodri7 1.11 $who = &get_database($id);
852 : mkubal 1.24 push(@$funcs_ref, [$id,$who,$tmp]);
853 : arodri7 1.5 }
854 :     }
855 :    
856 : mkubal 1.24 my $dataset = {'class' => 'IDENTICAL',
857 :     'type' => 'seq',
858 :     'fig_id' => $fid,
859 :     'rows' => $funcs_ref
860 :     };
861 :    
862 :     push (@{$datasets_ref} ,$dataset);
863 :    
864 : arodri7 1.5
865 :     }
866 :    
867 : arodri7 1.6 =head3 get_functional_coupling() (internal)
868 :    
869 :     This methods retrieves the functional coupling of a protein given a peg ID
870 :    
871 :     =cut
872 :    
873 :     sub get_functional_coupling{
874 :    
875 : arodri7 1.41 my ($fid,$datasets_ref,$fig) = (@_);
876 :     #my $fig = new FIG;
877 : arodri7 1.6 my @funcs = ();
878 :    
879 :     # initialize some variables
880 :     my($sc,$neigh);
881 :    
882 :     # set default parameters for coupling and evidence
883 :     my ($bound,$sim_cutoff,$coupling_cutoff) = (5000, 1.0e-10, 4);
884 :    
885 :     # get the fc data
886 : arodri7 1.71 my @fc_data = $fig->coupling_and_evidence($fid,$bound,$sim_cutoff,$coupling_cutoff);
887 : arodri7 1.6
888 :     # retrieve data
889 :     my @rows = map { ($sc,$neigh) = @$_;
890 :     [$sc,$neigh,scalar $fig->function_of($neigh)]
891 :     } @fc_data;
892 :    
893 : mkubal 1.24 my $dataset = {'class' => 'PCH',
894 :     'type' => 'fc',
895 :     'fig_id' => $fid,
896 :     'rows' => \@rows
897 :     };
898 :    
899 :     push (@{$datasets_ref} ,$dataset);
900 : arodri7 1.9
901 : arodri7 1.6 }
902 : arodri7 1.5
903 : mkubal 1.1 =head3 new (internal)
904 :    
905 :     Instantiate a new object.
906 :    
907 :     =cut
908 :    
909 :     sub new {
910 : mkubal 1.7 my ($class,$dataset) = @_;
911 :    
912 :     my $self = { class => $dataset->{'class'},
913 : mkubal 1.24 type => $dataset->{'type'},
914 :     fig_id => $dataset->{'fig_id'},
915 :     score => $dataset->{'score'},
916 : arodri7 1.10 };
917 : mkubal 1.7
918 :     bless($self,$class);
919 : mkubal 1.1
920 :     return $self;
921 :     }
922 :    
923 : arodri7 1.11 =head3 identity (internal)
924 :    
925 :     Returns the % identity of the similar sequence
926 :    
927 :     =cut
928 :    
929 :     sub identity {
930 :     my ($self) = @_;
931 :    
932 :     return $self->{identity};
933 :     }
934 :    
935 : mkubal 1.24 =head3 fig_id (internal)
936 :    
937 :     =cut
938 :    
939 :     sub fig_id {
940 :     my ($self) = @_;
941 :     return $self->{fig_id};
942 :     }
943 :    
944 : mkubal 1.1 =head3 feature_id (internal)
945 :    
946 :    
947 :     =cut
948 :    
949 :     sub feature_id {
950 :     my ($self) = @_;
951 :    
952 :     return $self->{feature_id};
953 :     }
954 : arodri7 1.5
955 :     =head3 id (internal)
956 :    
957 :     Returns the ID of the identical sequence
958 :    
959 :     =cut
960 :    
961 :     sub id {
962 :     my ($self) = @_;
963 :    
964 :     return $self->{id};
965 :     }
966 :    
967 :     =head3 organism (internal)
968 :    
969 :     Returns the organism of the identical sequence
970 :    
971 :     =cut
972 :    
973 :     sub organism {
974 :     my ($self) = @_;
975 :    
976 :     return $self->{organism};
977 :     }
978 :    
979 : arodri7 1.9 =head3 function (internal)
980 :    
981 :     Returns the function of the identical sequence
982 :    
983 :     =cut
984 :    
985 :     sub function {
986 :     my ($self) = @_;
987 :    
988 :     return $self->{function};
989 :     }
990 :    
991 : arodri7 1.5 =head3 database (internal)
992 :    
993 :     Returns the database of the identical sequence
994 :    
995 :     =cut
996 :    
997 :     sub database {
998 :     my ($self) = @_;
999 :    
1000 :     return $self->{database};
1001 :     }
1002 :    
1003 : mkubal 1.20 ############################################################
1004 :     ############################################################
1005 :     package Observation::PDB;
1006 :    
1007 :     use base qw(Observation);
1008 :    
1009 :     sub new {
1010 :    
1011 :     my ($class,$dataset) = @_;
1012 :     my $self = $class->SUPER::new($dataset);
1013 :     $self->{acc} = $dataset->{'acc'};
1014 :     $self->{evalue} = $dataset->{'evalue'};
1015 :     $self->{start} = $dataset->{'start'};
1016 :     $self->{stop} = $dataset->{'stop'};
1017 :     bless($self,$class);
1018 :     return $self;
1019 :     }
1020 :    
1021 :     =head3 display()
1022 :    
1023 :     displays data stored in best_PDB attribute and in Ontology server for given PDB id
1024 :    
1025 :     =cut
1026 :    
1027 :     sub display{
1028 : arodri7 1.41 my ($self,$gd,$fig) = @_;
1029 : mkubal 1.20
1030 : mkubal 1.24 my $fid = $self->fig_id;
1031 : paczian 1.52 my $dbmaster = DBMaster->new(-database =>'Ontology',
1032 : arodri7 1.74 -host => $WebConfig::DBHOST,
1033 :     -user => $WebConfig::DBUSER,
1034 :     -password => $WebConfig::DBPWD);
1035 : mkubal 1.20
1036 :     my $acc = $self->acc;
1037 :    
1038 :     my ($pdb_description,$pdb_source,$pdb_ligand);
1039 :     my $pdb_objs = $dbmaster->pdb->get_objects( { 'id' => $acc } );
1040 :     if(!scalar(@$pdb_objs)){
1041 :     $pdb_description = "not available";
1042 :     $pdb_source = "not available";
1043 :     $pdb_ligand = "not available";
1044 :     }
1045 :     else{
1046 :     my $pdb_obj = $pdb_objs->[0];
1047 :     $pdb_description = $pdb_obj->description;
1048 :     $pdb_source = $pdb_obj->source;
1049 :     $pdb_ligand = $pdb_obj->ligand;
1050 :     }
1051 : arodri7 1.6
1052 : mkubal 1.20 my $lines = [];
1053 :     my $line_data = [];
1054 :     my $line_config = { 'title' => "PDB hit for $fid",
1055 : paczian 1.47 'hover_title' => 'PDB',
1056 : mkubal 1.20 'short_title' => "best PDB",
1057 :     'basepair_offset' => '1' };
1058 :    
1059 : arodri7 1.41 #my $fig = new FIG;
1060 : mkubal 1.20 my $seq = $fig->get_translation($fid);
1061 :     my $fid_stop = length($seq);
1062 :    
1063 :     my $fid_element_hash = {
1064 :     "title" => $fid,
1065 :     "start" => '1',
1066 :     "end" => $fid_stop,
1067 :     "color"=> '1',
1068 :     "zlayer" => '1'
1069 :     };
1070 :    
1071 :     push(@$line_data,$fid_element_hash);
1072 :    
1073 :     my $links_list = [];
1074 :     my $descriptions = [];
1075 :    
1076 :     my $name;
1077 :     $name = {"title" => 'id',
1078 :     "value" => $acc};
1079 :     push(@$descriptions,$name);
1080 :    
1081 :     my $description;
1082 :     $description = {"title" => 'pdb description',
1083 :     "value" => $pdb_description};
1084 :     push(@$descriptions,$description);
1085 :    
1086 :     my $score;
1087 :     $score = {"title" => "score",
1088 :     "value" => $self->evalue};
1089 :     push(@$descriptions,$score);
1090 :    
1091 :     my $start_stop;
1092 :     my $start_stop_value = $self->start."_".$self->stop;
1093 :     $start_stop = {"title" => "start-stop",
1094 :     "value" => $start_stop_value};
1095 :     push(@$descriptions,$start_stop);
1096 :    
1097 :     my $source;
1098 :     $source = {"title" => "source",
1099 :     "value" => $pdb_source};
1100 :     push(@$descriptions,$source);
1101 :    
1102 :     my $ligand;
1103 :     $ligand = {"title" => "pdb ligand",
1104 :     "value" => $pdb_ligand};
1105 :     push(@$descriptions,$ligand);
1106 :    
1107 :     my $link;
1108 :     my $link_url ="http://www.rcsb.org/pdb/explore/explore.do?structureId=".$acc;
1109 :    
1110 :     $link = {"link_title" => $acc,
1111 :     "link" => $link_url};
1112 :     push(@$links_list,$link);
1113 :    
1114 :     my $pdb_element_hash = {
1115 :     "title" => "PDB homology",
1116 :     "start" => $self->start,
1117 :     "end" => $self->stop,
1118 :     "color"=> '6',
1119 :     "zlayer" => '3',
1120 :     "links_list" => $links_list,
1121 :     "description" => $descriptions};
1122 :    
1123 :     push(@$line_data,$pdb_element_hash);
1124 :     $gd->add_line($line_data, $line_config);
1125 :    
1126 :     return $gd;
1127 :     }
1128 :    
1129 :     1;
1130 : arodri7 1.11
1131 : arodri7 1.9 ############################################################
1132 :     ############################################################
1133 :     package Observation::Identical;
1134 :    
1135 :     use base qw(Observation);
1136 :    
1137 :     sub new {
1138 :    
1139 :     my ($class,$dataset) = @_;
1140 :     my $self = $class->SUPER::new($dataset);
1141 : mkubal 1.24 $self->{rows} = $dataset->{'rows'};
1142 :    
1143 : arodri7 1.9 bless($self,$class);
1144 :     return $self;
1145 :     }
1146 :    
1147 : mkubal 1.24 =head3 display_table()
1148 : arodri7 1.6
1149 :     If available use the function specified here to display the "raw" observation.
1150 :     This code will display a table for the identical protein
1151 :    
1152 :    
1153 : arodri7 1.9 B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evi
1154 :     dence.
1155 : arodri7 1.6
1156 :     =cut
1157 :    
1158 :    
1159 : mkubal 1.24 sub display_table{
1160 : arodri7 1.41 my ($self,$fig) = @_;
1161 : mkubal 1.24
1162 : arodri7 1.41 #my $fig = new FIG;
1163 : mkubal 1.24 my $fid = $self->fig_id;
1164 :     my $rows = $self->rows;
1165 :     my $cgi = new CGI;
1166 : arodri7 1.6 my $all_domains = [];
1167 :     my $count_identical = 0;
1168 : arodri7 1.9 my $content;
1169 : mkubal 1.24 foreach my $row (@$rows) {
1170 :     my $id = $row->[0];
1171 :     my $who = $row->[1];
1172 :     my $assignment = $row->[2];
1173 : arodri7 1.66 my $organism = "Data not available";
1174 :     if ($fig->org_of($id)){
1175 :     $organism = $fig->org_of($id);
1176 :     }
1177 : arodri7 1.9 my $single_domain = [];
1178 : mkubal 1.24 push(@$single_domain,$who);
1179 : paczian 1.64 push(@$single_domain,"<a href='?page=Annotation&feature=$id'>$id</a>");
1180 : mkubal 1.24 push(@$single_domain,$organism);
1181 :     push(@$single_domain,$assignment);
1182 : arodri7 1.9 push(@$all_domains,$single_domain);
1183 : mkubal 1.24 $count_identical++;
1184 : arodri7 1.6 }
1185 :    
1186 :     if ($count_identical >0){
1187 : arodri7 1.9 $content = $all_domains;
1188 : arodri7 1.6 }
1189 :     else{
1190 : arodri7 1.9 $content = "<p>This PEG does not have any essentially identical proteins</p>";
1191 : arodri7 1.6 }
1192 :     return ($content);
1193 :     }
1194 : mkubal 1.7
1195 : arodri7 1.9 1;
1196 :    
1197 :     #########################################
1198 :     #########################################
1199 :     package Observation::FC;
1200 :     1;
1201 :    
1202 :     use base qw(Observation);
1203 :    
1204 :     sub new {
1205 :    
1206 :     my ($class,$dataset) = @_;
1207 :     my $self = $class->SUPER::new($dataset);
1208 : mkubal 1.24 $self->{rows} = $dataset->{'rows'};
1209 : arodri7 1.9
1210 :     bless($self,$class);
1211 :     return $self;
1212 :     }
1213 :    
1214 : mkubal 1.24 =head3 display_table()
1215 : arodri7 1.9
1216 :     If available use the function specified here to display the "raw" observation.
1217 :     This code will display a table for the identical protein
1218 :    
1219 :    
1220 :     B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evi
1221 :     dence.
1222 :    
1223 :     =cut
1224 :    
1225 : mkubal 1.24 sub display_table {
1226 : arodri7 1.9
1227 : arodri7 1.41 my ($self,$dataset,$fig) = @_;
1228 : mkubal 1.24 my $fid = $self->fig_id;
1229 :     my $rows = $self->rows;
1230 :     my $cgi = new CGI;
1231 : arodri7 1.9 my $functional_data = [];
1232 :     my $count = 0;
1233 :     my $content;
1234 :    
1235 : mkubal 1.24 foreach my $row (@$rows) {
1236 : arodri7 1.9 my $single_domain = [];
1237 :     $count++;
1238 :    
1239 :     # construct the score link
1240 : mkubal 1.24 my $score = $row->[0];
1241 :     my $toid = $row->[1];
1242 : paczian 1.44 my $link = $cgi->url(-relative => 1) . "?page=Annotation&feature=$fid";
1243 :     my $sc_link = "<a href='$link'>$score</a>";
1244 : arodri7 1.9
1245 :     push(@$single_domain,$sc_link);
1246 : mkubal 1.24 push(@$single_domain,$row->[1]);
1247 :     push(@$single_domain,$row->[2]);
1248 : arodri7 1.9 push(@$functional_data,$single_domain);
1249 :     }
1250 :    
1251 :     if ($count >0){
1252 :     $content = $functional_data;
1253 :     }
1254 :     else
1255 :     {
1256 :     $content = "<p>This PEG does not have any functional coupling</p>";
1257 :     }
1258 :     return ($content);
1259 :     }
1260 :    
1261 :    
1262 :     #########################################
1263 :     #########################################
1264 : mkubal 1.7 package Observation::Domain;
1265 :    
1266 :     use base qw(Observation);
1267 :    
1268 :     sub new {
1269 :    
1270 :     my ($class,$dataset) = @_;
1271 :     my $self = $class->SUPER::new($dataset);
1272 :     $self->{evalue} = $dataset->{'evalue'};
1273 :     $self->{acc} = $dataset->{'acc'};
1274 :     $self->{start} = $dataset->{'start'};
1275 :     $self->{stop} = $dataset->{'stop'};
1276 :    
1277 :     bless($self,$class);
1278 :     return $self;
1279 :     }
1280 :    
1281 :     sub display {
1282 :     my ($thing,$gd) = @_;
1283 :     my $lines = [];
1284 : arodri7 1.27 # my $line_config = { 'title' => $thing->acc,
1285 :     # 'short_title' => $thing->type,
1286 :     # 'basepair_offset' => '1' };
1287 : mkubal 1.7 my $color = "4";
1288 :    
1289 :     my $line_data = [];
1290 :     my $links_list = [];
1291 :     my $descriptions = [];
1292 : mkubal 1.19
1293 :     my $db_and_id = $thing->acc;
1294 :     my ($db,$id) = split("::",$db_and_id);
1295 : arodri7 1.41
1296 : paczian 1.52 my $dbmaster = DBMaster->new(-database =>'Ontology',
1297 :     -host => $WebConfig::DBHOST,
1298 :     -user => $WebConfig::DBUSER,
1299 :     -password => $WebConfig::DBPWD);
1300 : mkubal 1.7
1301 : mkubal 1.19 my ($name_title,$name_value,$description_title,$description_value);
1302 : arodri7 1.74
1303 :     if($db =~ /PFAM/){
1304 :     my $new_id;
1305 :     if ($id =~ /_/){
1306 :     ($new_id) = ($id) =~ /(.*?)_/;
1307 : mkubal 1.19 }
1308 :     else{
1309 : arodri7 1.74 $new_id = $id;
1310 : mkubal 1.19 }
1311 : arodri7 1.74
1312 : arodri7 1.50 my $pfam_objs = $dbmaster->pfam->get_objects( { 'id' => $new_id } );
1313 : arodri7 1.41 if(!scalar(@$pfam_objs)){
1314 :     $name_title = "name";
1315 :     $name_value = "not available";
1316 :     $description_title = "description";
1317 :     $description_value = "not available";
1318 :     }
1319 :     else{
1320 :     my $pfam_obj = $pfam_objs->[0];
1321 : arodri7 1.50 $name_title = "name";
1322 :     $name_value = $pfam_obj->term;
1323 : arodri7 1.41 #$description_title = "description";
1324 :     #$description_value = $pfam_obj->description;
1325 :     }
1326 :     }
1327 :    
1328 :     my $short_title = $thing->acc;
1329 :     $short_title =~ s/::/ - /ig;
1330 : arodri7 1.50 my $new_short_title=$short_title;
1331 :     if ($short_title =~ /interpro/){
1332 :     ($new_short_title) = ($short_title) =~ /(.*?)_/;
1333 :     }
1334 : arodri7 1.41 my $line_config = { 'title' => $name_value,
1335 : paczian 1.47 'hover_title', => 'Domain',
1336 : arodri7 1.50 'short_title' => $new_short_title,
1337 : arodri7 1.27 'basepair_offset' => '1' };
1338 : mkubal 1.7
1339 : mkubal 1.19 my $name;
1340 : arodri7 1.50 my ($new_id) = ($id) =~ /(.*?)_/;
1341 : arodri7 1.41 $name = {"title" => $db,
1342 : arodri7 1.50 "value" => $new_id};
1343 : mkubal 1.19 push(@$descriptions,$name);
1344 :    
1345 : arodri7 1.41 # my $description;
1346 :     # $description = {"title" => $description_title,
1347 :     # "value" => $description_value};
1348 :     # push(@$descriptions,$description);
1349 : mkubal 1.7
1350 :     my $score;
1351 :     $score = {"title" => "score",
1352 :     "value" => $thing->evalue};
1353 :     push(@$descriptions,$score);
1354 :    
1355 : arodri7 1.41 my $location;
1356 :     $location = {"title" => "location",
1357 :     "value" => $thing->start . " - " . $thing->stop};
1358 :     push(@$descriptions,$location);
1359 :    
1360 : mkubal 1.7 my $link_id;
1361 : arodri7 1.41 if ($thing->acc =~/::(.*)/){
1362 : mkubal 1.7 $link_id = $1;
1363 :     }
1364 :    
1365 :     my $link;
1366 : mkubal 1.12 my $link_url;
1367 : arodri7 1.74 # if ($thing->class eq "CDD"){$link_url = "http://0-www.ncbi.nlm.nih.gov.library.vu.edu.au:80/Structure/cdd/cddsrv.cgi?uid=$link_id"}
1368 :     if($thing->class eq "PFAM"){$link_url = "http://pfam.sanger.ac.uk/family?acc=$link_id"}
1369 : mkubal 1.12 else{$link_url = "NO_URL"}
1370 :    
1371 : mkubal 1.7 $link = {"link_title" => $thing->acc,
1372 : mkubal 1.12 "link" => $link_url};
1373 : mkubal 1.7 push(@$links_list,$link);
1374 :    
1375 :     my $element_hash = {
1376 : arodri7 1.41 "title" => $name_value,
1377 : mkubal 1.7 "start" => $thing->start,
1378 :     "end" => $thing->stop,
1379 :     "color"=> $color,
1380 :     "zlayer" => '2',
1381 :     "links_list" => $links_list,
1382 :     "description" => $descriptions};
1383 :    
1384 :     push(@$line_data,$element_hash);
1385 :     $gd->add_line($line_data, $line_config);
1386 :    
1387 :     return $gd;
1388 :    
1389 :     }
1390 : arodri7 1.28
1391 :     sub display_table {
1392 :     my ($self,$dataset) = @_;
1393 :     my $cgi = new CGI;
1394 :     my $data = [];
1395 :     my $count = 0;
1396 :     my $content;
1397 : arodri7 1.74 my $seen = {};
1398 : arodri7 1.28
1399 :     foreach my $thing (@$dataset) {
1400 :     next if ($thing->type !~ /dom/);
1401 :     my $single_domain = [];
1402 :     $count++;
1403 :    
1404 :     my $db_and_id = $thing->acc;
1405 :     my ($db,$id) = split("::",$db_and_id);
1406 :    
1407 : paczian 1.52 my $dbmaster = DBMaster->new(-database =>'Ontology',
1408 :     -host => $WebConfig::DBHOST,
1409 :     -user => $WebConfig::DBUSER,
1410 :     -password => $WebConfig::DBPWD);
1411 : arodri7 1.28
1412 :     my ($name_title,$name_value,$description_title,$description_value);
1413 : arodri7 1.74
1414 :     my $new_id;
1415 :     if($db =~ /PFAM/){
1416 :     if ($id =~ /_/){
1417 :     ($new_id) = ($id) =~ /(.*?)_/;
1418 : arodri7 1.28 }
1419 :     else{
1420 : arodri7 1.74 $new_id = $id;
1421 : arodri7 1.28 }
1422 : arodri7 1.74
1423 :     next if ($seen->{$new_id});
1424 :     $seen->{$new_id}=1;
1425 :    
1426 : arodri7 1.51 my $pfam_objs = $dbmaster->pfam->get_objects( { 'id' => $new_id } );
1427 : arodri7 1.74 # print STDERR "VALUES: " . $pfam_objs . "\n";
1428 : arodri7 1.51 if(!scalar(@$pfam_objs)){
1429 :     $name_title = "name";
1430 :     $name_value = "not available";
1431 :     $description_title = "description";
1432 :     $description_value = "not available";
1433 :     }
1434 :     else{
1435 :     my $pfam_obj = $pfam_objs->[0];
1436 :     $name_title = "name";
1437 :     $name_value = $pfam_obj->term;
1438 :     #$description_title = "description";
1439 :     #$description_value = $pfam_obj->description;
1440 :     }
1441 :     }
1442 : arodri7 1.28
1443 :     my $location = $thing->start . " - " . $thing->stop;
1444 :    
1445 :     push(@$single_domain,$db);
1446 : arodri7 1.74 push(@$single_domain,$new_id);
1447 : arodri7 1.28 push(@$single_domain,$name_value);
1448 :     push(@$single_domain,$location);
1449 :     push(@$single_domain,$thing->evalue);
1450 :     push(@$single_domain,$description_value);
1451 :     push(@$data,$single_domain);
1452 :     }
1453 :    
1454 :     if ($count >0){
1455 :     $content = $data;
1456 :     }
1457 :     else
1458 :     {
1459 :     $content = "<p>This PEG does not have any similarities to domains</p>";
1460 :     }
1461 :     }
1462 :    
1463 : mkubal 1.7
1464 : arodri7 1.10 #########################################
1465 :     #########################################
1466 : mkubal 1.12 package Observation::Location;
1467 :    
1468 :     use base qw(Observation);
1469 :    
1470 :     sub new {
1471 :    
1472 :     my ($class,$dataset) = @_;
1473 :     my $self = $class->SUPER::new($dataset);
1474 :     $self->{cleavage_prob} = $dataset->{'cleavage_prob'};
1475 :     $self->{cleavage_loc} = $dataset->{'cleavage_loc'};
1476 :     $self->{signal_peptide_score} = $dataset->{'signal_peptide_score'};
1477 :     $self->{cello_location} = $dataset->{'cello_location'};
1478 :     $self->{cello_score} = $dataset->{'cello_score'};
1479 :     $self->{tmpred_score} = $dataset->{'tmpred_score'};
1480 :     $self->{tmpred_locations} = $dataset->{'tmpred_locations'};
1481 : mkubal 1.30 $self->{phobius_signal_location} = $dataset->{'phobius_signal_location'};
1482 :     $self->{phobius_tm_locations} = $dataset->{'phobius_tm_locations'};
1483 : mkubal 1.12
1484 :     bless($self,$class);
1485 :     return $self;
1486 :     }
1487 :    
1488 : mkubal 1.36 sub display_cello {
1489 : arodri7 1.45 my ($thing) = @_;
1490 : mkubal 1.36 my $html;
1491 :     my $cello_location = $thing->cello_location;
1492 :     my $cello_score = $thing->cello_score;
1493 :     if($cello_location){
1494 : arodri7 1.40 $html .= "<p><font type=verdana size=-2>Subcellular location prediction: $cello_location, score: $cello_score</font> </p>";
1495 :     #$html .= "<p>CELLO score: $cello_score </p>";
1496 : mkubal 1.36 }
1497 :     return ($html);
1498 :     }
1499 :    
1500 : mkubal 1.12 sub display {
1501 : arodri7 1.41 my ($thing,$gd,$fig) = @_;
1502 : mkubal 1.12
1503 : mkubal 1.24 my $fid = $thing->fig_id;
1504 : arodri7 1.41 #my $fig= new FIG;
1505 : mkubal 1.12 my $length = length($fig->get_translation($fid));
1506 :    
1507 :     my $cleavage_prob;
1508 :     if($thing->cleavage_prob){$cleavage_prob = $thing->cleavage_prob;}
1509 :     my ($cleavage_loc_begin,$cleavage_loc_end) = split("-",$thing->cleavage_loc);
1510 :     my $signal_peptide_score = $thing->signal_peptide_score;
1511 :     my $cello_location = $thing->cello_location;
1512 :     my $cello_score = $thing->cello_score;
1513 :     my $tmpred_score = $thing->tmpred_score;
1514 :     my @tmpred_locations = split(",",$thing->tmpred_locations);
1515 :    
1516 : mkubal 1.30 my $phobius_signal_location = $thing->phobius_signal_location;
1517 :     my @phobius_tm_locations = split(",",$thing->phobius_tm_locations);
1518 :    
1519 : mkubal 1.12 my $lines = [];
1520 :    
1521 :     #color is
1522 : arodri7 1.28 my $color = "6";
1523 : mkubal 1.36
1524 :    
1525 : arodri7 1.28
1526 : parrello 1.70 # if($cello_location){
1527 :     # my $cello_descriptions = [];
1528 :     # my $line_data =[];
1529 :     #
1530 :     # my $line_config = { 'title' => 'Localization Evidence',
1531 :     # 'short_title' => 'CELLO',
1532 :     # 'hover_title' => 'Localization',
1533 :     # 'basepair_offset' => '1' };
1534 :     #
1535 :     # my $description_cello_location = {"title" => 'Best Cello Location',
1536 :     # "value" => $cello_location};
1537 :     #
1538 :     # push(@$cello_descriptions,$description_cello_location);
1539 :     #
1540 :     # my $description_cello_score = {"title" => 'Cello Score',
1541 :     # "value" => $cello_score};
1542 :     #
1543 :     # push(@$cello_descriptions,$description_cello_score);
1544 :     #
1545 :     # my $element_hash = {
1546 :     # "title" => "CELLO",
1547 :     # "color"=> $color,
1548 :     # "start" => "1",
1549 :     # "end" => $length + 1,
1550 :     # "zlayer" => '1',
1551 :     # "description" => $cello_descriptions};
1552 :     #
1553 :     # push(@$line_data,$element_hash);
1554 :     # $gd->add_line($line_data, $line_config);
1555 :     # }
1556 :     #
1557 :     # $color = "2";
1558 :     # if($tmpred_score){
1559 :     # my $line_data =[];
1560 :     # my $line_config = { 'title' => 'Localization Evidence',
1561 :     # 'short_title' => 'Transmembrane',
1562 :     # 'basepair_offset' => '1' };
1563 :     #
1564 :     # foreach my $tmpred (@tmpred_locations){
1565 :     # my $descriptions = [];
1566 :     # my ($begin,$end) =split("-",$tmpred);
1567 :     # my $description_tmpred_score = {"title" => 'TMPRED score',
1568 :     # "value" => $tmpred_score};
1569 :     #
1570 :     # push(@$descriptions,$description_tmpred_score);
1571 :     #
1572 :     # my $element_hash = {
1573 :     # "title" => "transmembrane location",
1574 :     # "start" => $begin + 1,
1575 :     # "end" => $end + 1,
1576 :     # "color"=> $color,
1577 :     # "zlayer" => '5',
1578 :     # "type" => 'box',
1579 :     # "description" => $descriptions};
1580 :     #
1581 :     # push(@$line_data,$element_hash);
1582 :     #
1583 :     # }
1584 :     # $gd->add_line($line_data, $line_config);
1585 :     # }
1586 : arodri7 1.28
1587 : mkubal 1.12
1588 : mkubal 1.30 if((scalar(@phobius_tm_locations) > 0) || $phobius_signal_location){
1589 :     my $line_data =[];
1590 : arodri7 1.40 my $line_config = { 'title' => 'Localization Evidence, Transmembrane and Signal Peptide',
1591 :     'short_title' => 'TM and SP',
1592 : paczian 1.48 'hover_title' => 'Localization',
1593 : mkubal 1.30 'basepair_offset' => '1' };
1594 :    
1595 :     foreach my $tm_loc (@phobius_tm_locations){
1596 :     my $descriptions = [];
1597 : arodri7 1.40 my $description_phobius_tm_locations = {"title" => 'transmembrane location',
1598 : mkubal 1.30 "value" => $tm_loc};
1599 :     push(@$descriptions,$description_phobius_tm_locations);
1600 :    
1601 :     my ($begin,$end) =split("-",$tm_loc);
1602 :    
1603 :     my $element_hash = {
1604 : arodri7 1.40 "title" => "Phobius",
1605 : mkubal 1.30 "start" => $begin + 1,
1606 :     "end" => $end + 1,
1607 :     "color"=> '6',
1608 :     "zlayer" => '4',
1609 :     "type" => 'bigbox',
1610 :     "description" => $descriptions};
1611 :    
1612 :     push(@$line_data,$element_hash);
1613 :    
1614 :     }
1615 :    
1616 :     if($phobius_signal_location){
1617 :     my $descriptions = [];
1618 :     my $description_phobius_signal_location = {"title" => 'Phobius Signal Location',
1619 :     "value" => $phobius_signal_location};
1620 :     push(@$descriptions,$description_phobius_signal_location);
1621 :    
1622 :    
1623 :     my ($begin,$end) =split("-",$phobius_signal_location);
1624 :     my $element_hash = {
1625 :     "title" => "phobius signal locations",
1626 :     "start" => $begin + 1,
1627 :     "end" => $end + 1,
1628 :     "color"=> '1',
1629 :     "zlayer" => '5',
1630 :     "type" => 'box',
1631 :     "description" => $descriptions};
1632 :     push(@$line_data,$element_hash);
1633 :     }
1634 :    
1635 :     $gd->add_line($line_data, $line_config);
1636 :     }
1637 :    
1638 : arodri7 1.28
1639 : parrello 1.70 # $color = "1";
1640 :     # if($signal_peptide_score){
1641 :     # my $line_data = [];
1642 :     # my $descriptions = [];
1643 :     #
1644 :     # my $line_config = { 'title' => 'Localization Evidence',
1645 :     # 'short_title' => 'SignalP',
1646 :     # 'hover_title' => 'Localization',
1647 :     # 'basepair_offset' => '1' };
1648 :     #
1649 :     # my $description_signal_peptide_score = {"title" => 'signal peptide score',
1650 :     # "value" => $signal_peptide_score};
1651 :     #
1652 :     # push(@$descriptions,$description_signal_peptide_score);
1653 :     #
1654 :     # my $description_cleavage_prob = {"title" => 'cleavage site probability',
1655 :     # "value" => $cleavage_prob};
1656 :     #
1657 :     # push(@$descriptions,$description_cleavage_prob);
1658 :     #
1659 :     # my $element_hash = {
1660 :     # "title" => "SignalP",
1661 :     # "start" => $cleavage_loc_begin - 2,
1662 :     # "end" => $cleavage_loc_end + 1,
1663 :     # "type" => 'bigbox',
1664 :     # "color"=> $color,
1665 :     # "zlayer" => '10',
1666 :     # "description" => $descriptions};
1667 :     #
1668 :     # push(@$line_data,$element_hash);
1669 :     # $gd->add_line($line_data, $line_config);
1670 :     # }
1671 : mkubal 1.12
1672 : arodri7 1.40
1673 : mkubal 1.12 return ($gd);
1674 :    
1675 :     }
1676 :    
1677 :     sub cleavage_loc {
1678 :     my ($self) = @_;
1679 :    
1680 :     return $self->{cleavage_loc};
1681 :     }
1682 :    
1683 :     sub cleavage_prob {
1684 :     my ($self) = @_;
1685 :    
1686 :     return $self->{cleavage_prob};
1687 :     }
1688 :    
1689 :     sub signal_peptide_score {
1690 :     my ($self) = @_;
1691 :    
1692 :     return $self->{signal_peptide_score};
1693 :     }
1694 :    
1695 :     sub tmpred_score {
1696 :     my ($self) = @_;
1697 :    
1698 :     return $self->{tmpred_score};
1699 :     }
1700 :    
1701 :     sub tmpred_locations {
1702 :     my ($self) = @_;
1703 :    
1704 :     return $self->{tmpred_locations};
1705 :     }
1706 :    
1707 :     sub cello_location {
1708 :     my ($self) = @_;
1709 :    
1710 :     return $self->{cello_location};
1711 :     }
1712 :    
1713 :     sub cello_score {
1714 :     my ($self) = @_;
1715 :    
1716 :     return $self->{cello_score};
1717 :     }
1718 :    
1719 : mkubal 1.30 sub phobius_signal_location {
1720 :     my ($self) = @_;
1721 :     return $self->{phobius_signal_location};
1722 :     }
1723 :    
1724 :     sub phobius_tm_locations {
1725 :     my ($self) = @_;
1726 :     return $self->{phobius_tm_locations};
1727 :     }
1728 :    
1729 :    
1730 : mkubal 1.12
1731 :     #########################################
1732 :     #########################################
1733 : arodri7 1.10 package Observation::Sims;
1734 :    
1735 :     use base qw(Observation);
1736 :    
1737 :     sub new {
1738 :    
1739 :     my ($class,$dataset) = @_;
1740 :     my $self = $class->SUPER::new($dataset);
1741 : arodri7 1.11 $self->{identity} = $dataset->{'identity'};
1742 : arodri7 1.10 $self->{acc} = $dataset->{'acc'};
1743 : arodri7 1.40 $self->{query} = $dataset->{'query'};
1744 : arodri7 1.10 $self->{evalue} = $dataset->{'evalue'};
1745 : arodri7 1.11 $self->{qstart} = $dataset->{'qstart'};
1746 :     $self->{qstop} = $dataset->{'qstop'};
1747 :     $self->{hstart} = $dataset->{'hstart'};
1748 :     $self->{hstop} = $dataset->{'hstop'};
1749 :     $self->{database} = $dataset->{'database'};
1750 :     $self->{organism} = $dataset->{'organism'};
1751 :     $self->{function} = $dataset->{'function'};
1752 :     $self->{qlength} = $dataset->{'qlength'};
1753 :     $self->{hlength} = $dataset->{'hlength'};
1754 : arodri7 1.10
1755 :     bless($self,$class);
1756 :     return $self;
1757 :     }
1758 :    
1759 : arodri7 1.25 =head3 display()
1760 :    
1761 :     If available use the function specified here to display a graphical observation.
1762 :     This code will display a graphical view of the similarities using the genome drawer object
1763 :    
1764 :     =cut
1765 :    
1766 :     sub display {
1767 : arodri7 1.58 my ($self,$gd,$thing,$fig,$base_start,$in_subs,$cgi) = @_;
1768 : arodri7 1.25
1769 : arodri7 1.58 # declare variables
1770 :     my $window_size = $gd->window_size;
1771 :     my $peg = $thing->acc;
1772 :     my $query_id = $thing->query;
1773 :     my $organism = $thing->organism;
1774 :     my $abbrev_name = $fig->abbrev($organism);
1775 :     if (!$organism){
1776 :     $organism = $peg;
1777 :     $abbrev_name = $peg;
1778 :     }
1779 :     my $genome = $fig->genome_of($peg);
1780 :     my ($org_tax) = ($genome) =~ /(.*)\./;
1781 :     my $function = $thing->function;
1782 :     my $query_start = $thing->qstart;
1783 :     my $query_stop = $thing->qstop;
1784 :     my $hit_start = $thing->hstart;
1785 :     my $hit_stop = $thing->hstop;
1786 :     my $ln_query = $thing->qlength;
1787 :     my $ln_hit = $thing->hlength;
1788 : arodri7 1.60 # my $query_color = match_color($query_start, $query_stop, $ln_query, 1);
1789 :     # my $hit_color = match_color($hit_start, $hit_stop, $ln_hit, 1);
1790 :     my $query_color = match_color($query_start, $query_stop, abs($query_stop-$query_start), 1);
1791 :     my $hit_color = match_color($hit_start, $hit_stop, abs($query_stop-$query_start), 1);
1792 : arodri7 1.58
1793 :     my $tax_link = "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=" . $org_tax;
1794 :    
1795 :     # hit sequence title
1796 :     my $line_config = { 'title' => "$organism [$org_tax]",
1797 :     'short_title' => "$abbrev_name",
1798 :     'title_link' => '$tax_link',
1799 : arodri7 1.60 'basepair_offset' => '0',
1800 :     'no_middle_line' => '1'
1801 : arodri7 1.58 };
1802 :    
1803 :     # query sequence title
1804 :     my $replace_id = $peg;
1805 :     $replace_id =~ s/\|/_/ig;
1806 :     my $anchor_name = "anchor_". $replace_id;
1807 :     my $query_config = { 'title' => "Query",
1808 :     'short_title' => "Query",
1809 :     'title_link' => "changeSimsLocation('$replace_id', 1)",
1810 : arodri7 1.60 'basepair_offset' => '0',
1811 :     'no_middle_line' => '1'
1812 : arodri7 1.58 };
1813 :     my $line_data = [];
1814 :     my $query_data = [];
1815 :    
1816 :     my $element_hash;
1817 :     my $hit_links_list = [];
1818 :     my $hit_descriptions = [];
1819 :     my $query_descriptions = [];
1820 :    
1821 :     # get sequence information
1822 :     # evidence link
1823 :     my $evidence_link;
1824 :     if ($peg =~ /^fig\|/){
1825 : arodri7 1.66 $evidence_link = "?page=Annotation&feature=".$peg;
1826 : arodri7 1.41 }
1827 : arodri7 1.58 else{
1828 :     my $db = &Observation::get_database($peg);
1829 :     my ($link_id) = ($peg) =~ /\|(.*)/;
1830 :     $evidence_link = &HTML::alias_url($link_id, $db);
1831 :     #print STDERR "LINK: $db $evidence_link";
1832 :     }
1833 :     my $link = {"link_title" => $peg,
1834 :     "link" => $evidence_link};
1835 :     push(@$hit_links_list,$link) if ($evidence_link);
1836 :    
1837 :     # subsystem link
1838 :     my $subs = $in_subs->{$peg} if (defined $in_subs->{$peg});
1839 :     my @subsystems;
1840 :     foreach my $array (@$subs){
1841 :     my $subsystem = $$array[0];
1842 :     push(@subsystems,$subsystem);
1843 :     my $link = {"link" => "?page=Subsystems&subsystem=$subsystem",
1844 :     "link_title" => $subsystem};
1845 :     push(@$hit_links_list,$link);
1846 :     }
1847 :    
1848 :     # blast alignment
1849 :     $link = {"link_title" => "view blast alignment",
1850 :     "link" => "$FIG_Config::cgi_url/seedviewer.cgi?page=ToolResult&tool=bl2seq&peg1=$query_id&peg2=$peg"};
1851 :     push (@$hit_links_list,$link) if ($peg =~ /^fig\|/);
1852 :    
1853 :     # description data
1854 :     my $description_function;
1855 :     $description_function = {"title" => "function",
1856 :     "value" => $function};
1857 :     push(@$hit_descriptions,$description_function);
1858 :    
1859 :     # subsystem description
1860 :     my $ss_string = join (",", @subsystems);
1861 :     $ss_string =~ s/_/ /ig;
1862 :     my $description_ss = {"title" => "subsystems",
1863 :     "value" => $ss_string};
1864 :     push(@$hit_descriptions,$description_ss);
1865 :    
1866 :     # location description
1867 :     # hit
1868 :     my $description_loc;
1869 :     $description_loc = {"title" => "Hit Location",
1870 :     "value" => $hit_start . " - " . $hit_stop};
1871 :     push(@$hit_descriptions, $description_loc);
1872 :    
1873 :     $description_loc = {"title" => "Sequence Length",
1874 :     "value" => $ln_hit};
1875 :     push(@$hit_descriptions, $description_loc);
1876 :    
1877 :     # query
1878 :     $description_loc = {"title" => "Hit Location",
1879 :     "value" => $query_start . " - " . $query_stop};
1880 :     push(@$query_descriptions, $description_loc);
1881 :    
1882 :     $description_loc = {"title" => "Sequence Length",
1883 :     "value" => $ln_query};
1884 :     push(@$query_descriptions, $description_loc);
1885 :    
1886 :    
1887 :    
1888 :     # evalue score description
1889 :     my $evalue = $thing->evalue;
1890 :     while ($evalue =~ /-0/)
1891 :     {
1892 :     my ($chunk1, $chunk2) = split(/-/, $evalue);
1893 :     $chunk2 = substr($chunk2,1);
1894 :     $evalue = $chunk1 . "-" . $chunk2;
1895 :     }
1896 :    
1897 :     my $color = &color($evalue);
1898 :     my $description_eval = {"title" => "E-Value",
1899 :     "value" => $evalue};
1900 :     push(@$hit_descriptions, $description_eval);
1901 :     push(@$query_descriptions, $description_eval);
1902 :    
1903 :     my $identity = $self->identity;
1904 :     my $description_identity = {"title" => "Identity",
1905 :     "value" => $identity};
1906 :     push(@$hit_descriptions, $description_identity);
1907 :     push(@$query_descriptions, $description_identity);
1908 :    
1909 :    
1910 :     my $number = $base_start + ($query_start-$hit_start);
1911 :     #print STDERR "START: $number";
1912 :     $element_hash = {
1913 :     "title" => $query_id,
1914 :     "start" => $base_start,
1915 :     "end" => $base_start+$ln_query,
1916 :     "type"=> 'box',
1917 :     "color"=> $color,
1918 :     "zlayer" => "2",
1919 :     "links_list" => $query_links_list,
1920 :     "description" => $query_descriptions
1921 :     };
1922 :     push(@$query_data,$element_hash);
1923 :    
1924 :     $element_hash = {
1925 :     "title" => $query_id . ': HIT AREA',
1926 :     "start" => $base_start + $query_start,
1927 :     "end" => $base_start + $query_stop,
1928 :     "type"=> 'smallbox',
1929 :     "color"=> $query_color,
1930 :     "zlayer" => "3",
1931 :     "links_list" => $query_links_list,
1932 :     "description" => $query_descriptions
1933 :     };
1934 :     push(@$query_data,$element_hash);
1935 :    
1936 :     $gd->add_line($query_data, $query_config);
1937 : arodri7 1.25
1938 : arodri7 1.41
1939 : arodri7 1.58 $element_hash = {
1940 : arodri7 1.41 "title" => $peg,
1941 : arodri7 1.58 "start" => $base_start + ($query_start-$hit_start),
1942 :     "end" => $base_start + (($query_start-$hit_start)+$ln_hit),
1943 : arodri7 1.41 "type"=> 'box',
1944 :     "color"=> $color,
1945 :     "zlayer" => "2",
1946 : arodri7 1.58 "links_list" => $hit_links_list,
1947 :     "description" => $hit_descriptions
1948 : arodri7 1.41 };
1949 : arodri7 1.58 push(@$line_data,$element_hash);
1950 :    
1951 :     $element_hash = {
1952 :     "title" => $peg . ': HIT AREA',
1953 :     "start" => $base_start + $query_start,
1954 :     "end" => $base_start + $query_stop,
1955 :     "type"=> 'smallbox',
1956 :     "color"=> $hit_color,
1957 :     "zlayer" => "3",
1958 :     "links_list" => $hit_links_list,
1959 :     "description" => $hit_descriptions
1960 :     };
1961 :     push(@$line_data,$element_hash);
1962 :    
1963 :     $gd->add_line($line_data, $line_config);
1964 :    
1965 :     my $breaker = [];
1966 :     my $breaker_hash = {};
1967 :     my $breaker_config = { 'no_middle_line' => "1" };
1968 :    
1969 :     push (@$breaker, $breaker_hash);
1970 :     $gd->add_line($breaker, $breaker_config);
1971 :    
1972 : arodri7 1.25 return ($gd);
1973 :     }
1974 :    
1975 : mkubal 1.34 =head3 display_domain_composition()
1976 :    
1977 :     If available use the function specified here to display a graphical observation of the CDD(later Pfam or selected) domains that occur in the set of similar proteins
1978 :    
1979 :     =cut
1980 :    
1981 :     sub display_domain_composition {
1982 : arodri7 1.41 my ($self,$gd,$fig) = @_;
1983 : mkubal 1.34
1984 : arodri7 1.45 #$fig = new FIG;
1985 : mkubal 1.34 my $peg = $self->acc;
1986 :    
1987 :     my $line_data = [];
1988 :     my $links_list = [];
1989 :     my $descriptions = [];
1990 :    
1991 :     my @domain_query_results =$fig->get_attributes($peg,"CDD");
1992 : arodri7 1.45 #my @domain_query_results = ();
1993 : mkubal 1.34 foreach $dqr (@domain_query_results){
1994 :     my $key = @$dqr[1];
1995 :     my @parts = split("::",$key);
1996 :     my $db = $parts[0];
1997 :     my $id = $parts[1];
1998 :     my $val = @$dqr[2];
1999 :     my $from;
2000 :     my $to;
2001 :     my $evalue;
2002 :    
2003 :     if($val =~/^(\d+\.\d+|0\.0);(\d+)-(\d+)/){
2004 :     my $raw_evalue = $1;
2005 :     $from = $2;
2006 :     $to = $3;
2007 :     if($raw_evalue =~/(\d+)\.(\d+)/){
2008 :     my $part2 = 1000 - $1;
2009 :     my $part1 = $2/100;
2010 :     $evalue = $part1."e-".$part2;
2011 :     }
2012 :     else{
2013 :     $evalue = "0.0";
2014 :     }
2015 :     }
2016 :    
2017 : paczian 1.52 my $dbmaster = DBMaster->new(-database =>'Ontology',
2018 :     -host => $WebConfig::DBHOST,
2019 :     -user => $WebConfig::DBUSER,
2020 :     -password => $WebConfig::DBPWD);
2021 : mkubal 1.34 my ($name_value,$description_value);
2022 :    
2023 :     if($db eq "CDD"){
2024 :     my $cdd_objs = $dbmaster->cdd->get_objects( { 'id' => $id } );
2025 :     if(!scalar(@$cdd_objs)){
2026 :     $name_title = "name";
2027 :     $name_value = "not available";
2028 :     $description_title = "description";
2029 :     $description_value = "not available";
2030 :     }
2031 :     else{
2032 :     my $cdd_obj = $cdd_objs->[0];
2033 :     $name_value = $cdd_obj->term;
2034 :     $description_value = $cdd_obj->description;
2035 :     }
2036 :     }
2037 :    
2038 :     my $domain_name;
2039 :     $domain_name = {"title" => "name",
2040 : arodri7 1.45 "value" => $name_value};
2041 : mkubal 1.34 push(@$descriptions,$domain_name);
2042 :    
2043 :     my $description;
2044 :     $description = {"title" => "description",
2045 :     "value" => $description_value};
2046 :     push(@$descriptions,$description);
2047 :    
2048 :     my $score;
2049 :     $score = {"title" => "score",
2050 :     "value" => $evalue};
2051 :     push(@$descriptions,$score);
2052 :    
2053 :     my $link_id = $id;
2054 :     my $link;
2055 :     my $link_url;
2056 :     if ($db eq "CDD"){$link_url = "http://0-www.ncbi.nlm.nih.gov.library.vu.edu.au:80/Structure/cdd/cddsrv.cgi?uid=$link_id"}
2057 : arodri7 1.53 elsif($db eq "PFAM"){$link_url = "http://pfam.sanger.ac.uk/family?acc=$link_id"}
2058 : mkubal 1.34 else{$link_url = "NO_URL"}
2059 :    
2060 :     $link = {"link_title" => $name_value,
2061 :     "link" => $link_url};
2062 :     push(@$links_list,$link);
2063 :    
2064 :     my $domain_element_hash = {
2065 :     "title" => $peg,
2066 :     "start" => $from,
2067 :     "end" => $to,
2068 :     "type"=> 'box',
2069 :     "zlayer" => '4',
2070 :     "links_list" => $links_list,
2071 :     "description" => $descriptions
2072 :     };
2073 :    
2074 :     push(@$line_data,$domain_element_hash);
2075 :    
2076 :     #just one CDD domain for now, later will add option for multiple domains from selected DB
2077 :     last;
2078 :     }
2079 :    
2080 :     my $line_config = { 'title' => $peg,
2081 : paczian 1.47 'hover_title' => 'Domain',
2082 : mkubal 1.34 'short_title' => $peg,
2083 :     'basepair_offset' => '1' };
2084 : arodri7 1.45
2085 : mkubal 1.34 $gd->add_line($line_data, $line_config);
2086 :    
2087 :     return ($gd);
2088 :    
2089 :     }
2090 :    
2091 : mkubal 1.24 =head3 display_table()
2092 : arodri7 1.10
2093 :     If available use the function specified here to display the "raw" observation.
2094 :     This code will display a table for the similarities protein
2095 :    
2096 :     B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evidence.
2097 :    
2098 :     =cut
2099 :    
2100 : mkubal 1.24 sub display_table {
2101 : arodri7 1.60 my ($self,$dataset, $show_columns, $query_fid, $fig, $application, $cgi) = @_;
2102 :     my ($count, $data, $content, %box_column, $subsystems_column, $evidence_column, %e_identical, $function_color, @ids);
2103 :    
2104 :     my $scroll_list;
2105 :     foreach my $col (@$show_columns){
2106 :     push (@$scroll_list, $col->{key});
2107 :     }
2108 : arodri7 1.53
2109 : arodri7 1.60 push (@ids, $query_fid);
2110 : arodri7 1.10 foreach my $thing (@$dataset) {
2111 : arodri7 1.28 next if ($thing->class ne "SIM");
2112 :     push (@ids, $thing->acc);
2113 :     }
2114 :    
2115 : arodri7 1.60 $lineages = $fig->taxonomy_list() if (grep /lineage/, @$scroll_list);
2116 :     my @attributes = $fig->get_attributes(\@ids) if ( (grep /evidence/, @$scroll_list) || (grep /(pfam|mw)/, @$scroll_list) );
2117 : arodri7 1.35
2118 :     # get the column for the subsystems
2119 : arodri7 1.69 $subsystems_column = &get_subsystems_column(\@ids,$fig,$cgi,'hash');
2120 : arodri7 1.35
2121 :     # get the column for the evidence codes
2122 : arodri7 1.69 $evidence_column = &get_evidence_column(\@ids, \@attributes, $fig, $cgi, 'hash');
2123 : arodri7 1.35
2124 :     # get the column for pfam_domain
2125 : arodri7 1.60 $pfam_column = &get_attrb_column(\@ids, \@attributes, $fig, $cgi, 'pfam', 'PFAM', 'hash') if (grep /^pfam$/, @$scroll_list);
2126 :    
2127 :     # get the column for molecular weight
2128 :     $mw_column = &get_attrb_column(\@ids, \@attributes, $fig, $cgi, 'mw', 'molecular_weight', 'hash') if (grep /^mw$/, @$scroll_list);
2129 :    
2130 :     # get the column for organism's habitat
2131 :     my $habitat_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'habitat', 'Habitat', 'hash') if (grep /^habitat$/, @$scroll_list);
2132 :    
2133 :     # get the column for organism's temperature optimum
2134 :     my $temperature_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'temperature', 'Optimal_Temperature', 'hash') if (grep /^temperature$/, @$scroll_list);
2135 : arodri7 1.41
2136 : arodri7 1.60 # get the column for organism's temperature range
2137 :     my $temperature_range_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'temp_range', 'Temperature_Range', 'hash') if (grep /^temp_range$/, @$scroll_list);
2138 :    
2139 :     # get the column for organism's oxygen requirement
2140 :     my $oxygen_req_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'oxygen', 'Oxygen_Requirement', 'hash') if (grep /^oxygen$/, @$scroll_list);
2141 :    
2142 :     # get the column for organism's pathogenicity
2143 :     my $pathogenic_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'pathogenic', 'Pathogenic', 'hash') if (grep /^pathogenic$/, @$scroll_list);
2144 :    
2145 :     # get the column for organism's pathogenicity host
2146 :     my $pathogenic_in_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'pathogenic_in', 'Pathogenic_In', 'hash') if (grep /^pathogenic_in$/, @$scroll_list);
2147 :    
2148 :     # get the column for organism's salinity
2149 :     my $salinity_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'salinity', 'Salinity', 'hash') if (grep /^salinity$/, @$scroll_list);
2150 :    
2151 :     # get the column for organism's motility
2152 :     my $motility_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'motility', 'Motility', 'hash') if (grep /^motility$/, @$scroll_list);
2153 :    
2154 :     # get the column for organism's gram stain
2155 :     my $gram_stain_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'gram_stain', 'Gram_Stain', 'hash') if (grep /^gram_stain$/, @$scroll_list);
2156 :    
2157 :     # get the column for organism's endospores
2158 :     my $endospores_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'endospores', 'Endospores', 'hash') if (grep /^endospores$/, @$scroll_list);
2159 :    
2160 :     # get the column for organism's shape
2161 :     my $shape_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'shape', 'Shape', 'hash') if (grep /^shape$/, @$scroll_list);
2162 :    
2163 :     # get the column for organism's disease
2164 :     my $disease_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'disease', 'Disease', 'hash') if (grep /^disease$/, @$scroll_list);
2165 :    
2166 :     # get the column for organism's disease
2167 :     my $gc_content_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'gc_content', 'GC_Content', 'hash') if (grep /^gc_content$/, @$scroll_list);
2168 :    
2169 :     # get the column for transmembrane domains
2170 :     my $transmembrane_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'transmembrane', 'Phobius::transmembrane', 'hash') if (grep /^transmembrane$/, @$scroll_list);
2171 :    
2172 :     # get the column for similar to human
2173 :     my $similar_to_human_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'similar_to_human', 'similar_to_human', 'hash') if (grep /^similar_to_human$/, @$scroll_list);
2174 :    
2175 :     # get the column for signal peptide
2176 :     my $signal_peptide_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'signal_peptide', 'Phobius::signal', 'hash') if (grep /^signal_peptide$/, @$scroll_list);
2177 :    
2178 :     # get the column for transmembrane domains
2179 :     my $isoelectric_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'isoelectric', 'isoelectric_point', 'hash') if (grep /^isoelectric$/, @$scroll_list);
2180 :    
2181 :     # get the column for conserved neighborhood
2182 :     my $cons_neigh_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'conserved_neighborhood', undef, 'hash') if (grep /^conserved_neighborhood$/, @$scroll_list);
2183 :    
2184 :     # get the column for cellular location
2185 :     my $cell_location_column = &get_attrb_column(\@ids, undef, $fig, $cgi, 'cellular_location', 'PSORT::', 'hash') if (grep /^isoelectric$/, @$scroll_list);
2186 :    
2187 :     # get the aliases
2188 :     my $alias_col;
2189 :     if ( (grep /asap_id/, @$scroll_list) || (grep /ncbi_id/, @$scroll_list) ||
2190 :     (grep /refseq_id/, @$scroll_list) || (grep /swissprot_id/, @$scroll_list) ||
2191 :     (grep /uniprot_id/, @$scroll_list) || (grep /tigr_id/, @$scroll_list) ||
2192 :     (grep /kegg_id/, @$scroll_list) || (grep /pir_id/, @$scroll_list) ||
2193 :     (grep /trembl_id/, @$scroll_list) || (grep /jgi_id/, @$scroll_list) ) {
2194 :     $alias_col = &get_db_aliases(\@ids,$fig,'all',$cgi,'hash');
2195 :     }
2196 :    
2197 : arodri7 1.58 # get the colors for the function cell
2198 :     my $functions = $fig->function_of_bulk(\@ids,1);
2199 : arodri7 1.60 $functional_color = &get_function_color_cell($functions, $fig);
2200 : arodri7 1.58 my $query_function = $fig->function_of($query_fid);
2201 :    
2202 : arodri7 1.60 my %e_identical = &get_essentially_identical($query_fid,$dataset,$fig);
2203 : arodri7 1.31
2204 : olson 1.57 my $figfam_data = &FIG::get_figfams_data();
2205 : arodri7 1.55 my $figfams = new FFs($figfam_data);
2206 : arodri7 1.66 my $same_genome_flag = 0;
2207 : arodri7 1.53
2208 : arodri7 1.58 my $func_color_offset=0;
2209 : arodri7 1.60 unshift(@$dataset, $query_fid);
2210 : arodri7 1.66 for (my $thing_count=0;$thing_count<scalar @$dataset;$thing_count++){
2211 :     # foreach my $thing ( @$dataset){
2212 :     my $thing = $dataset->[$thing_count];
2213 :     my $next_thing = $dataset->[$thing_count+1] if (defined $dataset->[$thing_count+1]);
2214 :     my ($id, $taxid, $iden, $ln1,$ln2,$b1,$b2,$e1,$e2,$d1,$d2,$color1,$color2,$reg1,$reg2, $next_org);
2215 : arodri7 1.60 if ($thing eq $query_fid){
2216 :     $id = $thing;
2217 :     $taxid = $fig->genome_of($id);
2218 :     $organism = $fig->genus_species($taxid);
2219 :     $current_function = $fig->function_of($id);
2220 :     }
2221 :     else{
2222 :     next if ($thing->class ne "SIM");
2223 :    
2224 :     $id = $thing->acc;
2225 :     $evalue = $thing->evalue;
2226 :     $taxid = $fig->genome_of($id);
2227 :     $iden = $thing->identity;
2228 :     $organism= $thing->organism;
2229 :     $ln1 = $thing->qlength;
2230 :     $ln2 = $thing->hlength;
2231 :     $b1 = $thing->qstart;
2232 :     $e1 = $thing->qstop;
2233 :     $b2 = $thing->hstart;
2234 :     $e2 = $thing->hstop;
2235 :     $d1 = abs($e1 - $b1) + 1;
2236 :     $d2 = abs($e2 - $b2) + 1;
2237 :     $color1 = match_color( $b1, $e1, $ln1 );
2238 :     $color2 = match_color( $b2, $e2, $ln2 );
2239 :     $reg1 = {'data'=> "$b1-$e1 (<b>$d1/$ln1</b>)", 'highlight' => $color1};
2240 :     $reg2 = {'data'=> "$b2-$e2 (<b>$d2/$ln2</b>)", 'highlight' => $color2};
2241 :     $current_function = $thing->function;
2242 : arodri7 1.66 $next_org = $next_thing->organism if (defined $next_thing);
2243 : arodri7 1.60 }
2244 :    
2245 : arodri7 1.10 my $single_domain = [];
2246 :     $count++;
2247 :    
2248 : arodri7 1.58 # organisms cell
2249 :     my ($org, $org_color) = $fig->org_and_color_of($id);
2250 : arodri7 1.66
2251 :     my $org_cell;
2252 :     if ( ($next_org ne $organism) && ($same_genome_flag == 0) ){
2253 :     $org_cell = { 'data' => $organism, 'highlight' => $org_color};
2254 :     }
2255 :     elsif ($next_org eq $organism){
2256 :     $org_cell = { 'data' => "<b>" . $organism . "</b>", 'highlight' => $org_color};
2257 :     $same_genome_flag = 1;
2258 :     }
2259 :     elsif ($same_genome_flag == 1){
2260 :     $org_cell = { 'data' => "<b>" . $organism . "</b>", 'highlight' => $org_color};
2261 :     $same_genome_flag = 0;
2262 :     }
2263 : arodri7 1.11
2264 : arodri7 1.58 # checkbox cell
2265 : arodri7 1.60 my ($box_cell,$tax, $radio_cell);
2266 : arodri7 1.29 my $field_name = "tables_" . $id;
2267 : arodri7 1.58 my $pair_name = "visual_" . $id;
2268 :     my $cell_name = "cell_". $id;
2269 :     my $replace_id = $id;
2270 :     $replace_id =~ s/\|/_/ig;
2271 : arodri7 1.60 my $white = '#ffffff';
2272 :     $white = '#999966' if ($id eq $query_fid);
2273 :     $org_color = '#999966' if ($id eq $query_fid);
2274 : arodri7 1.58 my $anchor_name = "anchor_". $replace_id;
2275 : arodri7 1.66 my $checked = "";
2276 :     #$checked = "checked" if ($id eq $query_fid);
2277 : arodri7 1.58 if ($id =~ /^fig\|/){
2278 : arodri7 1.66 my $box = qq~<a name="$anchor_name"></a><input type="checkbox" name="seq" value="$id" id="$field_name" onClick="VisualCheckPair('$field_name', '$pair_name','$cell_name');" $checked>~;
2279 : arodri7 1.58 $box_cell = { 'data'=>$box, 'highlight'=>$org_color};
2280 : arodri7 1.60 $tax = $fig->genome_of($id);
2281 : arodri7 1.58 }
2282 :     else{
2283 :     my $box = qq(<a name="$anchor_name"></a>);
2284 :     $box_cell = { 'data'=>$box, 'highlight'=>$org_color};
2285 :     }
2286 :    
2287 : arodri7 1.68 # create the radio cell for any sequence, not just fig ids
2288 : arodri7 1.72 my $radio = qq(<input type="radio" name="function_select" value="$current_function" id="$field_name" onClick="clearText('new_text_function')">);
2289 : arodri7 1.68 $radio_cell = { 'data'=>$radio, 'highlight'=>$white};
2290 :    
2291 : arodri7 1.31 # get the linked fig id
2292 : arodri7 1.58 my $anchor_link = "graph_" . $replace_id;
2293 : paczian 1.64 my $fig_data = "<table><tr><td><a href='?page=Annotation&feature=$id'>$id</a></td>" . "&nbsp;" x 2;
2294 : parrello 1.70 $fig_data .= qq(<td><img height='10px' width='20px' src='$FIG_Config::cgi_url/Html/anchor_alignment.png' alt='View Graphic View of Alignment' onClick='changeSimsLocation("$anchor_link", 0)'/></td></tr></table>);
2295 : arodri7 1.58 my $fig_col = {'data'=> $fig_data,
2296 : arodri7 1.60 'highlight'=>$white};
2297 :    
2298 :     $replace_id = $peg;
2299 :     $replace_id =~ s/\|/_/ig;
2300 :     $anchor_name = "anchor_". $replace_id;
2301 :     my $query_config = { 'title' => "Query",
2302 :     'short_title' => "Query",
2303 :     'title_link' => "changeSimsLocation('$replace_id')",
2304 :     'basepair_offset' => '0'
2305 :     };
2306 : arodri7 1.58
2307 :     # function cell
2308 :     my $function_cell_colors = {0=>"#ffffff", 1=>"#eeccaa", 2=>"#ffaaaa",
2309 :     3=>"#ffcc66", 4=>"#ffff00", 5=>"#aaffaa",
2310 :     6=>"#bbbbff", 7=>"#ffaaff", 8=>"#dddddd"};
2311 : arodri7 1.60
2312 :     my $function_color;
2313 :     if ( (defined($functional_color->{$query_function})) && ($functional_color->{$query_function} == 1) ){
2314 :     $function_color = $function_cell_colors->{ $functional_color->{$current_function} - $func_color_offset};
2315 :     }
2316 :     else{
2317 :     $function_color = $function_cell_colors->{ $functional_color->{$current_function}};
2318 :     }
2319 : arodri7 1.58 my $function_cell;
2320 :     if ($current_function){
2321 :     if ($current_function eq $query_function){
2322 :     $function_cell = {'data'=>$current_function, 'highlight'=>$function_cell_colors->{0}};
2323 :     $func_color_offset=1;
2324 :     }
2325 :     else{
2326 : arodri7 1.60 $function_cell = {'data'=>$current_function,'highlight' => $function_color};
2327 : arodri7 1.58 }
2328 : arodri7 1.31 }
2329 : arodri7 1.58 else{
2330 :     $function_cell = {'data'=>$current_function,'highlight' => "#dddddd"};
2331 : arodri7 1.28 }
2332 : arodri7 1.58
2333 : arodri7 1.60 if ($id eq $query_fid){
2334 :     push (@$single_domain, $box_cell, {'data'=>qq~<i>Query Sequence: </i>~ . qq~<b>$id</b>~ , 'highlight'=>$white}, {'data'=> 'n/a', 'highlight'=>$white},
2335 :     {'data'=>'n/a', 'highlight'=>$white}, {'data'=>'n/a', 'highlight'=>$white}, {'data'=>'n/a', 'highlight'=>$white},
2336 : arodri7 1.69 {'data' => $organism, 'highlight'=> $white}, {'data'=>$current_function, 'highlight'=>$white},
2337 :     {'data'=>$subsystems_column->{$id},'highlight'=>$white},
2338 :     {'data'=>$evidence_column->{$id},'highlight'=>$white}); # permanent columns
2339 : arodri7 1.60 }
2340 :     else{
2341 :     push (@$single_domain, $box_cell, $fig_col, {'data'=> $evalue, 'highlight'=>"#ffffff"},
2342 : arodri7 1.69 {'data'=>"$iden\%", 'highlight'=>"#ffffff"}, $reg1, $reg2, $org_cell, $function_cell,
2343 :     {'data'=>$subsystems_column->{$id},'highlight'=>"#ffffff"},
2344 :     {'data'=>$evidence_column->{$id},'highlight'=>"#ffffff"}); # permanent columns
2345 :    
2346 : arodri7 1.60 }
2347 :    
2348 :     if ( ( $application->session->user) ){
2349 : paczian 1.64 my $user = $application->session->user;
2350 :     if ($user && $user->has_right(undef, 'annotate', 'genome', $fig->genome_of($id))) {
2351 : arodri7 1.60 push (@$single_domain,$radio_cell);
2352 : paczian 1.64 }
2353 : arodri7 1.60 }
2354 :    
2355 : arodri7 1.55 my ($ff) = $figfams->families_containing_peg($id);
2356 :    
2357 : arodri7 1.60 foreach my $col (@$scroll_list){
2358 :     if ($id eq $query_fid) { $highlight_color = "#999966"; }
2359 :     else { $highlight_color = "#ffffff"; }
2360 :    
2361 : arodri7 1.69 if ($col =~ /pfam/) {push(@$single_domain,{'data'=>$pfam_column->{$id},'highlight'=>$highlight_color});}
2362 : arodri7 1.60 elsif ($col =~ /mw/) {push(@$single_domain,{'data'=>$mw_column->{$id},'highlight'=>$highlight_color});}
2363 :     elsif ($col =~ /habitat/) {push(@$single_domain,{'data'=>$habitat_column->{$id},'highlight'=>$highlight_color});}
2364 :     elsif ($col =~ /temperature/) {push(@$single_domain,{'data'=>$temperature_column->{$id},'highlight'=>$highlight_color});}
2365 :     elsif ($col =~ /temp_range/) {push(@$single_domain,{'data'=>$temperature_range_column->{$id},'highlight'=>$highlight_color});}
2366 :     elsif ($col =~ /oxygen/) {push(@$single_domain,{'data'=>$oxygen_req_column->{$id},'highlight'=>$highlight_color});}
2367 :     elsif ($col =~ /^pathogenic$/) {push(@$single_domain,{'data'=>$pathogenic_column->{$id},'highlight'=>$highlight_color});}
2368 :     elsif ($col =~ /^pathogenic_in$/) {push(@$single_domain,{'data'=>$pathogenic_in_column->{$id},'highlight'=>$highlight_color});}
2369 :     elsif ($col =~ /salinity/) {push(@$single_domain,{'data'=>$salinity_column->{$id},'highlight'=>$highlight_color});}
2370 :     elsif ($col =~ /motility/) {push(@$single_domain,{'data'=>$motility_column->{$id},'highlight'=>$highlight_color});}
2371 :     elsif ($col =~ /gram_stain/) {push(@$single_domain,{'data'=>$gram_stain_column->{$id},'highlight'=>$highlight_color});}
2372 :     elsif ($col =~ /endospores/) {push(@$single_domain,{'data'=>$endospores_column->{$id},'highlight'=>$highlight_color});}
2373 :     elsif ($col =~ /shape/) {push(@$single_domain,{'data'=>$shape_column->{$id},'highlight'=>$highlight_color});}
2374 :     elsif ($col =~ /disease/) {push(@$single_domain,{'data'=>$disease_column->{$id},'highlight'=>$highlight_color});}
2375 :     elsif ($col =~ /gc_content/) {push(@$single_domain,{'data'=>$gc_content_column->{$id},'highlight'=>$highlight_color});}
2376 :     elsif ($col =~ /transmembrane/) {push(@$single_domain,{'data'=>$transmembrane_column->{$id},'highlight'=>$highlight_color});}
2377 :     elsif ($col =~ /signal_peptide/) {push(@$single_domain,{'data'=>$signal_peptide_column->{$id},'highlight'=>$highlight_color});}
2378 :     elsif ($col =~ /isoelectric/) {push(@$single_domain,{'data'=>$isoelectric_column->{$id},'highlight'=>$highlight_color});}
2379 : arodri7 1.66 elsif ($col =~ /conerved_neighborhood/) {push(@$single_domain,{'data'=>$cons_neigh_column->{$id},'highlight'=>$highlight_color});}
2380 : arodri7 1.60 elsif ($col =~ /cellular_location/) {push(@$single_domain,{'data'=>$cell_location_column->{$id},'highlight'=>$highlight_color});}
2381 :     elsif ($col =~ /ncbi_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"NCBI"},'highlight'=>$highlight_color});}
2382 :     elsif ($col =~ /refseq_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"RefSeq"},'highlight'=>$highlight_color});}
2383 :     elsif ($col =~ /swissprot_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"SwissProt"},'highlight'=>$highlight_color});}
2384 :     elsif ($col =~ /uniprot_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"UniProt"},'highlight'=>$highlight_color});}
2385 :     elsif ($col =~ /tigr_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"TIGR"},'highlight'=>$highlight_color});}
2386 :     elsif ($col =~ /pir_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"PIR"},'highlight'=>$highlight_color});}
2387 :     elsif ($col =~ /kegg_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"KEGG"},'highlight'=>$highlight_color});}
2388 :     elsif ($col =~ /trembl_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"TrEMBL"},'highlight'=>$highlight_color});}
2389 :     elsif ($col =~ /asap_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"ASAP"},'highlight'=>$highlight_color});}
2390 :     elsif ($col =~ /jgi_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"JGI"},'highlight'=>$highlight_color});}
2391 :     elsif ($col =~ /lineage/) {push(@$single_domain,{'data'=>$lineages->{$tax},'highlight'=>$highlight_color});}
2392 :     elsif ($col =~ /figfam/) {push(@$single_domain,{'data'=>"<a href='?page=FigFamViewer&figfam=" . $ff . "' target='_new'>" . $ff . "</a>",'highlight'=>$highlight_color});}
2393 : arodri7 1.32 }
2394 : arodri7 1.10 push(@$data,$single_domain);
2395 :     }
2396 : arodri7 1.26 if ($count >0 ){
2397 :     $content = $data;
2398 : arodri7 1.10 }
2399 : arodri7 1.26 else{
2400 : arodri7 1.10 $content = "<p>This PEG does not have any similarities</p>";
2401 :     }
2402 : arodri7 1.60 shift(@$dataset);
2403 : arodri7 1.10 return ($content);
2404 :     }
2405 : arodri7 1.11
2406 : arodri7 1.69
2407 :     =head3 display_figfam_table()
2408 :    
2409 :     If available use the function specified here to display the "raw" observation.
2410 :     This code will display a table for the similarities protein
2411 :    
2412 :     B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evidence.
2413 :    
2414 :     =cut
2415 :    
2416 :     sub display_figfam_table {
2417 :     my ($self,$ids, $show_columns, $fig, $application, $cgi) = @_;
2418 :     my ($count, $data, $content, %box_column, $subsystems_column, $evidence_column, %e_identical, $function_color, @ids);
2419 :    
2420 :     my $scroll_list;
2421 :     foreach my $col (@$show_columns){
2422 :     push (@$scroll_list, $col->{key});
2423 :     }
2424 :    
2425 :     $lineages = $fig->taxonomy_list() if (grep /lineage/, @$scroll_list);
2426 :     my @attributes = $fig->get_attributes($ids) if ( (grep /evidence/, @$scroll_list) || (grep /(pfam|mw)/, @$scroll_list) );
2427 :    
2428 :     # get the column for the subsystems
2429 :     $subsystems_column = &get_subsystems_column($ids,$fig,$cgi,'hash');
2430 :    
2431 :     # get the column for the evidence codes
2432 :     $evidence_column = &get_evidence_column($ids, \@attributes, $fig, $cgi, 'hash') if (grep /^evidence$/, @$scroll_list);
2433 :    
2434 :     # get the column for pfam_domain
2435 :     $pfam_column = &get_attrb_column($ids, \@attributes, $fig, $cgi, 'pfam', 'PFAM', 'hash') if (grep /^pfam$/, @$scroll_list);
2436 :    
2437 :     # get the column for molecular weight
2438 :     $mw_column = &get_attrb_column($ids, \@attributes, $fig, $cgi, 'mw', 'molecular_weight', 'hash') if (grep /^mw$/, @$scroll_list);
2439 :    
2440 :     # get the column for organism's habitat
2441 :     my $habitat_column = &get_attrb_column($ids, undef, $fig, $cgi, 'habitat', 'Habitat', 'hash') if (grep /^habitat$/, @$scroll_list);
2442 :    
2443 :     # get the column for organism's temperature optimum
2444 :     my $temperature_column = &get_attrb_column($ids, undef, $fig, $cgi, 'temperature', 'Optimal_Temperature', 'hash') if (grep /^temperature$/, @$scroll_list);
2445 :    
2446 :     # get the column for organism's temperature range
2447 :     my $temperature_range_column = &get_attrb_column($ids, undef, $fig, $cgi, 'temp_range', 'Temperature_Range', 'hash') if (grep /^temp_range$/, @$scroll_list);
2448 :    
2449 :     # get the column for organism's oxygen requirement
2450 :     my $oxygen_req_column = &get_attrb_column($ids, undef, $fig, $cgi, 'oxygen', 'Oxygen_Requirement', 'hash') if (grep /^oxygen$/, @$scroll_list);
2451 :    
2452 :     # get the column for organism's pathogenicity
2453 :     my $pathogenic_column = &get_attrb_column($ids, undef, $fig, $cgi, 'pathogenic', 'Pathogenic', 'hash') if (grep /^pathogenic$/, @$scroll_list);
2454 :    
2455 :     # get the column for organism's pathogenicity host
2456 :     my $pathogenic_in_column = &get_attrb_column($ids, undef, $fig, $cgi, 'pathogenic_in', 'Pathogenic_In', 'hash') if (grep /^pathogenic_in$/, @$scroll_list);
2457 :    
2458 :     # get the column for organism's salinity
2459 :     my $salinity_column = &get_attrb_column($ids, undef, $fig, $cgi, 'salinity', 'Salinity', 'hash') if (grep /^salinity$/, @$scroll_list);
2460 :    
2461 :     # get the column for organism's motility
2462 :     my $motility_column = &get_attrb_column($ids, undef, $fig, $cgi, 'motility', 'Motility', 'hash') if (grep /^motility$/, @$scroll_list);
2463 :    
2464 :     # get the column for organism's gram stain
2465 :     my $gram_stain_column = &get_attrb_column($ids, undef, $fig, $cgi, 'gram_stain', 'Gram_Stain', 'hash') if (grep /^gram_stain$/, @$scroll_list);
2466 :    
2467 :     # get the column for organism's endospores
2468 :     my $endospores_column = &get_attrb_column($ids, undef, $fig, $cgi, 'endospores', 'Endospores', 'hash') if (grep /^endospores$/, @$scroll_list);
2469 :    
2470 :     # get the column for organism's shape
2471 :     my $shape_column = &get_attrb_column($ids, undef, $fig, $cgi, 'shape', 'Shape', 'hash') if (grep /^shape$/, @$scroll_list);
2472 :    
2473 :     # get the column for organism's disease
2474 :     my $disease_column = &get_attrb_column($ids, undef, $fig, $cgi, 'disease', 'Disease', 'hash') if (grep /^disease$/, @$scroll_list);
2475 :    
2476 :     # get the column for organism's disease
2477 :     my $gc_content_column = &get_attrb_column($ids, undef, $fig, $cgi, 'gc_content', 'GC_Content', 'hash') if (grep /^gc_content$/, @$scroll_list);
2478 :    
2479 :     # get the column for transmembrane domains
2480 :     my $transmembrane_column = &get_attrb_column($ids, undef, $fig, $cgi, 'transmembrane', 'Phobius::transmembrane', 'hash') if (grep /^transmembrane$/, @$scroll_list);
2481 :    
2482 :     # get the column for similar to human
2483 :     my $similar_to_human_column = &get_attrb_column($ids, undef, $fig, $cgi, 'similar_to_human', 'similar_to_human', 'hash') if (grep /^similar_to_human$/, @$scroll_list);
2484 :    
2485 :     # get the column for signal peptide
2486 :     my $signal_peptide_column = &get_attrb_column($ids, undef, $fig, $cgi, 'signal_peptide', 'Phobius::signal', 'hash') if (grep /^signal_peptide$/, @$scroll_list);
2487 :    
2488 :     # get the column for transmembrane domains
2489 :     my $isoelectric_column = &get_attrb_column($ids, undef, $fig, $cgi, 'isoelectric', 'isoelectric_point', 'hash') if (grep /^isoelectric$/, @$scroll_list);
2490 :    
2491 :     # get the column for conserved neighborhood
2492 :     my $cons_neigh_column = &get_attrb_column($ids, undef, $fig, $cgi, 'conserved_neighborhood', undef, 'hash') if (grep /^conserved_neighborhood$/, @$scroll_list);
2493 :    
2494 :     # get the column for cellular location
2495 :     my $cell_location_column = &get_attrb_column($ids, undef, $fig, $cgi, 'cellular_location', 'PSORT::', 'hash') if (grep /^isoelectric$/, @$scroll_list);
2496 :    
2497 :     # get the aliases
2498 :     my $alias_col;
2499 :     if ( (grep /asap_id/, @$scroll_list) || (grep /ncbi_id/, @$scroll_list) ||
2500 :     (grep /refseq_id/, @$scroll_list) || (grep /swissprot_id/, @$scroll_list) ||
2501 :     (grep /uniprot_id/, @$scroll_list) || (grep /tigr_id/, @$scroll_list) ||
2502 :     (grep /kegg_id/, @$scroll_list) || (grep /pir_id/, @$scroll_list) ||
2503 :     (grep /trembl_id/, @$scroll_list) || (grep /jgi_id/, @$scroll_list) ) {
2504 :     $alias_col = &get_db_aliases($ids,$fig,'all',$cgi,'hash');
2505 :     }
2506 :    
2507 :     foreach my $id ( @$ids){
2508 :     my $current_function = $fig->function_of($id);
2509 :     my $organism = $fig->org_of($id);
2510 :     my $single_domain = [];
2511 :    
2512 :     # organisms cell
2513 :     my ($org, $org_color) = $fig->org_and_color_of($id);
2514 :     my $org_cell = { 'data' => $organism, 'highlight' => $org_color};
2515 :    
2516 :     # get the linked fig id
2517 :     my $fig_data = "<a href='?page=Annotation&feature=$id'>$id</a>";
2518 :     my $fig_col = {'data'=> $fig_data,
2519 :     'highlight'=>"#ffffff"};
2520 :    
2521 :     # function cell
2522 :     $function_cell = {'data'=>$current_function, 'highlight'=> "#ffffff"};
2523 :    
2524 :     # insert data
2525 :     push (@$single_domain, $fig_col, $org_cell, {'data'=>$subsystems_column->{$id},'highlight'=>"#ffffff"}, $function_cell);
2526 :    
2527 :     foreach my $col (@$scroll_list){
2528 :     my $highlight_color = "#ffffff";
2529 :    
2530 :     if ($col =~ /evidence/) {push(@$single_domain,{'data'=>$evidence_column->{$id},'highlight'=>$highlight_color});}
2531 :     elsif ($col =~ /pfam/) {push(@$single_domain,{'data'=>$pfam_column->{$id},'highlight'=>$highlight_color});}
2532 :     elsif ($col =~ /mw/) {push(@$single_domain,{'data'=>$mw_column->{$id},'highlight'=>$highlight_color});}
2533 :     elsif ($col =~ /habitat/) {push(@$single_domain,{'data'=>$habitat_column->{$id},'highlight'=>$highlight_color});}
2534 :     elsif ($col =~ /temperature/) {push(@$single_domain,{'data'=>$temperature_column->{$id},'highlight'=>$highlight_color});}
2535 :     elsif ($col =~ /temp_range/) {push(@$single_domain,{'data'=>$temperature_range_column->{$id},'highlight'=>$highlight_color});}
2536 :     elsif ($col =~ /oxygen/) {push(@$single_domain,{'data'=>$oxygen_req_column->{$id},'highlight'=>$highlight_color});}
2537 :     elsif ($col =~ /^pathogenic$/) {push(@$single_domain,{'data'=>$pathogenic_column->{$id},'highlight'=>$highlight_color});}
2538 :     elsif ($col =~ /^pathogenic_in$/) {push(@$single_domain,{'data'=>$pathogenic_in_column->{$id},'highlight'=>$highlight_color});}
2539 :     elsif ($col =~ /salinity/) {push(@$single_domain,{'data'=>$salinity_column->{$id},'highlight'=>$highlight_color});}
2540 :     elsif ($col =~ /motility/) {push(@$single_domain,{'data'=>$motility_column->{$id},'highlight'=>$highlight_color});}
2541 :     elsif ($col =~ /gram_stain/) {push(@$single_domain,{'data'=>$gram_stain_column->{$id},'highlight'=>$highlight_color});}
2542 :     elsif ($col =~ /endospores/) {push(@$single_domain,{'data'=>$endospores_column->{$id},'highlight'=>$highlight_color});}
2543 :     elsif ($col =~ /shape/) {push(@$single_domain,{'data'=>$shape_column->{$id},'highlight'=>$highlight_color});}
2544 :     elsif ($col =~ /disease/) {push(@$single_domain,{'data'=>$disease_column->{$id},'highlight'=>$highlight_color});}
2545 :     elsif ($col =~ /gc_content/) {push(@$single_domain,{'data'=>$gc_content_column->{$id},'highlight'=>$highlight_color});}
2546 :     elsif ($col =~ /transmembrane/) {push(@$single_domain,{'data'=>$transmembrane_column->{$id},'highlight'=>$highlight_color});}
2547 :     elsif ($col =~ /signal_peptide/) {push(@$single_domain,{'data'=>$signal_peptide_column->{$id},'highlight'=>$highlight_color});}
2548 :     elsif ($col =~ /isoelectric/) {push(@$single_domain,{'data'=>$isoelectric_column->{$id},'highlight'=>$highlight_color});}
2549 :     elsif ($col =~ /conerved_neighborhood/) {push(@$single_domain,{'data'=>$cons_neigh_column->{$id},'highlight'=>$highlight_color});}
2550 :     elsif ($col =~ /cellular_location/) {push(@$single_domain,{'data'=>$cell_location_column->{$id},'highlight'=>$highlight_color});}
2551 :     elsif ($col =~ /ncbi_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"NCBI"},'highlight'=>$highlight_color});}
2552 :     elsif ($col =~ /refseq_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"RefSeq"},'highlight'=>$highlight_color});}
2553 :     elsif ($col =~ /swissprot_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"SwissProt"},'highlight'=>$highlight_color});}
2554 :     elsif ($col =~ /uniprot_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"UniProt"},'highlight'=>$highlight_color});}
2555 :     elsif ($col =~ /tigr_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"TIGR"},'highlight'=>$highlight_color});}
2556 :     elsif ($col =~ /pir_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"PIR"},'highlight'=>$highlight_color});}
2557 :     elsif ($col =~ /kegg_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"KEGG"},'highlight'=>$highlight_color});}
2558 :     elsif ($col =~ /trembl_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"TrEMBL"},'highlight'=>$highlight_color});}
2559 :     elsif ($col =~ /asap_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"ASAP"},'highlight'=>$highlight_color});}
2560 :     elsif ($col =~ /jgi_id/) {push(@$single_domain,{'data'=>$alias_col->{$id}->{"JGI"},'highlight'=>$highlight_color});}
2561 :     elsif ($col =~ /lineage/) {push(@$single_domain,{'data'=>$lineages->{$tax},'highlight'=>$highlight_color});}
2562 :     elsif ($col =~ /figfam/) {push(@$single_domain,{'data'=>"<a href='?page=FigFamViewer&figfam=" . $ff . "' target='_new'>" . $ff . "</a>",'highlight'=>$highlight_color});}
2563 :     }
2564 :     push(@$data,$single_domain);
2565 :     }
2566 :    
2567 :     $content = $data;
2568 :     return ($content);
2569 :     }
2570 :    
2571 : arodri7 1.29 sub get_box_column{
2572 :     my ($ids) = @_;
2573 :     my %column;
2574 :     foreach my $id (@$ids){
2575 :     my $field_name = "tables_" . $id;
2576 :     my $pair_name = "visual_" . $id;
2577 : arodri7 1.58 my $cell_name = "cell_" . $id;
2578 :     $column{$id} = qq(<input type=checkbox name=seq value="$id" id="$field_name" onClick="VisualCheckPair('$field_name', '$pair_name', '$cell_name');">);
2579 : arodri7 1.29 }
2580 :     return (%column);
2581 :     }
2582 :    
2583 : arodri7 1.60 sub get_figfam_column{
2584 :     my ($ids, $fig, $cgi) = @_;
2585 :     my $column;
2586 :    
2587 :     my $figfam_data = &FIG::get_figfams_data();
2588 :     my $figfams = new FFs($figfam_data);
2589 :    
2590 :     foreach my $id (@$ids){
2591 : arodri7 1.74 my ($ff);
2592 :     if ($id =~ /\.peg\./){
2593 :     ($ff) = $figfams->families_containing_peg($id);
2594 :     }
2595 : arodri7 1.60 if ($ff){
2596 :     push (@$column, "<a href='?page=FigFamViewer&figfam=" . $ff . "' target='_new'>" . $ff . "</a>");
2597 :     }
2598 :     else{
2599 :     push (@$column, " ");
2600 :     }
2601 :     }
2602 :    
2603 :     return $column;
2604 :     }
2605 :    
2606 : arodri7 1.29 sub get_subsystems_column{
2607 : arodri7 1.60 my ($ids,$fig,$cgi,$returnType) = @_;
2608 : arodri7 1.29
2609 :     my %in_subs = $fig->subsystems_for_pegs($ids);
2610 : arodri7 1.60 my ($column, $ss);
2611 : arodri7 1.29 foreach my $id (@$ids){
2612 : arodri7 1.32 my @in_sub = @{$in_subs{$id}} if (defined $in_subs{$id});
2613 :     my @subsystems;
2614 :    
2615 : arodri7 1.29 if (@in_sub > 0) {
2616 : arodri7 1.32 foreach my $array(@in_sub){
2617 : arodri7 1.60 my $ss = $array->[0];
2618 : arodri7 1.41 $ss =~ s/_/ /ig;
2619 :     push (@subsystems, "-" . $ss);
2620 : arodri7 1.32 }
2621 :     my $in_sub_line = join ("<br>", @subsystems);
2622 : arodri7 1.60 $ss->{$id} = $in_sub_line;
2623 : arodri7 1.29 } else {
2624 : arodri7 1.60 $ss->{$id} = "None added";
2625 : arodri7 1.29 }
2626 : arodri7 1.60 push (@$column, $ss->{$id});
2627 :     }
2628 :    
2629 :     if ($returnType eq 'hash') { return $ss; }
2630 :     elsif ($returnType eq 'array') { return $column; }
2631 :     }
2632 :    
2633 :     sub get_lineage_column{
2634 :     my ($ids, $fig, $cgi) = @_;
2635 :    
2636 :     my $lineages = $fig->taxonomy_list();
2637 :    
2638 :     foreach my $id (@$ids){
2639 :     my $genome = $fig->genome_of($id);
2640 :     if ($lineages->{$genome}){
2641 :     # push (@$column, qq~<table style='border-style:hidden;'><tr><td style='background-color: #ffffff;'>~ . $lineages->{$genome} . qq~</td></tr</table>~);
2642 :     push (@$column, $lineages->{$genome});
2643 :     }
2644 :     else{
2645 :     push (@$column, " ");
2646 :     }
2647 : arodri7 1.29 }
2648 : arodri7 1.60 return $column;
2649 : arodri7 1.29 }
2650 :    
2651 : arodri7 1.58 sub match_color {
2652 :     my ( $b, $e, $n , $rgb) = @_;
2653 :     my ( $l, $r ) = ( $e > $b ) ? ( $b, $e ) : ( $e, $b );
2654 :     my $hue = 5/6 * 0.5*($l+$r)/$n - 1/12;
2655 :     my $cov = ( $r - $l + 1 ) / $n;
2656 :     my $sat = 1 - 10 * $cov / 9;
2657 :     my $br = 1;
2658 :     if ($rgb){
2659 :     return html2rgb( rgb2html( hsb2rgb( $hue, $sat, $br ) ) );
2660 :     }
2661 :     else{
2662 :     rgb2html( hsb2rgb( $hue, $sat, $br ) );
2663 :     }
2664 :     }
2665 :    
2666 :     sub hsb2rgb {
2667 :     my ( $h, $s, $br ) = @_;
2668 :     $h = 6 * ($h - floor($h));
2669 :     if ( $s > 1 ) { $s = 1 } elsif ( $s < 0 ) { $s = 0 }
2670 :     if ( $br > 1 ) { $br = 1 } elsif ( $br < 0 ) { $br = 0 }
2671 :     my ( $r, $g, $b ) = ( $h <= 3 ) ? ( ( $h <= 1 ) ? ( 1, $h, 0 )
2672 :     : ( $h <= 2 ) ? ( 2 - $h, 1, 0 )
2673 :     : ( 0, 1, $h - 2 )
2674 :     )
2675 :     : ( ( $h <= 4 ) ? ( 0, 4 - $h, 1 )
2676 :     : ( $h <= 5 ) ? ( $h - 4, 0, 1 )
2677 :     : ( 1, 0, 6 - $h )
2678 :     );
2679 :     ( ( $r * $s + 1 - $s ) * $br,
2680 :     ( $g * $s + 1 - $s ) * $br,
2681 :     ( $b * $s + 1 - $s ) * $br
2682 :     )
2683 :     }
2684 :    
2685 :     sub html2rgb {
2686 :     my ($hex) = @_;
2687 :     my ($r,$g,$b) = ($hex) =~ /^\#(\w\w)(\w\w)(\w\w)/;
2688 :     my $code = { 'A'=>10, 'B'=>11, 'C'=>12, 'D'=>13, 'E'=>14, 'F'=>15,
2689 :     1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9};
2690 :    
2691 :     my @R = split(//, $r);
2692 :     my @G = split(//, $g);
2693 :     my @B = split(//, $b);
2694 :    
2695 :     my $red = ($code->{uc($R[0])}*16)+$code->{uc($R[1])};
2696 :     my $green = ($code->{uc($G[0])}*16)+$code->{uc($G[1])};
2697 :     my $blue = ($code->{uc($B[0])}*16)+$code->{uc($B[1])};
2698 :    
2699 :     my $rgb = [$red, $green, $blue];
2700 :     return $rgb;
2701 :    
2702 :     }
2703 :    
2704 :     sub rgb2html {
2705 :     my ( $r, $g, $b ) = @_;
2706 :     if ( $r > 1 ) { $r = 1 } elsif ( $r < 0 ) { $r = 0 }
2707 :     if ( $g > 1 ) { $g = 1 } elsif ( $g < 0 ) { $g = 0 }
2708 :     if ( $b > 1 ) { $b = 1 } elsif ( $b < 0 ) { $b = 0 }
2709 :     sprintf("#%02x%02x%02x", int(255.999*$r), int(255.999*$g), int(255.999*$b) )
2710 :     }
2711 :    
2712 :     sub floor {
2713 :     my $x = $_[0];
2714 :     defined( $x ) || return undef;
2715 :     ( $x >= 0 ) || ( int($x) == $x ) ? int( $x ) : -1 - int( - $x )
2716 :     }
2717 :    
2718 :     sub get_function_color_cell{
2719 :     my ($functions, $fig) = @_;
2720 :    
2721 :     # figure out the quantity of each function
2722 :     my %hash;
2723 :     foreach my $key (keys %$functions){
2724 :     my $func = $functions->{$key};
2725 :     $hash{$func}++;
2726 :     }
2727 :    
2728 :     my %func_colors;
2729 :     my $count = 1;
2730 :     foreach my $key (sort {$hash{$b}<=>$hash{$a}} keys %hash){
2731 :     $func_colors{$key}=$count;
2732 :     $count++;
2733 :     }
2734 :    
2735 :     return \%func_colors;
2736 :     }
2737 :    
2738 : arodri7 1.31 sub get_essentially_identical{
2739 : arodri7 1.41 my ($fid,$dataset,$fig) = @_;
2740 :     #my $fig = new FIG;
2741 :    
2742 : arodri7 1.31 my %id_list;
2743 : arodri7 1.41 #my @maps_to = grep { $_ ne $fid and $_ !~ /^xxx/ } map { $_->[0] } $fig->mapped_prot_ids($fid);
2744 : arodri7 1.31
2745 : arodri7 1.41 foreach my $thing (@$dataset){
2746 :     if($thing->class eq "IDENTICAL"){
2747 :     my $rows = $thing->rows;
2748 :     my $count_identical = 0;
2749 :     foreach my $row (@$rows) {
2750 :     my $id = $row->[0];
2751 :     if (($id ne $fid) && ($fig->function_of($id))) {
2752 :     $id_list{$id} = 1;
2753 :     }
2754 :     }
2755 :     }
2756 : arodri7 1.31 }
2757 : arodri7 1.41
2758 :     # foreach my $id (@maps_to) {
2759 :     # if (($id ne $fid) && ($fig->function_of($id))) {
2760 :     # $id_list{$id} = 1;
2761 :     # }
2762 :     # }
2763 : arodri7 1.31 return(%id_list);
2764 :     }
2765 :    
2766 :    
2767 : arodri7 1.29 sub get_evidence_column{
2768 : arodri7 1.60 my ($ids,$attributes,$fig,$cgi,$returnType) = @_;
2769 :     my ($column, $code_attributes);
2770 :    
2771 :     if (! defined $attributes) {
2772 :     my @attributes_array = $fig->get_attributes($ids);
2773 :     $attributes = \@attributes_array;
2774 :     }
2775 : arodri7 1.29
2776 : arodri7 1.41 my @codes = grep { $_->[1] =~ /^evidence_code/i } @$attributes;
2777 : arodri7 1.29 foreach my $key (@codes){
2778 : arodri7 1.60 push (@{$code_attributes->{$key->[0]}}, $key);
2779 : arodri7 1.29 }
2780 :    
2781 :     foreach my $id (@$ids){
2782 :     # add evidence code with tool tip
2783 :     my $ev_codes=" &nbsp; ";
2784 :    
2785 : arodri7 1.60 my @codes = @{$code_attributes->{$id}} if (defined @{$code_attributes->{$id}});
2786 : arodri7 1.41 my @ev_codes = ();
2787 :     foreach my $code (@codes) {
2788 :     my $pretty_code = $code->[2];
2789 :     if ($pretty_code =~ /;/) {
2790 :     my ($cd, $ss) = split(";", $code->[2]);
2791 : arodri7 1.65 if ($cd =~ /ilit|dlit/){
2792 :     my ($type,$pubmed_id) = ($cd) =~ /(.*?)\((.*)\)/;
2793 :     my $publink = &HTML::alias_url($pubmed_id,'PMID');
2794 :     $cd = $type . "(<a href='" . $publink . "'>" . $pubmed_id . "</a>)";
2795 :     }
2796 : arodri7 1.41 $ss =~ s/_/ /g;
2797 :     $pretty_code = $cd;# . " in " . $ss;
2798 :     }
2799 :     push(@ev_codes, $pretty_code);
2800 :     }
2801 : arodri7 1.60
2802 : arodri7 1.29 if (scalar(@ev_codes) && $ev_codes[0]) {
2803 :     my $ev_code_help=join("<br />", map {&HTML::evidence_codes_explain($_)} @ev_codes);
2804 :     $ev_codes = $cgi->a(
2805 :     {
2806 :     id=>"evidence_codes", onMouseover=>"javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Evidence Codes', '$ev_code_help', ''); this.tooltip.addHandler(); return false;"}, join("<br />", @ev_codes));
2807 :     }
2808 : arodri7 1.60
2809 :     if ($returnType eq 'hash') { $column->{$id}=$ev_codes; }
2810 :     elsif ($returnType eq 'array') { push (@$column, $ev_codes); }
2811 : arodri7 1.29 }
2812 : arodri7 1.60 return $column;
2813 : arodri7 1.29 }
2814 :    
2815 : arodri7 1.60 sub get_attrb_column{
2816 :     my ($ids, $attributes, $fig, $cgi, $colName, $attrbName, $returnType) = @_;
2817 :    
2818 :     my ($column, %code_attributes, %attribute_locations);
2819 : paczian 1.52 my $dbmaster = DBMaster->new(-database =>'Ontology',
2820 : arodri7 1.60 -host => $WebConfig::DBHOST,
2821 :     -user => $WebConfig::DBUSER,
2822 :     -password => $WebConfig::DBPWD);
2823 :    
2824 :     if ($colName eq "pfam"){
2825 :     if (! defined $attributes) {
2826 :     my @attributes_array = $fig->get_attributes($ids);
2827 :     $attributes = \@attributes_array;
2828 :     }
2829 : arodri7 1.33
2830 : arodri7 1.60 my @codes = grep { $_->[1] =~ /^$attrbName/i } @$attributes;
2831 :     foreach my $key (@codes){
2832 :     my $name = $key->[1];
2833 :     if ($name =~ /_/){
2834 :     ($name) = ($key->[1]) =~ /(.*?)_/;
2835 :     }
2836 :     push (@{$code_attributes{$key->[0]}}, $name);
2837 :     push (@{$attribute_location{$key->[0]}{$name}}, $key->[2]);
2838 :     }
2839 :    
2840 :     foreach my $id (@$ids){
2841 :     # add pfam code
2842 :     my $pfam_codes=" &nbsp; ";
2843 :     my @pfam_codes = "";
2844 :     my %description_codes;
2845 :    
2846 :     if ($id =~ /^fig\|\d+\.\d+\.peg\.\d+$/) {
2847 :     my @ncodes = @{$code_attributes{$id}} if (defined @{$code_attributes{$id}});
2848 :     @pfam_codes = ();
2849 :    
2850 :     # get only unique values
2851 :     my %saw;
2852 :     foreach my $key (@ncodes) {$saw{$key}=1;}
2853 :     @ncodes = keys %saw;
2854 :    
2855 :     foreach my $code (@ncodes) {
2856 :     my @parts = split("::",$code);
2857 :     my $pfam_link = "<a href=http://pfam.sanger.ac.uk/family?acc=" . $parts[1] . ">$parts[1]</a>";
2858 :    
2859 : arodri7 1.74 # # get the locations for the domain
2860 :     # my @locs;
2861 :     # foreach my $part (@{$attribute_location{$id}{$code}}){
2862 :     # my ($loc) = ($part) =~ /\;(.*)/;
2863 :     # push (@locs,$loc);
2864 :     # }
2865 :     # my %locsaw;
2866 :     # foreach my $key (@locs) {$locsaw{$key}=1;}
2867 :     # @locs = keys %locsaw;
2868 :     #
2869 :     # my $locations = join (", ", @locs);
2870 :     #
2871 : arodri7 1.60 if (defined ($description_codes{$parts[1]})){
2872 : arodri7 1.74 push(@pfam_codes, "$parts[1]");
2873 : arodri7 1.60 }
2874 :     else {
2875 :     my $description = $dbmaster->pfam->get_objects( { 'id' => $parts[1] } );
2876 :     $description_codes{$parts[1]} = $description->[0]->{term};
2877 : arodri7 1.74 push(@pfam_codes, "$pfam_link");
2878 : arodri7 1.60 }
2879 :     }
2880 :    
2881 :     if ($returnType eq 'hash') { $column->{$id} = join("<br><br>", @pfam_codes); }
2882 :     elsif ($returnType eq 'array') { push (@$column, join("<br><br>", @pfam_codes)); }
2883 :     }
2884 : arodri7 1.41 }
2885 : arodri7 1.33 }
2886 : arodri7 1.60 elsif ($colName eq 'cellular_location'){
2887 :     if (! defined $attributes) {
2888 :     my @attributes_array = $fig->get_attributes($ids);
2889 :     $attributes = \@attributes_array;
2890 :     }
2891 : arodri7 1.33
2892 : arodri7 1.60 my @codes = grep { $_->[1] =~ /^$attrbName/i } @$attributes;
2893 :     foreach my $key (@codes){
2894 :     my ($loc) = ($key->[1]) =~ /::(.*)/;
2895 :     my ($new_loc, @all);
2896 :     @all = split (//, $loc);
2897 :     my $count = 0;
2898 :     foreach my $i (@all){
2899 :     if ( ($i eq uc($i)) && ($count > 0) ){
2900 :     $new_loc .= " " . $i;
2901 :     }
2902 :     else{
2903 :     $new_loc .= $i;
2904 : arodri7 1.40 }
2905 : arodri7 1.60 $count++;
2906 :     }
2907 :     push (@{$code_attributes{$key->[0]}}, [$new_loc, $key->[2]]);
2908 :     }
2909 :    
2910 :     foreach my $id (@$ids){
2911 :     my (@values, $entry);
2912 :     #@values = (" ");
2913 :     if (defined @{$code_attributes{$id}}){
2914 :     my @ncodes = @{$code_attributes{$id}};
2915 :     foreach my $code (@ncodes){
2916 :     push (@values, $code->[0] . ", " . $code->[1]);
2917 :     }
2918 :     }
2919 :     else{
2920 :     @values = ("Not available");
2921 :     }
2922 : arodri7 1.41
2923 : arodri7 1.60 if ($returnType eq 'hash') { $column->{$id} = join ("<BR>", @values); }
2924 :     elsif ($returnType eq 'array') { push (@$column, join ("<BR>", @values)); }
2925 :     }
2926 :     }
2927 :     elsif ( ($colName eq 'mw') || ($colName eq 'transmembrane') || ($colName eq 'similar_to_human') ||
2928 :     ($colName eq 'signal_peptide') || ($colName eq 'isoelectric') ){
2929 :     if (! defined $attributes) {
2930 :     my @attributes_array = $fig->get_attributes($ids);
2931 :     $attributes = \@attributes_array;
2932 :     }
2933 :    
2934 :     my @codes = grep { $_->[1] =~ /^$attrbName/i } @$attributes;
2935 :     foreach my $key (@codes){
2936 :     push (@{$code_attributes{$key->[0]}}, $key->[2]);
2937 :     }
2938 :    
2939 :     foreach my $id (@$ids){
2940 :     my (@values, $entry);
2941 :     #@values = (" ");
2942 :     if (defined @{$code_attributes{$id}}){
2943 :     my @ncodes = @{$code_attributes{$id}};
2944 :     foreach my $code (@ncodes){
2945 :     push (@values, $code);
2946 : arodri7 1.33 }
2947 :     }
2948 : arodri7 1.60 else{
2949 :     @values = ("Not available");
2950 :     }
2951 :    
2952 :     if ($returnType eq 'hash') { $column->{$id} = join ("<BR>", @values); }
2953 :     elsif ($returnType eq 'array') { push (@$column, join ("<BR>", @values)); }
2954 :     }
2955 :     }
2956 :     elsif ( ($colName eq 'habitat') || ($colName eq 'temperature') || ($colName eq 'temp_range') ||
2957 :     ($colName eq 'oxygen') || ($colName eq 'pathogenic') || ($colName eq 'pathogenic_in') ||
2958 :     ($colName eq 'salinity') || ($colName eq 'motility') || ($colName eq 'gram_stain') ||
2959 :     ($colName eq 'endospores') || ($colName eq 'shape') || ($colName eq 'disease') ||
2960 :     ($colName eq 'gc_content') ) {
2961 :     if (! defined $attributes) {
2962 :     my @attributes_array = $fig->get_attributes(undef,$attrbName);
2963 :     $attributes = \@attributes_array;
2964 :     }
2965 :    
2966 :     my $genomes_with_phenotype;
2967 :     foreach my $attribute (@$attributes){
2968 :     my $genome = $attribute->[0];
2969 :     $genomes_with_phenotype->{$genome} = $attribute->[2];
2970 : arodri7 1.33 }
2971 :    
2972 : arodri7 1.60 foreach my $id (@$ids){
2973 :     my $genome = $fig->genome_of($id);
2974 :     my @values = (' ');
2975 :     if (defined $genomes_with_phenotype->{$genome}){
2976 :     push (@values, $genomes_with_phenotype->{$genome});
2977 :     }
2978 :     if ($returnType eq 'hash') { $column->{$id} = join ("<BR>", @values); }
2979 :     elsif ($returnType eq 'array') { push (@$column, join ("<BR>", @values)); }
2980 :     }
2981 : arodri7 1.33 }
2982 : arodri7 1.60
2983 :     return $column;
2984 : arodri7 1.33 }
2985 : mkubal 1.12
2986 : arodri7 1.74 sub get_aclh_aliases {
2987 :     my ($ids,$fig,$db,$cgi,$returnType) = @_;
2988 :     my $db_array;
2989 :    
2990 :     my $id_line = join (",", @$ids);
2991 :     my $aclh_url = "http://clearinghouse.nmpdr.org/aclh.cgi?page=SearchResults&raw_dump=1&query=" . $id_line;
2992 :    
2993 :    
2994 :     }
2995 :    
2996 :     sub get_id_aliases {
2997 :     my ($id, $fig) = @_;
2998 :     my $aliases = {};
2999 :    
3000 :     my $org = $fig->org_of($id);
3001 :     my $url = "http://clearinghouse.nmpdr.org/aclh.cgi?page=SearchResults&raw_dump=1&query=$id";
3002 :     if ( my $form = &LWP::Simple::get($url) ) {
3003 :     my ($block) = ($form) =~ /<pre>(.*)<\/pre>/s;
3004 :     foreach my $line (split /\n/, $block){
3005 :     my @values = split /\t/, $line;
3006 :     next if ($values[3] eq "Expert");
3007 :     if (($values[1] =~ /$org/) || ($org =~ /$values[1]/) && (! defined $aliases->{$values[4]}) ){
3008 :     $aliases->{$values[4]} = $values[0];
3009 :     }
3010 :     }
3011 :     }
3012 :    
3013 :     return $aliases;
3014 :     }
3015 : arodri7 1.31
3016 : arodri7 1.60 sub get_db_aliases {
3017 :     my ($ids,$fig,$db,$cgi,$returnType) = @_;
3018 :     my $db_array;
3019 : arodri7 1.41 my $all_aliases = $fig->feature_aliases_bulk($ids);
3020 :     foreach my $id (@$ids){
3021 : arodri7 1.74 # my @all_aliases = grep { $_ ne $id and $_ !~ /^xxx/ } map { $_->[0] } $fig->mapped_prot_ids($id);
3022 :     my $id_org = $fig->org_of($id);
3023 :    
3024 : arodri7 1.41 foreach my $alias (@{$$all_aliases{$id}}){
3025 : arodri7 1.74 # foreach my $alias (@all_aliases){
3026 : arodri7 1.41 my $id_db = &Observation::get_database($alias);
3027 : arodri7 1.60 next if ( ($id_db ne $db) && ($db ne 'all') );
3028 :     next if ($aliases->{$id}->{$db});
3029 : arodri7 1.74 my $alias_org = $fig->org_of($alias);
3030 :     # if (($id ne $peg) && ( ($alias_org =~ /$id_org/) || ($id_org =~ /$alias_org/)) ) {
3031 :     #push(@funcs, [$id,$id_db,$tmp]);
3032 :     $aliases->{$id}->{$id_db} = &HTML::set_prot_links($cgi,$alias);
3033 :     # }
3034 : arodri7 1.28 }
3035 : arodri7 1.60 if (!defined( $aliases->{$id}->{$db})){
3036 :     $aliases->{$id}->{$db} = " ";
3037 :     }
3038 :     #push (@$db_array, {'data'=> $aliases->{$id}->{$db},'highlight'=>"#ffffff"});
3039 :     push (@$db_array, $aliases->{$id}->{$db});
3040 : arodri7 1.28 }
3041 : arodri7 1.74
3042 : arodri7 1.60 if ($returnType eq 'hash') { return $aliases; }
3043 :     elsif ($returnType eq 'array') { return $db_array; }
3044 : arodri7 1.28 }
3045 :    
3046 : arodri7 1.60
3047 :    
3048 : arodri7 1.33 sub html_enc { $_ = $_[0]; s/\&/&amp;/g; s/\>/&gt;/g; s/\</&lt;/g; $_ }
3049 :    
3050 : arodri7 1.26 sub color {
3051 : paczian 1.44 my ($evalue) = @_;
3052 :     my $palette = WebColors::get_palette('vitamins');
3053 : arodri7 1.26 my $color;
3054 : paczian 1.44 if ($evalue <= 1e-170){ $color = $palette->[0]; }
3055 :     elsif (($evalue <= 1e-120) && ($evalue > 1e-170)){ $color = $palette->[1]; }
3056 :     elsif (($evalue <= 1e-90) && ($evalue > 1e-120)){ $color = $palette->[2]; }
3057 :     elsif (($evalue <= 1e-70) && ($evalue > 1e-90)){ $color = $palette->[3]; }
3058 :     elsif (($evalue <= 1e-40) && ($evalue > 1e-70)){ $color = $palette->[4]; }
3059 :     elsif (($evalue <= 1e-20) && ($evalue > 1e-40)){ $color = $palette->[5]; }
3060 :     elsif (($evalue <= 1e-5) && ($evalue > 1e-20)){ $color = $palette->[6]; }
3061 :     elsif (($evalue <= 1) && ($evalue > 1e-5)){ $color = $palette->[7]; }
3062 :     elsif (($evalue <= 10) && ($evalue > 1)){ $color = $palette->[8]; }
3063 :     else{ $color = $palette->[9]; }
3064 : arodri7 1.26 return ($color);
3065 :     }
3066 : arodri7 1.13
3067 :    
3068 :     ############################
3069 :     package Observation::Cluster;
3070 :    
3071 :     use base qw(Observation);
3072 :    
3073 :     sub new {
3074 :    
3075 :     my ($class,$dataset) = @_;
3076 :     my $self = $class->SUPER::new($dataset);
3077 : mkubal 1.24 $self->{context} = $dataset->{'context'};
3078 : arodri7 1.13 bless($self,$class);
3079 :     return $self;
3080 :     }
3081 :    
3082 :     sub display {
3083 : arodri7 1.41 my ($self,$gd,$selected_taxonomies,$taxes,$sims_array,$fig) = @_;
3084 : mkubal 1.24
3085 : arodri7 1.53 $taxes = $fig->taxonomy_list();
3086 :    
3087 : mkubal 1.24 my $fid = $self->fig_id;
3088 :     my $compare_or_coupling = $self->context;
3089 :     my $gd_window_size = $gd->window_size;
3090 : arodri7 1.41 my $range = $gd_window_size;
3091 : mkubal 1.14 my $all_regions = [];
3092 : arodri7 1.38 my $gene_associations={};
3093 : arodri7 1.13
3094 :     #get the organism genome
3095 : mkubal 1.14 my $target_genome = $fig->genome_of($fid);
3096 : arodri7 1.38 $gene_associations->{$fid}->{"organism"} = $target_genome;
3097 :     $gene_associations->{$fid}->{"main_gene"} = $fid;
3098 :     $gene_associations->{$fid}->{"reverse_flag"} = 0;
3099 : arodri7 1.13
3100 :     # get location of the gene
3101 :     my $data = $fig->feature_location($fid);
3102 :     my ($contig, $beg, $end);
3103 : arodri7 1.22 my %reverse_flag;
3104 : arodri7 1.13
3105 :     if ($data =~ /(.*)_(\d+)_(\d+)$/){
3106 :     $contig = $1;
3107 :     $beg = $2;
3108 :     $end = $3;
3109 :     }
3110 :    
3111 : arodri7 1.22 my $offset;
3112 : arodri7 1.13 my ($region_start, $region_end);
3113 :     if ($beg < $end)
3114 :     {
3115 : arodri7 1.41 $region_start = $beg - ($range);
3116 :     $region_end = $end+ ($range);
3117 : arodri7 1.22 $offset = ($2+(($3-$2)/2))-($gd_window_size/2);
3118 : arodri7 1.13 }
3119 :     else
3120 :     {
3121 : arodri7 1.41 $region_start = $end-($range);
3122 :     $region_end = $beg+($range);
3123 : arodri7 1.22 $offset = ($3+(($2-$3)/2))-($gd_window_size/2);
3124 : arodri7 1.25 $reverse_flag{$target_genome} = $fid;
3125 : arodri7 1.38 $gene_associations->{$fid}->{"reverse_flag"} = 1;
3126 : arodri7 1.21 }
3127 : arodri7 1.13
3128 :     # call genes in region
3129 : arodri7 1.16 my ($target_gene_features, $reg_beg, $reg_end) = $fig->genes_in_region($target_genome, $contig, $region_start, $region_end);
3130 : arodri7 1.42 #foreach my $feat (@$target_gene_features){
3131 :     # push (@$all_regions, $feat) if ($feat =~ /peg/);
3132 :     #}
3133 : mkubal 1.14 push(@$all_regions,$target_gene_features);
3134 : arodri7 1.16 my (@start_array_region);
3135 : arodri7 1.22 push (@start_array_region, $offset);
3136 : mkubal 1.14
3137 :     my %all_genes;
3138 :     my %all_genomes;
3139 : arodri7 1.42 foreach my $feature (@$target_gene_features){
3140 :     #if ($feature =~ /peg/){
3141 :     $all_genes{$feature} = $fid; $gene_associations->{$feature}->{"main_gene"}=$fid;
3142 :     #}
3143 :     }
3144 :    
3145 : arodri7 1.41 my @selected_sims;
3146 : arodri7 1.16
3147 : arodri7 1.40 if ($compare_or_coupling eq "sims"){
3148 : arodri7 1.37 # get the selected boxes
3149 : arodri7 1.38 my @selected_taxonomy = @$selected_taxonomies;
3150 : arodri7 1.37
3151 :     # get the similarities and store only the ones that match the lineages selected
3152 : arodri7 1.41 if (@selected_taxonomy > 0){
3153 :     foreach my $sim (@$sims_array){
3154 :     next if ($sim->class ne "SIM");
3155 :     next if ($sim->acc !~ /fig\|/);
3156 : arodri7 1.37
3157 : arodri7 1.41 #my $genome = $fig->genome_of($sim->[1]);
3158 :     my $genome = $fig->genome_of($sim->acc);
3159 : arodri7 1.45 #my ($genome1) = ($genome) =~ /(.*)\./;
3160 : arodri7 1.53 my $lineage = $taxes->{$genome};
3161 :     #my $lineage = $fig->taxonomy_of($fig->genome_of($genome));
3162 : arodri7 1.38 foreach my $taxon(@selected_taxonomy){
3163 :     if ($lineage =~ /$taxon/){
3164 : arodri7 1.41 #push (@selected_sims, $sim->[1]);
3165 :     push (@selected_sims, $sim->acc);
3166 : arodri7 1.38 }
3167 : arodri7 1.37 }
3168 :     }
3169 :     }
3170 : arodri7 1.40 else{
3171 :     my $simcount = 0;
3172 : arodri7 1.41 foreach my $sim (@$sims_array){
3173 :     next if ($sim->class ne "SIM");
3174 :     next if ($sim->acc !~ /fig\|/);
3175 :    
3176 :     push (@selected_sims, $sim->acc);
3177 : arodri7 1.40 $simcount++;
3178 :     last if ($simcount > 4);
3179 :     }
3180 :     }
3181 : arodri7 1.16
3182 : arodri7 1.41 my %saw;
3183 :     @selected_sims = grep(!$saw{$_}++, @selected_sims);
3184 :    
3185 : arodri7 1.37 # get the gene context for the sorted matches
3186 :     foreach my $sim_fid(@selected_sims){
3187 :     #get the organism genome
3188 :     my $sim_genome = $fig->genome_of($sim_fid);
3189 : arodri7 1.38 $gene_associations->{$sim_fid}->{"organism"} = $sim_genome;
3190 :     $gene_associations->{$sim_fid}->{"main_gene"} = $sim_fid;
3191 :     $gene_associations->{$sim_fid}->{"reverse_flag"} = 0;
3192 : arodri7 1.37
3193 :     # get location of the gene
3194 :     my $data = $fig->feature_location($sim_fid);
3195 :     my ($contig, $beg, $end);
3196 :    
3197 :     if ($data =~ /(.*)_(\d+)_(\d+)$/){
3198 :     $contig = $1;
3199 :     $beg = $2;
3200 :     $end = $3;
3201 :     }
3202 :    
3203 :     my $offset;
3204 :     my ($region_start, $region_end);
3205 :     if ($beg < $end)
3206 :     {
3207 : arodri7 1.41 $region_start = $beg - ($range/2);
3208 :     $region_end = $end+($range/2);
3209 : arodri7 1.38 $offset = ($beg+(($end-$beg)/2))-($gd_window_size/2);
3210 : arodri7 1.37 }
3211 :     else
3212 :     {
3213 : arodri7 1.41 $region_start = $end-($range/2);
3214 :     $region_end = $beg+($range/2);
3215 : arodri7 1.38 $offset = ($end+(($beg-$end)/2))-($gd_window_size/2);
3216 :     $reverse_flag{$sim_genome} = $sim_fid;
3217 :     $gene_associations->{$sim_fid}->{"reverse_flag"} = 1;
3218 : arodri7 1.37 }
3219 :    
3220 :     # call genes in region
3221 :     my ($sim_gene_features, $reg_beg, $reg_end) = $fig->genes_in_region($sim_genome, $contig, $region_start, $region_end);
3222 :     push(@$all_regions,$sim_gene_features);
3223 :     push (@start_array_region, $offset);
3224 : arodri7 1.38 foreach my $feature (@$sim_gene_features){ $all_genes{$feature} = $sim_fid;$gene_associations->{$feature}->{"main_gene"}=$sim_fid;}
3225 :     $all_genomes{$sim_genome} = 1;
3226 : arodri7 1.16 }
3227 : mkubal 1.14
3228 :     }
3229 : arodri7 1.41
3230 : arodri7 1.42 #print STDERR "START CLUSTER OF GENES IN COMP REGION: " . `date`;
3231 : arodri7 1.38 # cluster the genes
3232 :     my @all_pegs = keys %all_genes;
3233 :     my $color_sets = &cluster_genes($fig,\@all_pegs,$fid);
3234 : arodri7 1.42 #print STDERR "END CLUSTER OF GENES IN COMP REGION: ". `date`;
3235 : arodri7 1.41 my %in_subs = $fig->subsystems_for_pegs(\@all_pegs);
3236 : arodri7 1.21
3237 : mkubal 1.14 foreach my $region (@$all_regions){
3238 :     my $sample_peg = @$region[0];
3239 :     my $region_genome = $fig->genome_of($sample_peg);
3240 :     my $region_gs = $fig->genus_species($region_genome);
3241 : arodri7 1.18 my $abbrev_name = $fig->abbrev($region_gs);
3242 : arodri7 1.45 #my ($genome1) = ($region_genome) =~ /(.*?)\./;
3243 : arodri7 1.53 my $lineage = $taxes->{$region_genome};
3244 :     #my $lineage = $fig->taxonomy_of($region_genome);
3245 : arodri7 1.40 #$region_gs .= "Lineage:$lineage";
3246 : arodri7 1.16 my $line_config = { 'title' => $region_gs,
3247 : arodri7 1.18 'short_title' => $abbrev_name,
3248 : arodri7 1.16 'basepair_offset' => '0'
3249 :     };
3250 :    
3251 : arodri7 1.22 my $offsetting = shift @start_array_region;
3252 : arodri7 1.16
3253 : arodri7 1.40 my $second_line_config = { 'title' => "$lineage",
3254 : arodri7 1.25 'short_title' => "",
3255 : arodri7 1.38 'basepair_offset' => '0',
3256 :     'no_middle_line' => '1'
3257 : arodri7 1.25 };
3258 :    
3259 : mkubal 1.14 my $line_data = [];
3260 : arodri7 1.25 my $second_line_data = [];
3261 :    
3262 :     # initialize variables to check for overlap in genes
3263 :     my ($prev_start, $prev_stop, $prev_fig, $second_line_flag);
3264 :     my $major_line_flag = 0;
3265 :     my $prev_second_flag = 0;
3266 :    
3267 : arodri7 1.16 foreach my $fid1 (@$region){
3268 : arodri7 1.25 $second_line_flag = 0;
3269 : mkubal 1.14 my $element_hash;
3270 :     my $links_list = [];
3271 :     my $descriptions = [];
3272 : arodri7 1.38
3273 :     my $color = $color_sets->{$fid1};
3274 : arodri7 1.26
3275 : arodri7 1.18 # get subsystem information
3276 :     my $function = $fig->function_of($fid1);
3277 : paczian 1.44 my $url_link = "?page=Annotation&feature=".$fid1;
3278 : arodri7 1.18
3279 :     my $link;
3280 :     $link = {"link_title" => $fid1,
3281 :     "link" => $url_link};
3282 :     push(@$links_list,$link);
3283 :    
3284 : arodri7 1.41 my @subs = @{$in_subs{$fid1}} if (defined $in_subs{$fid1});
3285 :     my @subsystems;
3286 :     foreach my $array (@subs){
3287 :     my $subsystem = $$array[0];
3288 :     my $ss = $subsystem;
3289 :     $ss =~ s/_/ /ig;
3290 :     push (@subsystems, $ss);
3291 : arodri7 1.18 my $link;
3292 : paczian 1.44 $link = {"link" => "?page=Subsystems&subsystem=$subsystem",
3293 : arodri7 1.41 "link_title" => $ss};
3294 : arodri7 1.18 push(@$links_list,$link);
3295 :     }
3296 : arodri7 1.41
3297 :     if ($fid1 eq $fid){
3298 :     my $link;
3299 :     $link = {"link_title" => "Annotate this sequence",
3300 :     "link" => "$FIG_Config::cgi_url/seedviewer.cgi?page=Commentary"};
3301 :     push (@$links_list,$link);
3302 :     }
3303 :    
3304 : arodri7 1.18 my $description_function;
3305 :     $description_function = {"title" => "function",
3306 :     "value" => $function};
3307 :     push(@$descriptions,$description_function);
3308 :    
3309 :     my $description_ss;
3310 : arodri7 1.41 my $ss_string = join (", ", @subsystems);
3311 : arodri7 1.18 $description_ss = {"title" => "subsystems",
3312 :     "value" => $ss_string};
3313 :     push(@$descriptions,$description_ss);
3314 :    
3315 : arodri7 1.16
3316 :     my $fid_location = $fig->feature_location($fid1);
3317 : mkubal 1.14 if($fid_location =~/(.*)_(\d+)_(\d+)$/){
3318 :     my($start,$stop);
3319 : arodri7 1.22 $start = $2 - $offsetting;
3320 :     $stop = $3 - $offsetting;
3321 : arodri7 1.25
3322 :     if ( (($prev_start) && ($prev_stop) ) &&
3323 :     ( ($start < $prev_start) || ($start < $prev_stop) ||
3324 :     ($stop < $prev_start) || ($stop < $prev_stop) )){
3325 :     if (($second_line_flag == 0) && ($prev_second_flag == 0)) {
3326 :     $second_line_flag = 1;
3327 :     $major_line_flag = 1;
3328 :     }
3329 :     }
3330 :     $prev_start = $start;
3331 :     $prev_stop = $stop;
3332 :     $prev_fig = $fid1;
3333 :    
3334 : arodri7 1.58 if ((defined($reverse_flag{$region_genome})) && ($reverse_flag{$region_genome} eq $all_gnes{$fid1})){
3335 : arodri7 1.22 $start = $gd_window_size - $start;
3336 :     $stop = $gd_window_size - $stop;
3337 :     }
3338 :    
3339 : arodri7 1.41 my $title = $fid1;
3340 :     if ($fid1 eq $fid){
3341 :     $title = "My query gene: $fid1";
3342 :     }
3343 :    
3344 : mkubal 1.14 $element_hash = {
3345 : arodri7 1.41 "title" => $title,
3346 : mkubal 1.14 "start" => $start,
3347 :     "end" => $stop,
3348 :     "type"=> 'arrow',
3349 :     "color"=> $color,
3350 : arodri7 1.18 "zlayer" => "2",
3351 :     "links_list" => $links_list,
3352 :     "description" => $descriptions
3353 : mkubal 1.14 };
3354 : arodri7 1.25
3355 :     # if there is an overlap, put into second line
3356 :     if ($second_line_flag == 1){ push(@$second_line_data,$element_hash); $prev_second_flag = 1;}
3357 :     else{ push(@$line_data,$element_hash); $prev_second_flag = 0;}
3358 : arodri7 1.41
3359 :     if ($fid1 eq $fid){
3360 :     $element_hash = {
3361 :     "title" => 'Query',
3362 :     "start" => $start,
3363 :     "end" => $stop,
3364 :     "type"=> 'bigbox',
3365 :     "color"=> $color,
3366 :     "zlayer" => "1"
3367 :     };
3368 :    
3369 :     # if there is an overlap, put into second line
3370 :     if ($second_line_flag == 1){ push(@$second_line_data,$element_hash); $prev_second_flag = 1;}
3371 :     else{ push(@$line_data,$element_hash); $prev_second_flag = 0;}
3372 :     }
3373 : mkubal 1.14 }
3374 :     }
3375 :     $gd->add_line($line_data, $line_config);
3376 : arodri7 1.40 $gd->add_line($second_line_data, $second_line_config); # if ($major_line_flag == 1);
3377 : mkubal 1.14 }
3378 : arodri7 1.41 return ($gd, \@selected_sims);
3379 : mkubal 1.14 }
3380 :    
3381 : arodri7 1.38 sub cluster_genes {
3382 :     my($fig,$all_pegs,$peg) = @_;
3383 :     my(%seen,$i,$j,$k,$x,$cluster,$conn,$pegI,$red_set);
3384 :    
3385 :     my @color_sets = ();
3386 :    
3387 :     $conn = &get_connections_by_similarity($fig,$all_pegs);
3388 :    
3389 :     for ($i=0; ($i < @$all_pegs); $i++) {
3390 :     if ($all_pegs->[$i] eq $peg) { $pegI = $i }
3391 :     if (! $seen{$i}) {
3392 :     $cluster = [$i];
3393 :     $seen{$i} = 1;
3394 :     for ($j=0; ($j < @$cluster); $j++) {
3395 :     $x = $conn->{$cluster->[$j]};
3396 :     foreach $k (@$x) {
3397 :     if (! $seen{$k}) {
3398 :     push(@$cluster,$k);
3399 :     $seen{$k} = 1;
3400 :     }
3401 :     }
3402 :     }
3403 :    
3404 :     if ((@$cluster > 1) || ($cluster->[0] eq $pegI)) {
3405 :     push(@color_sets,$cluster);
3406 :     }
3407 :     }
3408 :     }
3409 :     for ($i=0; ($i < @color_sets) && (! &in($pegI,$color_sets[$i])); $i++) {}
3410 :     $red_set = $color_sets[$i];
3411 :     splice(@color_sets,$i,1);
3412 :     @color_sets = sort { @$b <=> @$a } @color_sets;
3413 :     unshift(@color_sets,$red_set);
3414 :    
3415 :     my $color_sets = {};
3416 :     for ($i=0; ($i < @color_sets); $i++) {
3417 :     foreach $x (@{$color_sets[$i]}) {
3418 :     $color_sets->{$all_pegs->[$x]} = $i;
3419 :     }
3420 :     }
3421 :     return $color_sets;
3422 :     }
3423 :    
3424 :     sub get_connections_by_similarity {
3425 :     my($fig,$all_pegs) = @_;
3426 :     my($i,$j,$tmp,$peg,%pos_of);
3427 :     my($sim,%conn,$x,$y);
3428 :    
3429 :     for ($i=0; ($i < @$all_pegs); $i++) {
3430 :     $tmp = $fig->maps_to_id($all_pegs->[$i]);
3431 :     push(@{$pos_of{$tmp}},$i);
3432 :     if ($tmp ne $all_pegs->[$i]) {
3433 :     push(@{$pos_of{$all_pegs->[$i]}},$i);
3434 :     }
3435 :     }
3436 :    
3437 :     foreach $y (keys(%pos_of)) {
3438 : arodri7 1.41 $x = $pos_of{$y};
3439 : arodri7 1.38 for ($i=0; ($i < @$x); $i++) {
3440 :     for ($j=$i+1; ($j < @$x); $j++) {
3441 :     push(@{$conn{$x->[$i]}},$x->[$j]);
3442 :     push(@{$conn{$x->[$j]}},$x->[$i]);
3443 :     }
3444 :     }
3445 :     }
3446 :    
3447 :     for ($i=0; ($i < @$all_pegs); $i++) {
3448 : arodri7 1.42 foreach $sim ($fig->sims($all_pegs->[$i],500,10,"raw")) {
3449 : arodri7 1.38 if (defined($x = $pos_of{$sim->id2})) {
3450 :     foreach $y (@$x) {
3451 :     push(@{$conn{$i}},$y);
3452 :     }
3453 :     }
3454 :     }
3455 :     }
3456 :     return \%conn;
3457 :     }
3458 :    
3459 :     sub in {
3460 :     my($x,$xL) = @_;
3461 :     my($i);
3462 :    
3463 :     for ($i=0; ($i < @$xL) && ($x != $xL->[$i]); $i++) {}
3464 :     return ($i < @$xL);
3465 :     }
3466 : arodri7 1.41
3467 :     #############################################
3468 :     #############################################
3469 :     package Observation::Commentary;
3470 :    
3471 :     use base qw(Observation);
3472 :    
3473 :     =head3 display_protein_commentary()
3474 :    
3475 :     =cut
3476 :    
3477 :     sub display_protein_commentary {
3478 :     my ($self,$dataset,$mypeg,$fig) = @_;
3479 :    
3480 :     my $all_rows = [];
3481 :     my $content;
3482 :     #my $fig = new FIG;
3483 :     my $cgi = new CGI;
3484 :     my $count = 0;
3485 :     my $peg_array = [];
3486 : arodri7 1.60 my ($evidence_column, $subsystems_column, %e_identical);
3487 : arodri7 1.41
3488 :     if (@$dataset != 1){
3489 :     foreach my $thing (@$dataset){
3490 :     if ($thing->class eq "SIM"){
3491 :     push (@$peg_array, $thing->acc);
3492 :     }
3493 :     }
3494 :     # get the column for the evidence codes
3495 : arodri7 1.60 $evidence_column = &Observation::Sims::get_evidence_column($peg_array, undef, $fig, $cgi, 'hash');
3496 : arodri7 1.41
3497 :     # get the column for the subsystems
3498 : arodri7 1.60 $subsystems_column = &Observation::Sims::get_subsystems_column($peg_array,$fig, $cgi, 'array');
3499 : arodri7 1.41
3500 :     # get essentially identical seqs
3501 :     %e_identical = &Observation::Sims::get_essentially_identical($mypeg,$dataset,$fig);
3502 :     }
3503 :     else{
3504 :     push (@$peg_array, @$dataset);
3505 :     }
3506 :    
3507 :     my $selected_sims = [];
3508 :     foreach my $id (@$peg_array){
3509 :     last if ($count > 10);
3510 :     my $row_data = [];
3511 :     my ($set, $org, $ss, $ev, $function, $function_cell, $id_cell);
3512 : arodri7 1.66 if ($fig->org_of($id)){
3513 :     $org = $fig->org_of($id);
3514 :     }
3515 :     else{
3516 :     $org = "Data not available";
3517 :     }
3518 : arodri7 1.41 $function = $fig->function_of($id);
3519 :     if ($mypeg ne $id){
3520 : paczian 1.47 $function_cell = "<input type='radio' name='function' id='$id' value='$function' onClick=\"clearText('setAnnotation');\">&nbsp;&nbsp;$function";
3521 :     $id_cell .= "<a href='?page=Annotation&feature=$id'>$id</a>"; # &HTML::set_prot_links($cgi,$id);
3522 : arodri7 1.41 if (defined($e_identical{$id})) { $id_cell .= "*";}
3523 :     }
3524 :     else{
3525 :     $function_cell = "&nbsp;&nbsp;$function";
3526 : paczian 1.47 $id_cell = "<input type='checkbox' name='peg' id='peg$count' value='$id' checked='true'>";
3527 :     $id_cell .= "<a href='?page=Annotation&feature=$id'>$id</a>"; # &HTML::set_prot_links($cgi,$id);
3528 : arodri7 1.41 }
3529 :    
3530 :     push(@$row_data,$id_cell);
3531 :     push(@$row_data,$org);
3532 : arodri7 1.60 push(@$row_data, $subsystems_column->{$id}) if ($mypeg ne $id);
3533 :     push(@$row_data, $evidence_column->{$id}) if ($mypeg ne $id);
3534 : arodri7 1.41 push(@$row_data, $fig->translation_length($id));
3535 :     push(@$row_data,$function_cell);
3536 :     push(@$all_rows,$row_data);
3537 :     push (@$selected_sims, $id);
3538 :     $count++;
3539 :     }
3540 :    
3541 :     if ($count >0){
3542 :     $content = $all_rows;
3543 :     }
3544 :     else{
3545 :     $content = "<p>This PEG does not have enough similarities to change the commentary</p>";
3546 :     }
3547 :     return ($content,$selected_sims);
3548 :     }
3549 :    
3550 :     sub display_protein_history {
3551 :     my ($self, $id,$fig) = @_;
3552 :     my $all_rows = [];
3553 :     my $content;
3554 :    
3555 :     my $cgi = new CGI;
3556 :     my $count = 0;
3557 :     foreach my $feat ($fig->feature_annotations($id)){
3558 :     my $row = [];
3559 :     my $col1 = $feat->[2];
3560 :     my $col2 = $feat->[1];
3561 :     #my $text = "<pre>" . $feat->[3] . "<\pre>";
3562 :     my $text = $feat->[3];
3563 :    
3564 :     push (@$row, $col1);
3565 :     push (@$row, $col2);
3566 :     push (@$row, $text);
3567 :     push (@$all_rows, $row);
3568 :     $count++;
3569 :     }
3570 :     if ($count > 0){
3571 :     $content = $all_rows;
3572 :     }
3573 :     else {
3574 :     $content = "There is no history for this PEG";
3575 :     }
3576 :    
3577 :     return($content);
3578 :     }
3579 : arodri7 1.58

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3