3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
38 archived information from
EnsEMBL core database.
42 stable_id: eg. ENSG00000000001
44 db_name: eg. homo_sapiens_core_12_31
47 successors: listref of Bio::EnsEMBL::ArchiveStableIds
50 Status: At Risk. This module is in development.
60 package Bio::EnsEMBL::ArchiveStableId;
64 no warnings qw(uninitialized);
67 use Scalar::Util qw(weaken isweak);
71 Arg [STABLE_ID] : String $stable_id
72 Arg [VERSION] : Int $version
73 Arg [CURRENT_VERSION]: Int $current_version
74 Arg [DB_NAME] : String $db_name
75 Arg [RELEASE] : String $release
76 Arg [ASSEMBLY_NAME] : String $assembly
77 Arg [TYPE] : String $type -
"Gene",
"Transcript",
"Translation",
"Exon"
79 Description : standard constructor with named arguments to create
91 $class = ref( $class ) || $class;
93 my $self = bless {}, $class;
95 my ($stable_id, $version, $current_version, $db_name, $release, $assembly,
96 $type, $adaptor) = rearrange([qw( STABLE_ID VERSION CURRENT_VERSION DB_NAME
97 RELEASE ASSEMBLY TYPE ADAPTOR)], @_ );
99 $self->{
'stable_id'} = $stable_id;
100 $self->{
'version'} = $version;
101 $self->{
'current_version'} = $current_version;
102 $self->{
'db_name'} = $db_name;
103 $self->{
'release'} = $release;
104 $self->{
'assembly'} = $assembly;
105 $self->{
'type'} = $type;
106 $self->adaptor($adaptor);
114 Arg [1] : String $stable_id
115 Arg [2] : Int $version
116 Arg [3] : String $db_name
117 Arg [4] : String $release
118 Arg [5] : String $assembly
119 Arg [6] : String $type -
"Gene",
"Transcript",
"Translation",
"Exon"
121 Arg [8] : Int $current_version
122 Description : faster version of above constructor
134 $class = ref ($class) || $class;
137 'stable_id' => $_[0],
144 'current_version' => $_[7],
147 weaken($self->{adaptor})
if ( ! isweak($self->{adaptor}) );
153 =head2 get_history_tree
155 Arg[1] : (optional) Int $num_high_scorers
156 number of mappings per stable ID allowed when filtering
157 Arg[2] : (optional) Int $max_rows
158 maximum number of stable IDs in history tree (used
for
160 Example : my $history_tree = $archive_id->get_history_tree;
161 Description : Returns the history tree of
this ArchiveStableId
170 sub get_history_tree {
171 my ($self, $num_high_scorers, $max_rows) = @_;
173 unless ($self->{
'history'}) {
174 $self->{
'history'} = $self->adaptor->fetch_history_tree_by_stable_id(
175 $self->stable_id, $num_high_scorers, $max_rows);
178 return $self->{
'history'};
185 Description : Retrieve a specific
event for this archive and a given stable
id
195 my ($self, $stable_id) = @_;
197 my $event = $self->adaptor->fetch_stable_id_event($self, $stable_id);
203 =head2 get_all_predecessors
206 Description : Retrieve a list of ArchiveStableIds that were mapped to
this
216 sub get_all_predecessors {
219 my $predecessors = $self->
adaptor->fetch_predecessors_by_archive_id($self);
221 foreach my $pre (@$predecessors) {
222 $pre->successors($self);
225 return $predecessors;
229 =head2 get_all_successors
232 Description : Retrieve a list of ArchiveStableIds that
this one was mapped to.
241 sub get_all_successors {
244 if ($self->{
'successors'}) {
245 return $self->{
'successors'};
247 my $successors = $self->
adaptor->fetch_successors_by_archive_id($self);
248 return $self->successors(@$successors);
255 Description : Retrieves the peptide
string for this ArchiveStableId.
256 Returntype : String, or undef
if this is not a Translation or cant be found
268 if ( lc( $self->type() ) eq
'translation' ) {
269 return $self->
adaptor->get_peptide($self);
276 =head2 get_all_associated_archived
278 Example : my ($arch_gene, $arch_tr, $arch_tl, $pep_seq) =
279 @{ $arch_id->get_all_associated_archived };
280 Description : Fetches associated archived stable IDs from the db
for this
281 ArchiveStableId (version is taken into account).
282 Return type : Listref of
283 ArchiveStableId archived gene
285 (optional) ArchiveStableId archived translation
286 (optional) peptide sequence
287 Caller : webcode, general
293 sub get_all_associated_archived {
295 return $self->adaptor->fetch_associated_archived($self);
299 =head2 get_all_gene_archive_ids
301 Example : my @archived_genes = @{ $arch_id->get_all_gene_archive_ids };
302 Description : Returns gene ArchiveStableIds associated with
this
303 ArchiveStableId. If
this is a gene, it returns itself.
312 sub get_all_gene_archive_ids {
315 if ($self->type eq
"Gene") {
318 return $self->
adaptor->fetch_all_by_archive_id($self,
'Gene');
323 =head2 get_all_transcript_archive_ids
325 Example : my @archived_transcripts =
326 @{ $arch_id->get_all_transcript_archive_ids };
327 Description : Returns
transcript ArchiveStableIds associated with
this
328 ArchiveStableId. If
this is a
transcript, it returns itself.
337 sub get_all_transcript_archive_ids {
340 if ($self->type eq
"Transcript") {
343 return $self->
adaptor->fetch_all_by_archive_id($self,
'Transcript');
348 =head2 get_all_translation_archive_ids
350 Example : my @archived_peptides =
351 @{ $arch_id->get_all_translation_archive_ids };
352 Description : Returns translation ArchiveStableIds associated with
this
353 ArchiveStableId. If
this is a translation, it returns itself.
362 sub get_all_translation_archive_ids {
365 if ($self->type eq
"Translation") {
368 return $self->
adaptor->fetch_all_by_archive_id($self,
'Translation');
373 =head2 current_version
375 Example :
if (my $v = $arch_id->current_version) {
376 print
"Current version of this stable ID ", $v,
"\n";
378 print
"This stable ID is not in the current db.\n";
380 Description : Lazy-loads the current version of stable ID
381 Return type : Boolean (TRUE is current version found,
else FALSE)
389 sub current_version {
393 $self->{
'current_version'} = shift;
394 } elsif (! defined $self->{
'current_version'}) {
395 if (defined $self->adaptor()) {
397 $self->adaptor()->lookup_current($self);
401 return $self->{
'current_version'};
407 Example :
if ($arch_id->is_current) {
408 print $arch_id->version,
" is the current version of this
411 Description : Determines
if the version of
this object is the current version
412 of
this stable ID. Note that
this method doesn
't lazy-load the
413 current version of an ArchiveStableId; if you want to be sure,
414 use current_version() instead.
415 Return type : Boolean (TRUE if it is current, else FALSE)
425 return ($self->{'version
'} == $self->{'current_version
'});
429 =head2 get_latest_incarnation
431 Example : my $latest = $arch_id->get_latest_incarnation;
432 print "Latest version of ".$arch_id->stable_id." is ".
433 $latest->version."\n";
434 Description : Returns the ArchiveStableId representing the latest version
435 of this stable ID. Returns itself if this already is the latest
436 version, otherwise fetches it from the db.
437 Return type : Bio::EnsEMBL::ArchiveStableId
445 sub get_latest_incarnation {
448 return $self if ($self->is_latest);
450 my $latest = $self->adaptor->fetch_by_stable_id($self->stable_id);
457 Arg[1] : (optional) Boolean $is_latest
458 Example : if ($arch_id->is_latest) {
459 print "Version ".$arch_id->version." is the latest version
460 of ".$arch_id->stable_id."\n";
462 Description : Indicates whether this is the latest version of this stable ID.
463 Can also be used as a setter if we know this is the latest
465 Return type : Boolean (TRUE if yes, FALSE if no)
467 Caller : Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor->fetch_by_stable_id, general
475 $self->{'is_latest
'} = shift if (@_);
476 return ($self->{'is_latest
'} || $self->is_current);
481 # getter/setters for attributes
486 $self->{'stable_id
'} = shift if (@_);
487 return $self->{'stable_id
'};
492 $self->{'version
'} = shift if (@_);
493 return $self->{'version
'};
498 $self->{'db_name
'} = shift if (@_);
499 return $self->{'db_name
'};
504 $self->{'release
'} = shift if (@_);
505 return $self->{'release
'};
510 $self->{'assembly
'} = shift if (@_);
511 return $self->{'assembly
'};
516 $self->{'type
'} = shift if (@_);
517 return $self->{'type
'};
522 weaken($self->{'adaptor
'} = shift) if (@_);
523 return $self->{'adaptor
'};
528 $self->{'successors
'} = \@_;
529 return $self->{'successors
'};