Skip to content
Snippets Groups Projects
Commit b3861b19 authored by Arne Stabenau's avatar Arne Stabenau
Browse files

added biotype, source, confidence removed description as separate table

parent a90b9f0d
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,6 @@ sub _tables {
my $self = shift;
return ([ 'gene', 'g' ],
[ 'gene_description', 'gd' ],
[ 'gene_stable_id', 'gsi' ],
[ 'xref', 'x' ],
[ 'external_db' , 'exdb' ]);
......@@ -91,8 +90,9 @@ sub _columns {
my $self = shift;
return qw( g.gene_id g.seq_region_id g.seq_region_start g.seq_region_end
g.seq_region_strand g.analysis_id g.type g.display_xref_id
gd.description gsi.stable_id gsi.version UNIX_TIMESTAMP(gsi.created_date)
g.seq_region_strand g.analysis_id g.biotype g.display_xref_id
g.description g.confidence g.source
gsi.stable_id gsi.version UNIX_TIMESTAMP(gsi.created_date)
UNIX_TIMESTAMP(gsi.modified_date)
x.display_label x.dbprimary_acc x.description x.version
exdb.db_name exdb.status exdb.release );
......@@ -100,8 +100,7 @@ sub _columns {
sub _left_join {
return ( [ 'gene_description', "gd.gene_id = g.gene_id" ],
[ 'gene_stable_id', "gsi.gene_id = g.gene_id" ],
return ( [ 'gene_stable_id', "gsi.gene_id = g.gene_id" ],
[ 'xref', "x.xref_id = g.display_xref_id" ],
[ 'external_db', "exdb.external_db_id = x.external_db_id" ] );
}
......@@ -535,9 +534,15 @@ sub fetch_all_by_external_name {
my $entryAdaptor = $self->db->get_DBEntryAdaptor();
my @ids = $entryAdaptor->list_gene_ids_by_extids( $external_id );
my ( @ids, @result );
@ids = $entryAdaptor->list_gene_ids_by_extids( $external_id );
return $self->fetch_all_by_dbID_list(\@ids);
my $genes = $self->fetch_all_by_dbID_list(\@ids);
my %genes_by_dbIDs = map { $_->dbID(),$_ } @$genes;
@result = map { $genes_by_dbIDs{ $_ } } @ids;
return \@result;
}
......@@ -742,7 +747,7 @@ sub store {
$analysis_id = $db->get_AnalysisAdaptor->store($analysis);
}
my $type = $gene->type || "";
my $type = $gene->biotype || "";
my $original = $gene;
my $original_transcripts = $gene->get_all_Transcripts();
......@@ -751,22 +756,28 @@ sub store {
my $store_gene_sql =
"INSERT INTO gene " .
"SET type = ?, " .
"SET biotype = ?, " .
"analysis_id = ?, " .
"seq_region_id = ?, " .
"seq_region_start = ?, " .
"seq_region_end = ?, " .
"seq_region_strand = ?";
"seq_region_strand = ?, ".
"description = ?, " .
"source = ?, ".
"confidence = ? ";
my $sth = $self->prepare( $store_gene_sql );
$sth->execute(
"$type",
$analysis_id,
$seq_region_id,
$gene->start(),
$gene->end(),
$gene->strand()
);
$type,
$analysis_id,
$seq_region_id,
$gene->start(),
$gene->end(),
$gene->strand(),
$gene->description(),
$gene->source(),
$gene->confidence()
);
$sth->finish();
my $gene_dbID = $sth->{'mysql_insertid'};
......@@ -796,16 +807,6 @@ sub store {
}
# store the gene description associated with this gene if there is
# one
my $desc = $gene->description();
if(defined($desc)) {
$sth = $self->prepare("INSERT INTO gene_description " .
" SET gene_id = ?, " .
" description = ?" );
$sth->execute($gene_dbID, $desc);
$sth->finish();
}
# store the dbentries associated with this gene
my $dbEntryAdaptor = $db->get_DBEntryAdaptor();
......@@ -945,12 +946,6 @@ sub remove {
$sth->execute( $gene->dbID );
$sth->finish();
# remove this genes description
$sth = $self->prepare( "delete from gene_description where gene_id = ?" );
$sth->execute( $gene->dbID() );
$sth->finish();
# remove this gene from the database
$sth = $self->prepare( "delete from gene where gene_id = ? " );
......@@ -1041,9 +1036,10 @@ sub update {
my $update_gene_sql = "
UPDATE gene
SET type = ?,
SET biotype = ?,
analysis_id = ?,
display_xref_id = ?
display_xref_id = ?,
confidence = ?
WHERE gene_id = ?";
my $display_xref = $gene->display_xref();
......@@ -1059,6 +1055,7 @@ sub update {
$sth->execute($gene->type(),
$gene->analysis->dbID(),
$display_xref_id,
$gene->confidence(),
$gene->dbID()
);
......@@ -1096,15 +1093,16 @@ sub _objs_from_sth {
my %sr_cs_hash;
my ( $gene_id, $seq_region_id, $seq_region_start, $seq_region_end,
$seq_region_strand, $analysis_id, $type, $display_xref_id,
$seq_region_strand, $analysis_id, $biotype, $display_xref_id,
$gene_description, $stable_id, $version, $created_date,
$modified_date, $xref_display_id,
$modified_date, $xref_display_id, $confidence, $source,
$xref_primary_acc, $xref_desc, $xref_version, $external_name,
$external_db, $external_status, $external_release );
$sth->bind_columns( \$gene_id, \$seq_region_id, \$seq_region_start,
\$seq_region_end, \$seq_region_strand, \$analysis_id, \$type,
\$display_xref_id, \$gene_description, \$stable_id, \$version,
\$seq_region_end, \$seq_region_strand, \$analysis_id, \$biotype,
\$display_xref_id, \$gene_description, \$confidence, \$source,
\$stable_id, \$version,
\$created_date, \$modified_date,
\$xref_display_id, \$xref_primary_acc, \$xref_desc, \$xref_version,
\$external_db, \$external_status,
......@@ -1222,7 +1220,7 @@ sub _objs_from_sth {
#finally, create the new gene
push @genes, Bio::EnsEMBL::Gene->new
( '-analysis' => $analysis,
'-type' => $type,
'-biotype' => $biotype,
'-start' => $seq_region_start,
'-end' => $seq_region_end,
'-strand' => $seq_region_strand,
......@@ -1237,13 +1235,21 @@ sub _objs_from_sth {
'-external_name' => $external_name,
'-external_db' => $external_db,
'-external_status' => $external_status,
'-display_xref' => $display_xref );
'-display_xref' => $display_xref,
'-confidence' => $confidence,
'-source' => $source );
}
return \@genes;
}
##########################
# #
# DEPRECATED METHODS #
# #
##########################
=head2 fetch_by_maximum_DBLink
......@@ -1255,6 +1261,8 @@ sub _objs_from_sth {
sub fetch_by_maximum_DBLink {
my ( $self, $external_id ) = @_;
deprecate( "use fetch_all_by_external_name instead" );
my $genes=$self->fetch_all_by_external_name( $external_id);
my $biggest;
......
......@@ -60,10 +60,11 @@ sub new {
my ( $stable_id, $version, $external_name, $type, $external_db,
$external_status, $display_xref, $description, $transcripts,
$created_date, $modified_date ) =
$created_date, $modified_date, $confidence, $biotype, $source ) =
rearrange( [ 'STABLE_ID', 'VERSION', 'EXTERNAL_NAME', 'TYPE',
'EXTERNAL_DB', 'EXTERNAL_STATUS', 'DISPLAY_XREF', 'DESCRIPTION',
'TRANSCRIPTS', 'CREATED_DATE', 'MODIFIED_DATE'], @_ );
'TRANSCRIPTS', 'CREATED_DATE', 'MODIFIED_DATE',
'CONFIDENCE', 'BIOTYPE', 'SOURCE'], @_ );
if ($transcripts) {
$self->{'_transcript_array'} = $transcripts;
......@@ -79,9 +80,11 @@ sub new {
$self->external_db( $external_db ) if( defined $external_db );
$self->external_status( $external_status ) if( defined $external_status );
$self->display_xref( $display_xref ) if( defined $display_xref );
$self->type( $type ) if( defined $type );
$self->biotype( $type ) if( defined $type );
$self->biotype( $biotype ) if( defined $biotype );
$self->description($description);
$self->confidence( $confidence );
$self->source( $source );
return $self;
}
......@@ -101,7 +104,7 @@ sub new {
sub is_known{
my $self = shift;
return ($self->{'display_xref'}) ? 1 : 0;
return ( $self->{'confidence'} eq "KNOWN" );
}
......@@ -135,6 +138,44 @@ sub external_name {
}
=head2 confidence
Arg [1] : string $confidence
Example : none
Description: get/set for attribute confidence
Returntype : string
Exceptions : none
Caller : general
=cut
sub confidence {
my $self = shift;
$self->{'confidence'} = shift if( @_ );
return $self->{'confidence'};
}
=head2 source
Arg [1] : string $source
Example : none
Description: get/set for attribute source
Returntype : string
Exceptions : none
Caller : general
=cut
sub source {
my $self = shift;
$self->{'source'} = shift if( @_ );
return ( $self->{'source'} || "ensembl" );
}
=head2 external_db
Arg [1] : string $external_db
......@@ -178,9 +219,9 @@ sub external_db {
=cut
sub external_status {
my ( $self, $ext_status ) = @_;
my $self = shift;
return $self->{'_ext_status'} = $ext_status if defined $ext_status;
$self->{'_ext_status'} = shift if ( @_ );
return $self->{'_ext_status'} if exists $self->{'_ext_status'};
my $display_xref = $self->display_xref();
......@@ -342,6 +383,7 @@ sub get_all_Exons {
Arg [1] : string $type
Example : none
Description: get/set for attribute type
This function is going to be deprecated soon, use biotype instead
Returntype : string
Exceptions : none
Caller : general
......@@ -351,10 +393,30 @@ sub get_all_Exons {
sub type {
my $self = shift;
$self->{'biotype'} = shift if( @_ );
return ( $self->{'biotype'} || "protein_coding" );
}
=head2 biotype
Arg [1] : string $biotype
Example : $gene->biotype( "protein_coding" );
Description: get/set for the biotype attribute
Returntype : string
Exceptions : none
Caller : general
=cut
$self->{'type'} = shift if( @_ );
sub biotype {
my $self = shift;
return $self->{'type'};
$self->{'biotype'} = shift if( @_ );
return ( $self->{'biotype'} || "protein_coding" );
}
......@@ -556,7 +618,6 @@ sub transfer {
}
=head2 display_xref
Arg [1] : Bio::EnsEMBL::DBEntry $display_xref
......@@ -651,110 +712,6 @@ sub display_id {
###########################
# DEPRECATED METHODS FOLLOW
###########################
=head2 DEPRECATED add_DBLink
Description: DEPRECATED This method has been deprecated in favor of the
add_DBEntry method. Objects are responible for holding only
xrefs directly associated with themselves now.
=cut
sub add_DBLink{
my ($self,$value) = @_;
throw("add_DBLink is deprecated. You probably want add_DBEntry.");
# unless(defined $value && ref $value
# && $value->isa('Bio::Annotation::DBLink') ) {
# throw("This [$value] is not a DBLink");
# }
# if( !defined $self->{'_db_link'} ) {
# $self->{'_db_link'} = [];
# }
# push(@{$self->{'_db_link'}},$value);
}
=head2 temporary_id
Function: DEPRECATED: Use dbID or stable_id or something else instead
=cut
sub temporary_id {
my ($obj,$value) = @_;
deprecate( "I cant see what a temporary_id is good for, please use " .
"dbID or stableID or\n try without an id." );
if( defined $value) {
$obj->{'temporary_id'} = $value;
}
return $obj->{'temporary_id'};
}
=head2 created
Description: DEPRECATED - Transcripts no longer have a created attribute
=cut
sub created{
my ($self,$value) = @_;
deprecate( "The created attribute isnt available any more" );
if(defined $value ) {
$self->{'created'} = $value;
}
return $self->{'created'};
}
=head2 modified
Description: DEPRECATED - Transcripts no longer have a modified attribute
=cut
sub modified {
my ($self,$value) = @_;
deprecate( "The modified item isnt available any more" );
if( defined $value ) {
$self->{'modified'} = $value;
}
return $self->{'modified'};
}
=head2 chr_name
Description: DEPRECATED. Use project, tranform, or transfer to obtain this
gene in another coord system. Use $gene->slice->seq_region_name
to get the name of the underlying coord system. Or
$gene->slice->name().
=cut
sub chr_name {
my $self = shift;
deprecate( "Use project() to obtain other coordinate systems" );
my $gene_slice = $self->slice();
if( $gene_slice->coord_system()->name eq "chromosome" ) {
return $gene_slice->seq_region_name();
}
my $coords = $self->project( "toplevel" );
if( @$coords ) {
return $coords->[0]->[2]->seq_region_name();
}
}
=head2 get_all_DASFactories
......@@ -837,6 +794,8 @@ sub get_all_DASFeatures_by_slice{
}
return \%das_features;
}
=head2 get_all_DAS_Features
Arg [1] : none
......@@ -905,4 +864,81 @@ sub get_all_regulatory_features {
}
###########################
# DEPRECATED METHODS FOLLOW
###########################
=head2 DEPRECATED add_DBLink
Description: DEPRECATED This method has been deprecated in favor of the
add_DBEntry method. Objects are responible for holding only
xrefs directly associated with themselves now.
=cut
sub add_DBLink{
my ($self,$value) = @_;
throw("add_DBLink is deprecated. You probably want add_DBEntry.");
# unless(defined $value && ref $value
# && $value->isa('Bio::Annotation::DBLink') ) {
# throw("This [$value] is not a DBLink");
# }
# if( !defined $self->{'_db_link'} ) {
# $self->{'_db_link'} = [];
# }
# push(@{$self->{'_db_link'}},$value);
}
=head2 temporary_id
Function: DEPRECATED: Use dbID or stable_id or something else instead
=cut
sub temporary_id {
my ($obj,$value) = @_;
deprecate( "I cant see what a temporary_id is good for, please use " .
"dbID or stableID or\n try without an id." );
if( defined $value) {
$obj->{'temporary_id'} = $value;
}
return $obj->{'temporary_id'};
}
=head2 chr_name
Description: DEPRECATED. Use project, tranform, or transfer to obtain this
gene in another coord system. Use $gene->slice->seq_region_name
to get the name of the underlying coord system. Or
$gene->slice->name().
=cut
sub chr_name {
my $self = shift;
deprecate( "Use project() to obtain other coordinate systems" );
my $gene_slice = $self->slice();
if( $gene_slice->coord_system()->name eq "chromosome" ) {
return $gene_slice->seq_region_name();
}
my $coords = $self->project( "toplevel" );
if( @$coords ) {
return $coords->[0]->[2]->seq_region_name();
}
}
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