Skip to content
Snippets Groups Projects
Commit 249fb779 authored by Kieron Taylor's avatar Kieron Taylor :angry:
Browse files

[ENSCORESW-1050] Cure issues with get_nearest_Gene caused by minor invocation bugs.

parent 9861ea20
No related branches found
No related tags found
No related merge requests found
......@@ -1476,8 +1476,8 @@ sub remove_by_feature_id {
sub fetch_nearest_by_Feature {
my $self = shift;
my $feature = shift;
my @hits = @{ $self->fetch_all_by_outward_search(-FEATURE => $feature, -MAX_RANGE => 1000000, -RANGE => 1000 -LIMIT => 1) };
return $hits[0] if (@hits > 0);
my @hits = @{ $self->fetch_all_by_outward_search(-FEATURE => $feature, -MAX_RANGE => 1000000, -RANGE => 1000, -LIMIT => 1) };
return $hits[0] if (scalar @hits > 0);
return;
}
......
......@@ -1440,7 +1440,7 @@ sub get_overlapping_Genes{
=head2 get_nearest_Gene
Description: Get the nearest genes to the feature
Returntype : listref of Bio::EnsEMBL::Gene
Returntype : Bio::EnsEMBL::Gene
Caller : general
Status : At risk
......@@ -1449,7 +1449,8 @@ sub get_overlapping_Genes{
sub get_nearest_Gene {
my $self = shift;
my $ga = Bio::EnsEMBL::Registry->get_adaptor($self->adaptor->db->species,'core','Gene');
return $ga->fetch_nearest_by_Feature($self);
my ($gene, $distance) = @{ $ga->fetch_nearest_by_Feature($self) };
return $gene;
}
=head2 summary_as_hash
......
......@@ -245,19 +245,13 @@ cmp_ok($results[3]->[0]->display_id, 'eq', 'c', 'Check for a feature found outsi
### Issues/Todos ###
#
#2 Ordering is wrong and seemingly arbitrary when dealing with negative numbers. Drop
# negative numbers, such that the distances are standardised.
# This will be useful for filtering, which will be a common task, and leave up/downsteam
# detection to users, as this will be much less common?
#6 For streamed queries we probably do not want to return features where the target measurement point is enclosed
# by the source feature. This suggests we should change the functionality of -NOT_OVERLAPPING to -INCLUDE_ENCLOSED
# Including overlaps should be the default for non-streamed queries
# 8 Strand tests seem lacking, so we need to add a target feature on the negative strand for each context?
# 10 STRAND could be renamed, as this is a little ambiguous to. Could be -TARGET_STRAND ?
# Also take +/- aswell as 1/-1?
# 13 Add iterator
note("Nathan's tests");
my $g = Bio::EnsEMBL::SimpleFeature->new(
......@@ -458,11 +452,23 @@ sub print_what_you_got {
note ("Results: ".scalar @$results." features");
if (scalar(@$results) == 0) { note("No hits"); return;}
for (my $i =0; $i<scalar(@$results);$i++) {
my ($feature,$distance,$effective,$length,$dbID) = @{$results->[$i]};
my ($feature,$distance) = @{$results->[$i]};
no warnings 'uninitialized';
note("Feature: ".$feature->display_id." at ".$distance.", ".$effective.", length: ".$length);
note("Feature: ".$feature->display_id." at ".$distance);
}
}
# test utility functions get_nearest_Gene and
$dba = $db->get_DBAdaptor('core');
my $tra = $dba->get_TranscriptAdaptor();
my $ga = $dba->get_GeneAdaptor();
my $enst = $tra->fetch_by_stable_id('ENST00000300415');
my $gene;
($gene,$distance) = @{ $ga->fetch_nearest_by_Feature($enst) };
is($gene->stable_id, 'ENSG00000101331','Simple usecase for fetch_nearest_by_Feature');
my $ensg = $enst->get_nearest_Gene;
# diag(Dumper $ensg);
is($ensg->stable_id,'ENSG00000101331','Simple usecase for get_nearest_Gene');
done_testing;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment