Commit a9ac8581 authored by Matthew Laird's avatar Matthew Laird
Browse files

Jira ENSCORESW-1381

- Added fetch_by_stable_id_version to TranslationAdaptor for consistency
- Related tests for new function
parent 09abe4f6
......@@ -775,6 +775,44 @@ sub fetch_by_stable_id {
return $self->fetch_by_Transcript($transcript);
}
=head2 fetch_by_stable_id_version
Arg [1] : String $id
The stable ID of the gene to retrieve
Arg [2] : Integer $version
The version of the stable_id to retrieve
Example : $gene = $gene_adaptor->fetch_by_stable_id('ENSG00000148944', 14);
Description: Retrieves a gene object from the database via its stable id and version.
The gene will be retrieved in its native coordinate system (i.e.
in the coordinate system it is stored in the database). It may
be converted to a different coordinate system through a call to
transform() or transfer(). If the gene or exon is not found
undef is returned instead.
Returntype : Bio::EnsEMBL::Gene or undef
Exceptions : if we cant get the gene in given coord system
Caller : general
Status : Stable
=cut
sub fetch_by_stable_id_version {
my ($self,$stable_id, $version) = @_;
if(!$stable_id) {
throw("stable id argument is required");
}
# Enforce that version be numeric
return unless($version =~ /^\d+$/);
my $transcript_adaptor = $self->db()->get_TranscriptAdaptor();
my $transcript =
$transcript_adaptor->fetch_by_translation_stable_id_version($stable_id, $version);
return if(!$transcript);
return $self->fetch_by_Transcript($transcript);
}
=head2 fetch_all_by_Transcript_list
......
......@@ -113,6 +113,12 @@ ok($translation && $translation->dbID() == 21734, 'fetch_by_stable_id with versi
$translation = $ta->fetch_by_stable_id('ENSP00000201961.1a');
ok(!defined($translation), 'fetch_by_stable_id with bad version');
$translation = $ta->fetch_by_stable_id_version('ENSP00000201961', 1);
ok($translation && $translation->dbID() == 21734, 'fetch_by_stable_id_version');
$translation = $ta->fetch_by_stable_id_version('ENSP00000201961', '1a');
ok(!defined($translation), 'fetch_by_stable_id_version with bad version');
#
# test fetch_by_external_name
#
......
Markdown is supported
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