Bio::EnsEMBL::Funcgen::DBSQL
DBEntryAdaptor
Toolbar
Summary
Bio::EnsEMBL::DBSQL::DBEntryAdaptor -
MySQL Database queries to load and store external object references.
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
$db_entry_adaptor = $db_adaptor->get_DBEntryAdaptor();
$db_entry = $db_entry_adaptor->fetch_by_dbID($id);
my $gene = $db_adaptor->get_GeneAdaptor->fetch_by_stable_id('ENSG00000101367')
;
@db_entries = @{$db_entry_adaptor->fetch_all_by_Gene($gene)}
;
@gene_ids = $db_entry_adaptor->list_gene_ids_by_extids('BAB15482');
Description
No description!
Methods
Methods description
Arg [1] : string $type - external_db type Arg [2] : string $ensType - ensembl_object_type Arg [3] : (optional) string $extraType other object type to be returned Example : $self->_type_by_external_id(1030, 'Translation'); Description: Gets Returntype : list of dbIDs (gene_id, transcript_id, etc.) Exceptions : none Caller : list_translation_ids_by_extids translationids_by_extids geneids_by_extids Status : Stable |
Arg [1] : string $name - dbprimary_acc Arg [2] : string $ensType - ensembl_object_type Arg [3] : (optional) string $extraType Arg [4] : (optional) string $external_db_name other object type to be returned Example : $self->_type_by_external_id($name, 'regulatory_feature'); Description: Gets Returntype : list of dbIDs (regulatory_feature, external_feature ) Exceptions : none Caller : list_regulatory/external_feature_ids_by_extid Status : Stable |
Arg [1] : string $external_name Arg [2] : (optional) string $external_db_name Example : @tr_ids = $dbea->list_annotated_feature_ids_by_extid('GO:0004835'); Description: Gets a list of annotated_feature IDs by external display IDs Returntype : list of Ints Exceptions : none Caller : unknown Status : At risk |
Arg [1] : string $external_name Arg [2] : (optional) string $external_db_name Example : @tr_ids = $dbea->list_external_feature_ids_by_extid('GO:0004835'); Description: Gets a list of external_feature IDs by external display IDs Returntype : list of Ints Exceptions : none Caller : unknown Status : At risk |
Arg [1] : string $external_name Arg [2] : (optional) string $external_db_name Example : @tr_ids = $dbea->list_feature_type_ids_by_extid('BEAF-32'); Description: Gets a list of regulatory_feature IDs by external display IDs Returntype : list of Ints Exceptions : none Caller : unknown Status : At risk |
Arg [1] : string $external_name Arg [2] : (optional) string $external_db_name Example : @tr_ids = $dbea->list_annotated_feature_ids_by_extid('ENST000000000001'); Description: Gets a list of annotated_feature IDs by external display IDs Returntype : list of Ints Exceptions : none Caller : unknown Status : At risk |
Arg [1] : string $external_id Example : @gene_ids = $dbea->list_regulatory_feature_ids_by_external_db_id(1020); Description: Retrieve a list of regulatory_feature ids by an external identifier that is linked to any of the genes transcripts, translations or the gene itself. NOTE: if more than one external identifier has the same primary accession then genes for each of these is returned. Returntype : list of ints Exceptions : none Caller : unknown Status : Stable |
Arg [1] : string $external_name Arg [2] : (optional) string $external_db_name Example : @tr_ids = $dbea->list_regulatory_feature_ids_by_extid('GO:0004835'); Description: Gets a list of regulatory_feature IDs by external display IDs Returntype : list of Ints Exceptions : none Caller : unknown Status : At risk |
Arg [1] : string $external_name Arg [2] : (optional) string $external_db_name Example : @tr_ids = $dbea->list_gene_ids_by_extids('BCRA2'); Description: Retrieve a list transcript ids by an external identifier that is linked to any of the genes transcripts, translations or the gene itself Returntype : list of ints Exceptions : none Caller : unknown Status : Stable |
Methods code
sub _type_by_external_db_id
{ my ($self, $external_db_id, $ensType, $extraType) = @_;
my $from_sql = '';
my $where_sql = '';
my $ID_sql = "oxr.ensembl_id";
if (defined $extraType) {
throw('Extra types not accomodated in eFG xref schema');
if (lc($extraType) eq 'translation') {
$ID_sql = "tl.translation_id";
} else {
$ID_sql = "t.${extraType}_id";
}
if (lc($ensType) eq 'translation') {
$from_sql = 'transcript t, translation tl, ';
$where_sql = qq(
t.transcript_id = tl.transcript_id AND
tl.translation_id = oxr.ensembl_id AND
t.is_current = 1 AND
);
} else {
$from_sql = 'transcript t, ';
$where_sql = 't.'.lc($ensType).'_id = oxr.ensembl_id AND '.
't.is_current = 1 AND ';
}
}
if(lc($ensType) eq 'regulatoryfeature'){
$from_sql = 'regulatory_feature rf, ';
$where_sql = qq( rf.regulatory_feature_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'externalfeature'){
$from_sql = 'external_feature ef, ';
$where_sql = qq( ef.external_feature_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'annotatedfeature'){
$from_sql = 'annotated_feature af, ';
$where_sql = qq( af.annotated_feature_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'featuretype'){
$from_sql = 'featuretype ft, ';
$where_sql = qq( ft.feature_type_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'probefeature'){
$from_sql = 'probe_feature pf, ';
$where_sql = qq( pf.probe_feature_id = oxr.ensembl_id AND );
}
my $query =
"SELECT $ID_sql
FROM $from_sql xref x, object_xref oxr
WHERE $where_sql x.external_db_id = ? AND
x.xref_id = oxr.xref_id AND oxr.ensembl_object_type= ?";
my %hash = ();
my @result = ();
my $sth = $self->prepare( $query );
$sth->bind_param(1, "$external_db_id", SQL_VARCHAR);
$sth->bind_param(2, $ensType, SQL_VARCHAR);
$sth->execute();
while( my $r = $sth->fetchrow_array() ) {
if( !exists $hash{$r} ) {
$hash{$r} = 1;
push( @result, $r );
}
}
return @result;
}
1; } |
sub _type_by_external_id
{ my ( $self, $name, $ensType, $extraType, $external_db_name ) = @_;
my $from_sql = '';
my $where_sql = '';
my $ID_sql = "oxr.ensembl_id";
if ( defined $extraType ) {
throw('Extra types not accomodated in eFG xref schema');
if ( lc($extraType) eq 'translation' ) {
$ID_sql = "tl.translation_id";
} else {
$ID_sql = "t.${extraType}_id";
}
if ( lc($ensType) eq 'translation' ) {
$from_sql = 'transcript t, translation tl, ';
$where_sql = qq(
t.transcript_id = tl.transcript_id AND
tl.translation_id = oxr.ensembl_id AND
t.is_current = 1 AND
);
} else {
$from_sql = 'transcript t, ';
$where_sql = 't.'
. lc($ensType)
. '_id = oxr.ensembl_id AND '
. 't.is_current = 1 AND ';
}
}
if(lc($ensType) eq 'regulatoryfeature'){
$from_sql = 'regulatory_feature rf, ';
$where_sql = qq( rf.regulatory_feature_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'externalfeature'){
$from_sql = 'external_feature ef, ';
$where_sql = qq( ef.external_feature_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'annotatedfeature'){
$from_sql = 'annotated_feature af, ';
$where_sql = qq( af.annotated_feature_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'featuretype'){
$from_sql = 'featuretype ft, ';
$where_sql = qq( ft.feature_type_id = oxr.ensembl_id AND );
}
elsif(lc($ensType) eq 'probefeature'){
$from_sql = 'probe_feature pf, ';
$where_sql = qq( pf.probe_feature_id = oxr.ensembl_id AND );
}
if ( defined($external_db_name) ) {
$from_sql .= 'external_db xdb, ';
$where_sql .=
'xdb.db_name LIKE '
. $self->dbc()->db_handle()->quote( $external_db_name . '%' )
. ' AND xdb.external_db_id = x.external_db_id AND';
}
my @queries = (
"SELECT $ID_sql
FROM $from_sql xref x, object_xref oxr
WHERE $where_sql x.dbprimary_acc = ? AND
x.xref_id = oxr.xref_id AND
oxr.ensembl_object_type= ?",
"SELECT $ID_sql
FROM $from_sql xref x, object_xref oxr
WHERE $where_sql x.display_label = ? AND
x.xref_id = oxr.xref_id AND
oxr.ensembl_object_type= ?"
);
if ( defined $external_db_name ) {
push @queries, "SELECT $ID_sql
FROM $from_sql xref x, object_xref oxr, external_synonym syn
WHERE $where_sql syn.synonym = ? AND
x.xref_id = oxr.xref_id AND
oxr.ensembl_object_type= ? AND
syn.xref_id = oxr.xref_id";
} else {
push @queries, "SELECT $ID_sql
FROM $from_sql object_xref oxr, external_synonym syn
WHERE $where_sql syn.synonym = ? AND
oxr.ensembl_object_type= ? AND
syn.xref_id = oxr.xref_id";
}
my %hash = ();
my @result = ();
foreach (@queries) {
my $sth = $self->prepare($_);
$sth->bind_param( 1, "$name", SQL_VARCHAR );
$sth->bind_param( 2, $ensType, SQL_VARCHAR );
$sth->execute();
while ( my $r = $sth->fetchrow_array() ) {
if ( !exists $hash{$r} ) {
$hash{$r} = 1;
push( @result, $r );
}
}
}
return @result;
}
} |
sub fetch_all_by_Gene
{ my ( $self, $gene) = @_;
if(! (ref($gene) && $gene->isa('Bio::EnsEMBL::Gene'))) {
throw("Bio::EnsEMBL::Gene argument expected.");
}
throw('Not yet implemented for eFG');
} |
sub fetch_all_by_Transcript
{ my ( $self, $trans) = @_;
throw('Not implemented in eFG, maybe you want the core DBEntryAdaptor?');
if(! $trans->isa('Bio::EnsEMBL::Transcript')){
throw('Must provide a valid stored Bio::EnsEMBL::Transcript');
}
$self->fetch_by_db_accession($trans->stable_id, 'ensembl_core_Gene'); } |
sub fetch_all_by_Translation
{ my ( $self, $trans) = @_;
throw('Not implemented in eFG, maybe you want the core DBEntryAdaptor?');
}
} |
sub list_annotated_feature_ids_by_extid
{ my ( $self, $external_name, $external_db_name ) = @_;
return
$self->_type_by_external_id( $external_name, 'AnnotatedFeature', undef,
$external_db_name ); } |
sub list_external_feature_ids_by_extid
{ my ( $self, $external_name, $external_db_name ) = @_;
return
$self->_type_by_external_id( $external_name, 'ExternalFeature', undef,
$external_db_name ); } |
sub list_feature_type_ids_by_extid
{ my ( $self, $external_name, $external_db_name ) = @_;
return $self->_type_by_external_id( $external_name, 'FeatureType',
undef, $external_db_name ); } |
sub list_gene_ids_by_external_db_id
{ my ($self,$external_db_id) = @_;
throw('Not implemented in eFG, maybe you want the core DBEntryAdaptor?');
my %T = map { ($_, 1) }
$self->_type_by_external_db_id( $external_db_id, 'Translation', 'gene' ),
$self->_type_by_external_db_id( $external_db_id, 'Transcript', 'gene' ),
$self->_type_by_external_db_id( $external_db_id, 'Gene' );
return keys %T; } |
sub list_gene_ids_by_extids
{ my ( $self, $external_name, $external_db_name ) = @_;
throw('Not implemented in eFG, maybe you want the core DBEntryAdaptor?');
my %T = map { ( $_, 1 ) }
$self->_type_by_external_id( $external_name, 'Translation', 'gene',
$external_db_name ),
$self->_type_by_external_id( $external_name, 'Transcript', 'gene',
$external_db_name ),
$self->_type_by_external_id( $external_name, 'Gene', undef,
$external_db_name );
return keys %T; } |
sub list_probe_feature_ids_by_extid
{ my ( $self, $external_name, $external_db_name ) = @_;
return
$self->_type_by_external_id( $external_name, 'ProbeFeature', undef,
$external_db_name ); } |
sub list_regulatory_feature_ids_by_external_db_id
{ my ($self,$external_db_id) = @_;
my %T = map { ($_, 1) }
$self->_type_by_external_db_id( $external_db_id, 'RegulatoryFeature' );
return keys %T; } |
sub list_regulatory_feature_ids_by_extid
{ my ( $self, $external_name, $external_db_name ) = @_;
return $self->_type_by_external_id( $external_name, 'RegulatoryFeature',
undef, $external_db_name ); } |
sub list_transcript_ids_by_extids
{ my ( $self, $external_name, $external_db_name ) = @_;
throw('Not implemented in eFG, maybe you want the core DBEntryAdaptor?');
my %T = map { ( $_, 1 ) }
$self->_type_by_external_id( $external_name, 'Translation',
'transcript', $external_db_name
),
$self->_type_by_external_id( $external_name, 'Transcript', undef,
$external_db_name );
return keys %T; } |
list_translation_ids_by_extids | description | prev | next | Top |
sub list_translation_ids_by_extids
{ my ( $self, $external_name, $external_db_name ) = @_;
throw('Not implemented in eFG, maybe you want the core DBEntryAdaptor?');
return
$self->_type_by_external_id( $external_name, 'Translation', undef,
$external_db_name ); } |
General documentation
Arg [1] : string $dbname - The name of the database which the provided
accession is for.
Arg [2] : string $accession - The accesion of the external reference to
retrieve.
Example : my $xref = $dbea->fetch_by_db_accession('Interpro','IPR003439');
print $xref->description(), "\n" if($xref);
Description: Retrieves a DBEntry (xref) via the name of the database it is
from and its primary accession in that database. Undef is
returned if the xref cannot be found in the database.
Returntype : Bio::EnsEMBL::DBSQL::DBEntry
Exceptions : thrown if arguments are incorrect
Caller : general, domainview
Status : Stable
Arg [1] : string $ensID
Arg [2] : string $ensType
(object type to be returned)
Arg [3] : optional $exdbname (external database name)
Arf [4] : optional $exdb_type (external database type)
Example : $self->_fetch_by_object_type( $translation_id, 'Translation' )
Description: Fetches DBEntry by Object type
Returntype : arrayref of DBEntry objects; may be of type IdentityXref if
there is mapping data, or GoXref if there is linkage data.
Exceptions : none
Caller : fetch_all_by_Gene
fetch_all_by_Translation
fetch_all_by_Transcript
Status : Stable