Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/DBSQL/ArchiveStableIdAdaptor.pm view on Meta::CPAN
sub lookup_current {
my $self = shift;
my $arch_id = shift;
my $type = lc( $arch_id->type );
unless ($type) {
warning("Can't lookup current version without a type.");
return 0;
}
my $sql = qq(
SELECT version FROM ${type}
WHERE stable_id = ?
);
my $sth = $self->prepare($sql);
$sth->execute( $arch_id->stable_id );
my ($version) = $sth->fetchrow_array;
$sth->finish;
if ($version) {
$arch_id->current_version($version);
return 1;
}
# didn't find a current version
return 0;
} ## end sub lookup_current
# infer type from stable ID format
sub _resolve_type {
my $self = shift;
my $arch_id = shift;
my $stable_id = $arch_id->stable_id();
my $id_type;
# first, try to infer type from stable ID format
#
# Anopheles IDs
if ($stable_id =~ /^AGAP.*/) {
if ($stable_id =~ /.*-RA/) {
$id_type = "Transcript";
} elsif ($stable_id =~ /.*-PA/) {
$id_type = "Translation";
} else {
$id_type = "Gene";
}
# standard Ensembl IDs
} elsif ($stable_id =~ /.*G\d+(\.\d+)?$/) {
$id_type = "Gene";
} elsif ($stable_id =~ /.*T\d+(\.\d+)?$/) {
$id_type = "Transcript";
} elsif ($stable_id =~ /.*P\d+(\.\d+)?$/) {
$id_type = "Translation";
} elsif ($stable_id =~ /.*E\d+(\.\d+)?$/) {
$id_type = "Exon";
# if guessing fails, look in db
} else {
my $sql = qq(
SELECT type from stable_id_event
WHERE old_stable_id = ?
OR new_stable_id = ?
);
my $sth = $self->prepare($sql);
$sth->execute($stable_id, $stable_id);
($id_type) = $sth->fetchrow_array;
$sth->finish;
}
warning("Couldn't resolve stable ID type.") unless ($id_type);
$arch_id->type($id_type);
}
1;
( run in 2.378 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )