Skip to content
Snippets Groups Projects
Commit e15560b0 authored by Patrick Meidl's avatar Patrick Meidl
Browse files

improved retrieval of associated ArchiveStableIds for a given ArchiveStableIds...

improved retrieval of associated ArchiveStableIds for a given ArchiveStableIds (e.g. transcripts and translation for genes)
parent e815acb4
No related branches found
No related tags found
No related merge requests found
......@@ -197,7 +197,6 @@ sub get_all_successors {
=head2 get_peptide
Args : none
Example : none
Description : Retrieves the peptide string for this ArchiveStableId.
Returntype : String, or undef if this is not a Translation or cant be found
......@@ -220,12 +219,37 @@ sub get_peptide {
}
=head2 get_all_gene_archive_ids
Example : my @archived_genes = @{ $arch_id->get_all_gene_archive_ids };
Description : Returns gene ArchiveStableIds associated with this
ArchiveStableId. If this is a gene, it returns itself.
Returntype : listref of Bio::EnsEMBL::ArchiveStableId
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub get_all_gene_archive_ids {
my $self = shift;
if ($self->type eq "Gene") {
return [$self];
} else {
return $self->adaptor->fetch_all_by_archive_id($self, 'Gene');
}
}
=head2 get_all_transcript_archive_ids
Args : none
Example : none
Description : If this is a genes ArchiveStableId and found in the database,
this function gets the transcripts archiveStableIds from it.
Example : my @archived_transcripts =
@{ $arch_id->get_all_transcript_archive_ids };
Description : Returns transcript ArchiveStableIds associated with this
ArchiveStableId. If this is a gene, it returns itself.
Returntype : listref of Bio::EnsEMBL::ArchiveStableId
Exceptions : none
Caller : general
......@@ -237,22 +261,20 @@ sub get_peptide {
sub get_all_transcript_archive_ids {
my $self = shift;
my $archive_ids = [];
if( $self->type() eq "Gene" ) {
$archive_ids = $self->adaptor->fetch_all_by_gene_archive_id( $self );
if ($self->type eq "Transcript") {
return [$self];
} else {
return $self->adaptor->fetch_all_by_archive_id($self, 'Transcript');
}
return $archive_ids;
}
=head2 get_all_translation_archive_ids
Args : none
Example : none
Description : Retrieves the Translation ArchiveStableIds for this transcript
stable id.
Example : my @archived_peptides =
@{ $arch_id->get_all_translation_archive_ids };
Description : Returns translation ArchiveStableIds associated with this
ArchiveStableId. If this is a gene, it returns itself.
Returntype : listref of Bio::EnsEMBL::ArchiveStableId
Exceptions : none
Caller : general
......@@ -264,19 +286,10 @@ sub get_all_transcript_archive_ids {
sub get_all_translation_archive_ids {
my $self = shift;
if( $self->type() eq "Transcript" ) {
my $T = $self->adaptor->fetch_by_transcript_archive_id( $self );
return $T ? [$T] : [];
} elsif( $self->type() eq "Gene" ) {
my $transcripts = $self->adaptor->fetch_all_by_gene_archive_id( $self );
my @peptides ;
for (@$transcripts) {
my $T = $self->adaptor->fetch_by_transcript_archive_id( $_ );
push @peptides, $T if $T;
}
return \@peptides;
} else {
if ($self->type eq "Translation") {
return [$self];
} else {
return $self->adaptor->fetch_all_by_archive_id($self, 'Translation');
}
}
......
......@@ -36,8 +36,7 @@ This whole module has a status of At Risk as it is under development.
fetch_by_stable_id
fetch_by_stable_id_version
fetch_by_stable_id_dbname
fetch_all_by_gene_archive_id
fetch_by_transcript_archive_id
fetch_all_by_archive_id
fetch_predecessors_by_archive_id
fetch_successors_by_archive_id
fetch_stable_id_history
......@@ -45,8 +44,6 @@ This whole module has a status of At Risk as it is under development.
fetch_successor_history
get_peptide
list_dbnames
_lookup_version
_resolve_type
=head1 LICENCE
......@@ -231,53 +228,61 @@ sub fetch_by_stable_id_dbname {
}
=head2 fetch_all_by_gene_archive_id
=head2 fetch_all_by_archive_id
Arg [1] : Bio::EnsEMBL::ArchiveStableId $gene_archive_id
Example : none
Description : Given the ArchiveStableId of a gene retrieves ArchiveStableIds
of Transcripts that make that gene.
Arg [1] : Bio::EnsEMBL::ArchiveStableId $archive_id
Arg [2] : String $return_type - type of ArchiveStableId to fetch
Example : my $arch_id = $arch_adaptor->fetch_by_stable_id('ENSG0001');
my @archived_transcripts = $arch_adaptor->fetch_all_by_archive_id($arch_id, 'Transcript');
Description : Given a ArchiveStableId it retrieves associated ArchiveStableIds
of specified type (e.g. retrieve transcripts for genes or vice
versa).
Returntype : listref Bio::EnsEMBL::ArchiveStableId
Exceptions : none
Caller : Bio::EnsEMBL::ArchiveStableId->get_all_transcript_archive_ids
Caller : Bio::EnsEMBL::ArchiveStableId->get_all_gene_archive_ids,
get_all_transcript_archive_ids, get_all_translation_archive_ids
Status : At Risk
: under development
=cut
sub fetch_all_by_gene_archive_id {
sub fetch_all_by_archive_id {
my $self = shift;
my $gene_archive_id = shift;
my $archive_id = shift;
my $return_type = shift;
my @result = ();
my $lc_self_type = lc($archive_id->type);
my $lc_return_type = lc($return_type);
my $sql = qq(
SELECT
ga.transcript_stable_id,
ga.transcript_version,
ga.${lc_return_type}_stable_id,
ga.${lc_return_type}_version,
m.old_db_name,
m.old_release,
m.old_assembly
FROM gene_archive ga, mapping_session m
WHERE ga.gene_stable_id = ?
AND ga.gene_version = ?
WHERE ga.${lc_self_type}_stable_id = ?
AND ga.${lc_self_type}_version = ?
AND ga.mapping_session_id = m.mapping_session_id
);
my $sth = $self->prepare($sql);
$sth->bind_param(1,$gene_archive_id->stable_id,SQL_VARCHAR);
$sth->bind_param(2,$gene_archive_id->version,SQL_SMALLINT);
$sth->execute();
$sth->bind_param(1, $archive_id->stable_id, SQL_VARCHAR);
$sth->bind_param(2, $archive_id->version, SQL_SMALLINT);
$sth->execute;
my ($stable_id, $version, $db_name, $release, $assembly);
$sth->bind_columns(\$stable_id, \$version, \$db_name, \$release, \$assembly);
while( $sth->fetch() ) {
while ($sth->fetch) {
my $new_arch_id = Bio::EnsEMBL::ArchiveStableId->new
(
-version => $version,
-adaptor => $self,
-stable_id => $stable_id,
-type => "Transcript",
-type => $return_type,
-db_name => $db_name,
-release => $release,
-assembly => $assembly
......@@ -291,65 +296,6 @@ sub fetch_all_by_gene_archive_id {
}
=head2 fetch_by_transcript_archive_id
Arg [1] : Bio::EnsEMBL::ArchiveStableId
Example : none
Description : Given a Transcripts ArchiveStableId retrieves the
Translations ArchiveStableId.
Returntype : Bio::EnsEMBL::ArchiveStableId or undef if not in database
Exceptions : none
Caller : Bio::EnsEMBL::ArchiveStableId->get_all_translation_archive_ids
Status : At Risk
: under development
=cut
sub fetch_by_transcript_archive_id {
my $self = shift;
my $transcript_archive_id = shift;
my $sql = qq(
SELECT
ga.translation_stable_id,
ga.translation_version,
m.old_db_name,
m.old_release,
m.old_assembly
FROM gene_archive ga, mapping_session m
WHERE ga.transcript_stable_id = ?
AND ga.transcript_version = ?
AND ga.mapping_session_id = m.mapping_session_id
);
my $sth = $self->prepare( $sql );
$sth->bind_param(1,$transcript_archive_id->stable_id,SQL_VARCHAR);
$sth->bind_param(2,$transcript_archive_id->version,SQL_SMALLINT);
$sth->execute();
my ($stable_id, $version, $db_name, $release, $assembly) = $sth->fetchrow_array();
$sth->finish();
if( $db_name ) {
my $new_arch_id = Bio::EnsEMBL::ArchiveStableId->new
(
-version => $version,
-adaptor => $self,
-stable_id => $stable_id,
-type => "Translation",
-db_name => $db_name,
-release => $release,
-assembly => $assembly
);
return $new_arch_id;
} else {
return undef;
}
}
=head2 fetch_predecessors_by_archive_id
Arg [1] : Bio::EnsEMBL::ArchiveStableId
......@@ -1063,4 +1009,47 @@ sub fetch_all_currently_related {
}
=head2 fetch_all_by_gene_archive_id
Description : DEPRECATED. Please use fetch_all_by_archive_id($archive_id,
'Transcript') instead.
=cut
sub fetch_all_by_gene_archive_id {
my $self = shift;
my $gene_archive_id = shift;
deprecate("Please use fetch_all_by_archive_id(\$archive_id, 'Transcript') instead.");
return $self->fetch_all_by_archive_id($gene_archive_id, 'Transcript');
}
=head2 fetch_by_transcript_archive_id
Description : DEPRECATED. Please use fetch_all_by_archive_id($archive_id,
'Translation') instead. Note that the return type of the new
method is different from this one.
=cut
sub fetch_by_transcript_archive_id {
my $self = shift;
my $transcript_archive_id = shift;
deprecate("Please use fetch_all_by_archive_id(\$archive_id, 'Translation') instead.");
my ($translation_archive_id) =
@{ $self->fetch_all_by_archive_id($transcript_archive_id, 'Translation') };
if ($translation_archive_id) {
return $translation_archive_id;
} else {
return undef;
}
}
1;
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