435 |
=cut |
=cut |
436 |
|
|
437 |
sub get_sims_summary { |
sub get_sims_summary { |
438 |
my ($observation, $fid) = @_; |
my ($observation, $fid, $taxes) = @_; |
439 |
my $fig = new FIG; |
my $fig = new FIG; |
440 |
my %families; |
my %families; |
441 |
my @sims= $fig->nsims($fid,20000,10,"fig"); |
my @sims= $fig->nsims($fid,20000,10,"fig"); |
443 |
foreach my $sim (@sims){ |
foreach my $sim (@sims){ |
444 |
next if ($sim->[1] !~ /fig\|/); |
next if ($sim->[1] !~ /fig\|/); |
445 |
my $genome = $fig->genome_of($sim->[1]); |
my $genome = $fig->genome_of($sim->[1]); |
446 |
my $taxonomy = $fig->taxonomy_of($fig->genome_of($sim->[1])); |
my ($genome1) = ($genome) =~ /(.*)\./; |
447 |
|
my $taxonomy = $taxes->{$genome1}; |
448 |
|
#my $taxonomy = $fig->taxonomy_of($fig->genome_of($sim->[1])); # use this if the taxonomies have been updated |
449 |
my $parent_tax = "Root"; |
my $parent_tax = "Root"; |
450 |
my @currLineage = ($parent_tax); |
my @currLineage = ($parent_tax); |
451 |
foreach my $tax (split(/\; /, $taxonomy)){ |
foreach my $tax (split(/\; /, $taxonomy)){ |
453 |
push (@currLineage, $tax); |
push (@currLineage, $tax); |
454 |
$families{parent}{$tax} = $parent_tax; |
$families{parent}{$tax} = $parent_tax; |
455 |
$families{lineage}{$tax} = join(";", @currLineage); |
$families{lineage}{$tax} = join(";", @currLineage); |
456 |
|
if (defined ($families{evalue}{$tax})){ |
457 |
|
if ($sim->[10] < $families{evalue}{$tax}){ |
458 |
|
$families{evalue}{$tax} = $sim->[10]; |
459 |
|
$families{color}{$tax} = &get_taxcolor($sim->[10]); |
460 |
|
} |
461 |
|
} |
462 |
|
else{ |
463 |
|
$families{evalue}{$tax} = $sim->[10]; |
464 |
|
$families{color}{$tax} = &get_taxcolor($sim->[10]); |
465 |
|
} |
466 |
|
|
467 |
$parent_tax = $tax; |
$parent_tax = $tax; |
468 |
} |
} |
469 |
} |
} |
486 |
|
|
487 |
=cut |
=cut |
488 |
|
|
489 |
|
sub get_taxcolor{ |
490 |
|
my ($evalue) = @_; |
491 |
|
my $color; |
492 |
|
if ($evalue <= 1e-170){ $color = "#FF2000"; } |
493 |
|
elsif (($evalue <= 1e-120) && ($evalue > 1e-170)){ $color = "#FF3300"; } |
494 |
|
elsif (($evalue <= 1e-90) && ($evalue > 1e-120)){ $color = "#FF6600"; } |
495 |
|
elsif (($evalue <= 1e-70) && ($evalue > 1e-90)){ $color = "#FF9900"; } |
496 |
|
elsif (($evalue <= 1e-40) && ($evalue > 1e-70)){ $color = "#FFCC00"; } |
497 |
|
elsif (($evalue <= 1e-20) && ($evalue > 1e-40)){ $color = "#FFFF00"; } |
498 |
|
elsif (($evalue <= 1e-5) && ($evalue > 1e-20)){ $color = "#CCFF00"; } |
499 |
|
elsif (($evalue <= 1) && ($evalue > 1e-5)){ $color = "#66FF00"; } |
500 |
|
elsif (($evalue <= 10) && ($evalue > 1)){ $color = "#00FF00"; } |
501 |
|
else{ $color = "#6666FF"; } |
502 |
|
return ($color); |
503 |
|
} |
504 |
|
|
505 |
|
|
506 |
sub get_attribute_based_domain_observations{ |
sub get_attribute_based_domain_observations{ |
507 |
|
|
508 |
# we read a FIG ID and a reference to an array (of arrays of hashes, see above) |
# we read a FIG ID and a reference to an array (of arrays of hashes, see above) |
2129 |
|
|
2130 |
sub color { |
sub color { |
2131 |
my ($evalue) = @_; |
my ($evalue) = @_; |
|
|
|
2132 |
my $color; |
my $color; |
2133 |
if ($evalue <= 1e-170){ |
if ($evalue <= 1e-170){ $color = 51; } |
2134 |
$color = 51; |
elsif (($evalue <= 1e-120) && ($evalue > 1e-170)){ $color = 52; } |
2135 |
} |
elsif (($evalue <= 1e-90) && ($evalue > 1e-120)){ $color = 53; } |
2136 |
elsif (($evalue <= 1e-120) && ($evalue > 1e-170)){ |
elsif (($evalue <= 1e-70) && ($evalue > 1e-90)){ $color = 54; } |
2137 |
$color = 52; |
elsif (($evalue <= 1e-40) && ($evalue > 1e-70)){ $color = 55; } |
2138 |
} |
elsif (($evalue <= 1e-20) && ($evalue > 1e-40)){ $color = 56; } |
2139 |
elsif (($evalue <= 1e-90) && ($evalue > 1e-120)){ |
elsif (($evalue <= 1e-5) && ($evalue > 1e-20)){ $color = 57; } |
2140 |
$color = 53; |
elsif (($evalue <= 1) && ($evalue > 1e-5)){ $color = 58; } |
2141 |
} |
elsif (($evalue <= 10) && ($evalue > 1)){ $color = 59; } |
2142 |
elsif (($evalue <= 1e-70) && ($evalue > 1e-90)){ |
else{ $color = 60; } |
|
$color = 54; |
|
|
} |
|
|
elsif (($evalue <= 1e-40) && ($evalue > 1e-70)){ |
|
|
$color = 55; |
|
|
} |
|
|
elsif (($evalue <= 1e-20) && ($evalue > 1e-40)){ |
|
|
$color = 56; |
|
|
} |
|
|
elsif (($evalue <= 1e-5) && ($evalue > 1e-20)){ |
|
|
$color = 57; |
|
|
} |
|
|
elsif (($evalue <= 1) && ($evalue > 1e-5)){ |
|
|
$color = 58; |
|
|
} |
|
|
elsif (($evalue <= 10) && ($evalue > 1)){ |
|
|
$color = 59; |
|
|
} |
|
|
else{ |
|
|
$color = 60; |
|
|
} |
|
|
|
|
|
|
|
2143 |
return ($color); |
return ($color); |
2144 |
} |
} |
2145 |
|
|
2159 |
} |
} |
2160 |
|
|
2161 |
sub display { |
sub display { |
2162 |
my ($self,$gd,$selected_taxonomies) = @_; |
my ($self,$gd,$selected_taxonomies,$taxes) = @_; |
2163 |
|
|
2164 |
my $fid = $self->fig_id; |
my $fid = $self->fig_id; |
2165 |
my $compare_or_coupling = $self->context; |
my $compare_or_coupling = $self->context; |
2267 |
foreach my $sim (@sims){ |
foreach my $sim (@sims){ |
2268 |
next if ($sim->[1] !~ /fig\|/); |
next if ($sim->[1] !~ /fig\|/); |
2269 |
my $genome = $fig->genome_of($sim->[1]); |
my $genome = $fig->genome_of($sim->[1]); |
2270 |
my $lineage = $fig->taxonomy_of($fig->genome_of($sim->[1])); |
my ($genome1) = ($genome) =~ /(.*)\./; |
2271 |
|
my $lineage = $taxes->{$genome1}; |
2272 |
|
#my $lineage = $fig->taxonomy_of($fig->genome_of($sim->[1])); |
2273 |
foreach my $taxon(@selected_taxonomy){ |
foreach my $taxon(@selected_taxonomy){ |
2274 |
if ($lineage =~ /$taxon/){ |
if ($lineage =~ /$taxon/){ |
2275 |
push (@selected_sims, $sim->[1]); |
push (@selected_sims, $sim->[1]); |