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

Annotation of /FigKernelPackages/Observation.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3