Commit ffb686da authored by Emmanuel Mongin's avatar Emmanuel Mongin
Browse files

Change quite a lot of stuff to try to comply with the new DBentry schema. Also...

Change quite a lot of stuff to try to comply with the new DBentry schema. Also added new methods in DBEntry (display_id) and in DBEntryAdaptor (few methods to get geneids, ... out with a DBEntry).

E.
parent 6a386d38
......@@ -49,13 +49,14 @@ sub new {
my $self = bless {},$class;
my ( $adaptor, $dbID, $primary_id, $version,
$dbname, $release ) = $self->_rearrange
$dbname, $release, $display_id ) = $self->_rearrange
( [ qw { ADAPTOR
DBID
PRIMARY_ID
VERSION
DBNAME
RELEASE
DISPLAY_ID
}], @args );
if( defined $adaptor ) { $self->adaptor( $adaptor )}
......@@ -64,6 +65,7 @@ sub new {
if( defined $version ) { $self->version( $version ) }
if( defined $dbname ) { $self->dbname( $dbname ) }
if( defined $release) { $self->release( $release ) }
if( defined $display_id) { $self->display_id( $display_id ) }
$self->{_synonyms} = [];;
return $self;
......@@ -78,6 +80,27 @@ sub primary_id {
return $self->{_primary_id};
}
=head2 display_id
Title : display_id
Usage : $obj->display_id($newval)
Function:
Returns : value of display_id
Args : newvalue (optional)
=cut
sub display_id{
my ( $self, $arg ) = @_;
if( defined $arg ) {
$self->{_display_id} = $arg;
}
return $self->{_display_id};
}
sub dbname {
my ( $self, $arg ) = @_;
if( defined $arg ) {
......@@ -94,7 +117,7 @@ sub database {
sub optional_id {
my $self = shift;
return "";
return $self->display_id;
}
......
......@@ -267,6 +267,116 @@ sub _fetch_by_EnsObject_type {
return @out;
}
=head2 geneids_by_extids
Title : geneids_by_extids
Usage :
Function:
Example :
Returns :
Args :
=cut
sub geneids_by_extids{
my ($self,$name) = @_;
return $self->_type_by_external_id($name,'Gene');
}
=head2 transcriptids_by_extids
Title : transcriptids_by_extids
Usage :
Function:
Example :
Returns :
Args :
=cut
sub transcriptids_by_extids{
my ($self,$name) = @_;
return $self->_type_by_external_id($name,'Transcript');
}
=head2 translationids_by_extids
Title : translationids_by_extids
Usage :
Function:
Example :
Returns :
Args :
=cut
sub translationids_by_extids{
my ($self,$name) = @_;
return $self->_type_by_external_id($name,'Transcript');
}
=head2 rawContigids_by_extids
Title : rawContigids_by_extids
Usage :
Function:
Example :
Returns :
Args :
=cut
sub rawContigids_by_extids{
my ($self,$name) = @_;
return $self->_type_by_external_id($name,'rawContig');
}
=head2 _type_by_external_id
Title : _fetch_type_by_external_id
Usage :
Function:
Example :
Returns :
Args :
=cut
sub _type_by_external_id{
my ($self,$name,$ensType) = @_;
my @out;
my $sth = $self->prepare( "
SELECT oxr.ensembl_id
FROM Xref, externalDB exDB, objectXref oxr, externalSynonym syn
WHERE (Xref.dbprimary_id = '$name'
AND Xref.xrefId = oxr.xrefId
AND oxr.ensembl_object_type = '$ensType')
OR (Xref.display_id = '$name'
AND Xref.xrefId = oxr.xrefId
AND oxr.ensembl_object_type = '$ensType')
OR (syn.synonym = '$name'
AND syn.xrefId = oxr.xrefId
AND oxr.ensembl_object_type = '$ensType')
" );
$sth->execute();
while ( my $arrRef = $sth->fetchrow_arrayref() ) {
my ( $ensID) =
@$arrRef;;
push (@out,$ensID);
}
return @out;
}
# creates all tables for this adaptor
# if they exist they are emptied and newly created
......@@ -291,6 +401,7 @@ sub create_tables {
xrefId INT not null auto_increment,
externalDBId int not null,
dbprimary_id VARCHAR(40) not null,
display_id VARCHAR(40) not null,
version VARCHAR(10),
description VARCHAR(255),
PRIMARY KEY( xrefId ),
......
......@@ -65,6 +65,7 @@ use Bio::EnsEMBL::StickyExon;
use Bio::EnsEMBL::DBSQL::DummyStatement;
use Bio::EnsEMBL::DB::Gene_ObjI;
use Bio::EnsEMBL::DBSQL::DBEntryAdaptor;
@ISA = qw(Bio::EnsEMBL::DB::Gene_ObjI Bio::Root::RootI);
......@@ -818,30 +819,45 @@ sub _get_dblinks{
}
my $geneid = $gene->id;
my $query = "select external_db,external_id from genedblink where gene_id = '$geneid'";
my $sth = $self->_db_obj->prepare($query);
my $res = $sth ->execute();
while( (my $hash = $sth->fetchrow_hashref()) ) {
my $dblink = Bio::Annotation::DBLink->new();
$dblink->database($hash->{'external_db'});
$dblink->primary_id($hash->{'external_id'});
$gene->add_DBLink($dblink);
my $entryAdaptor = $self->_db_obj->get_DBEntryAdaptor();
my @gene_xrefs = $entryAdaptor->fetch_by_gene($geneid);
#
# my $query = "select external_db,external_id from genedblink where gene_id = '$geneid'";
# my $sth = $self->_db_obj->prepare($query);
# my $res = $sth ->execute();
# while( (my $hash = $sth->fetchrow_hashref()) ) {
# my $dblink = Bio::Annotation::DBLink->new();
# $dblink->database($hash->{'external_db'});
# $dblink->primary_id($hash->{'external_id'});
foreach my $genelink (@gene_xrefs) {
$gene->add_DBLink($genelink);
}
# }
#
foreach my $trans ( $gene->each_Transcript ) {
my $transid = $trans->id;
my @transcript_xrefs = $entryAdaptor->fetch_by_transcript($transid);
$query = "select external_db,external_id from transcriptdblink where transcript_id = '$transid'";
$sth = $self->_db_obj->prepare($query);
$res = $sth ->execute();
while( (my $hash = $sth->fetchrow_hashref()) ) {
my $dblink = Bio::Annotation::DBLink->new();
$dblink->database($hash->{'external_db'});
$dblink->primary_id($hash->{'external_id'});
$trans->add_DBLink($dblink);
foreach my $translink(@transcript_xrefs) {
$trans->add_DBLink($translink);
}
}
# $query = "select external_db,external_id from transcriptdblink where transcript_id = '$transid'";
# $sth = $self->_db_obj->prepare($query);
# $res = $sth ->execute();
# while( (my $hash = $sth->fetchrow_hashref()) ) {
#
# my $dblink = Bio::Annotation::DBLink->new();
# $dblink->database($hash->{'external_db'});
# $dblink->primary_id($hash->{'external_id'});
# $trans->add_DBLink($dblink);
# }
# }
} # _get_dblinks
=head2 _get_description
......@@ -948,10 +964,18 @@ sub get_Gene_array_by_DBLink {
my $supporting = shift;
my @genes;
my $sth = $self->_db_obj->prepare("select gene_id from genedblink where external_id = '$external_id'");
$sth->execute;
my $entryAdaptor = $self->_db_obj->get_DBEntryAdaptor();
my @ids = $entryAdaptor->geneids_by_extids($external_id);
my $seen=0;
while (my ($geneid)=$sth->fetchrow_array()) {
foreach my $geneid(@ids) {
#my $sth = $self->_db_obj->prepare("select gene_id from genedblink where external_id = '$external_id'");
#$sth->execute;
#while (my ($geneid)=$sth->fetchrow_array()) {
push (@genes,$self->get($geneid,$supporting));
$seen=1;
}
......
......@@ -345,9 +345,9 @@ sub get_interproac_by_signature_id{
sub _set_protein_feature{
my ($self,$rowhash) = @_;
#my $analysis = $self->_feature_obj->get_Analysis($rowhash->{'analysis'});
my $analysis = $self->_feature_obj->get_Analysis($rowhash->{'analysis'});
my $analysis = $self->_feature_obj->get_Analysis(7);
#my $analysis = $self->_feature_obj->get_Analysis(7);
my $feat1 = new Bio::EnsEMBL::SeqFeature ( -seqname => $rowhash->{'translation'},
......
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