Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/IdMapping/ScoredMappingMatrix.pm view on Meta::CPAN
my $sub_matrix = Bio::EnsEMBL::IdMapping::ScoredMappingMatrix->new(
-DUMP_PATH => $self->dump_path,
-CACHE_FILE => $self->cache_file_name,
);
my $i = 0;
foreach my $key (sort keys %{ $self->{'cache'}->{'matrix'} }) {
$i++;
next if ($i < $start);
last if ($i > $end);
my ($source, $target) = split(/:/, $key);
$sub_matrix->add_score($source, $target,
$self->{'cache'}->{'matrix'}->{$key});
}
return $sub_matrix;
}
=head2 add_Entry
Arg[1] : Bio::EnsEMBL::IdMapping::Entry $entry - Entry to add
Example : $gene_scores->add_Entry($entry);
Description : Adds an Entry to the scoring matrix.
Return type : Float - the Entry's score
Exceptions : thrown on wrong or missing argument
Caller : general
Status : At Risk
: under development
=cut
sub add_Entry {
my $self = shift;
my $entry = shift;
unless ($entry and $entry->isa('Bio::EnsEMBL::IdMapping::Entry')) {
throw("Need a Bio::EnsEMBL::IdMapping::Entry");
}
return $self->add_score($entry->source, $entry->target, $entry->score);
}
=head2 update_Entry
Arg[1] : Bio::EnsEMBL::IdMapping::Entry $entry - Entry to update
Example : $gene_scores->update_Entry($entry);
Description : Updates an Entry (or rather its score) in the scoring matrix.
Actually delegates to add_Entry(), only there as an intuitively
named wrapper.
Return type : Float - the Entry's score
Exceptions : thrown on wrong or missing argument
Caller : general
Status : At Risk
: under development
=cut
sub update_Entry {
return $_[0]->add_Entry($_[1]);
}
#
# not needed in the current application, so not implemented
#
sub remove_Entry {
warning('Method ScoredMappingMatrix->remove_Entry not implemented (yet).');
}
=head2 add_score
Arg[1] : Int $source - source object's internal Id ("dbID")
Arg[2] : Int $target - target object's internal Id ("dbID")
Arg[3] : Float $score - score for source/target pair
Example : $gene_scores->add_score(1234, 5678, 0.997);
Description : Adds a score for a source/target pair to the scoring matrix.
This is a low-level version of add_Entry().
Return type : Float - the score
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub add_score {
my $self = shift;
my $source = shift;
my $target = shift;
my $score = shift;
# make sure you don't put duplicates on the source and target lists
unless (exists($self->{'cache'}->{'matrix'}->{"$source:$target"})) {
push @{ $self->{'cache'}->{'source_list'}->{$source} }, $target;
push @{ $self->{'cache'}->{'target_list'}->{$target} }, $source;
}
$self->{'cache'}->{'matrix'}->{"$source:$target"} = $score;
}
=head2 set_score
Arg[1] : Int $source - source object's internal Id ("dbID")
Arg[2] : Int $target - target object's internal Id ("dbID")
Arg[3] : Float $score - score for source/target pair
Example : $gene_scores->set_score(1234, 5678, 0.997);
Description : Sets the score for a source/target pair in the scoring matrix.
This method is similar to add_score, but assumes that the Entry
has been added before, so won't update the sources and target
lists.
Return type : Float - the score
Exceptions : none
Caller : general
Status : At Risk
: under development
( run in 0.635 second using v1.01-cache-2.11-cpan-f56aa216473 )