diff --git a/modules/Bio/EnsEMBL/DBSQL/ExonAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/ExonAdaptor.pm index 44a6fd0db9007c3bd86ea87a831a908aed43433f..a5142548f2a0ce7e796cbb1dba4ab1b272b59aa3 100644 --- a/modules/Bio/EnsEMBL/DBSQL/ExonAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/ExonAdaptor.pm @@ -632,7 +632,7 @@ sub _objs_from_sth { '-modified_date' => $modified_date || undef, '-phase' => $phase, '-end_phase' => $end_phase, - 'is_current' => $is_current + '-is_current' => $is_current ); } diff --git a/modules/Bio/EnsEMBL/Exon.pm b/modules/Bio/EnsEMBL/Exon.pm index 7d60888286371378068a49e44bc6d25e19895cda..33e3cd81a33d0af444fa30b6a1214a86553cd4bd 100755 --- a/modules/Bio/EnsEMBL/Exon.pm +++ b/modules/Bio/EnsEMBL/Exon.pm @@ -75,17 +75,17 @@ use vars qw(@ISA); the slice it is sitting on. Coordinates start at 1 and are inclusive. Arg [-STRAND]: The orientation of this feature. Valid values are 1,-1,0. - Arg [-SEQNAME] : A seqname to be used instead of the default name of the - of the slice. Useful for features that do not have an + Arg [-SEQNAME] : (optional) A seqname to be used instead of the default name + of the of the slice. Useful for features that do not have an attached slice such as protein features. Arg [-dbID] : (optional) internal database id Arg [-ADAPTOR]: (optional) Bio::EnsEMBL::DBSQL::BaseAdaptor - Arg [-PHASE] :(optional) the phase. - Arg [-END_PHASE]:(optional) the end phase - Arg [-STABLE_ID]:(optional) the stable id of the exon - Arg [-VERSION] :(optional) the version - Arg [-CREATED_DATE] :(optional) the created date - Arg [-MODIFIED_DATE]:(optional) the last midifeid date + Arg [-PHASE] : the phase. + Arg [-END_PHASE]: the end phase + Arg [-STABLE_ID]: (optional) the stable id of the exon + Arg [-VERSION] : (optional) the version + Arg [-CREATED_DATE] : (optional) the created date + Arg [-MODIFIED_DATE]: (optional) the last midifeid date Example : none Description: create an Exon object @@ -114,7 +114,10 @@ sub new { $self->{'version'} = $version; $self->{'created_date'} = $created_date; $self->{'modified_date'} = $modified_date; - $self->{'is_current'} if (defined($is_current)); + + # default is_current + $is_current = 1 unless (defined($is_current)); + $self->{'is_current'} = $is_current; return $self; } diff --git a/modules/Bio/EnsEMBL/Gene.pm b/modules/Bio/EnsEMBL/Gene.pm index 1e2beadf63eb649a709a5e6d5c786ebcb55c62f1..0a9bb76ea928da48f2d4d927a54fdfcf97d1e4dd 100755 --- a/modules/Bio/EnsEMBL/Gene.pm +++ b/modules/Bio/EnsEMBL/Gene.pm @@ -139,7 +139,10 @@ sub new { # kept to ensure routine is backwards compatible. $self->status( $status); # add new naming $self->source( $source ); - $self->is_current($is_current) if (defined($is_current)); + + # default to is_current + $is_current = 1 unless (defined($is_current)); + $self->{'is_current'} = $is_current; return $self; } diff --git a/modules/Bio/EnsEMBL/Transcript.pm b/modules/Bio/EnsEMBL/Transcript.pm index 8865d81b85c22e21b2e1a2b9c3345bbaccd7c118..cae4e2957fce409c02f1a340790c90646dc6a6ee 100755 --- a/modules/Bio/EnsEMBL/Transcript.pm +++ b/modules/Bio/EnsEMBL/Transcript.pm @@ -151,7 +151,10 @@ sub new { $self->status( $confidence ); # old style name $self->status( $status ); # new style name $self->biotype( $biotype ); - $self->is_current($is_current) if (defined($is_current)); + + # default is_current + $is_current = 1 unless (defined($is_current)); + $self->{'is_current'} = $is_current; return $self; } diff --git a/modules/t/exon.t b/modules/t/exon.t index ec2b2d5f4cc5b3b02c3d42428960d2286b11e7d2..1fde99f4dd0cd547a377433611286917dd8f7934 100644 --- a/modules/t/exon.t +++ b/modules/t/exon.t @@ -2,7 +2,7 @@ use strict; BEGIN { $| = 1; use Test ; - plan tests => 31; + plan tests => 35; } my $loaded = 0; @@ -210,8 +210,9 @@ ok(count_rows($db, 'supporting_feature') == $supfeat_count - $supfeat_minus); $multi->restore(); - +# # tests for multiple versions of transcripts in a database +# $exon = $exonad->fetch_by_stable_id('ENSE00001109603'); debug("fetch_by_stable_id"); @@ -221,4 +222,45 @@ my @exons = @{ $exonad->fetch_all_versions_by_stable_id('ENSE00001109603') }; debug("fetch_all_versions_by_stable_id"); ok( scalar(@exons) == 2 ); +# store/update tests + +$multi->hide( "core", "exon", "supporting_feature", + "protein_align_feature", "dna_align_feature"); + +my $e1 = Bio::EnsEMBL::Exon->new( + -start => 10, + -end => 1000, + -strand => 1, + -slice => $slice, + -phase => 0, + -end_phase => 0, + -stable_id => 'ENSE0001', + -version => 1 +); + +my $e2 = Bio::EnsEMBL::Exon->new( + -start => 10, + -end => 1000, + -strand => 1, + -slice => $slice, + -phase => 0, + -end_phase => 0, + -stable_id => 'ENSE0001', + -version => 2, + -is_current => 0 +); + +$exonad->store($e1); +$exonad->store($e2); + +$exon = $exonad->fetch_by_stable_id('ENSE0001'); +ok( $exon->is_current == 1); + +@exons = @{ $exonad->fetch_all_versions_by_stable_id('ENSE0001') }; +foreach my $e (@exons) { + next unless ($e->version == 2); + ok($e->is_current == 0); +} + +$multi->restore(); diff --git a/modules/t/gene.t b/modules/t/gene.t index 12df2ac83c5a122f0fe54838ee9ee80cc1fdc88c..419715937b497fd17e5239fca871ddf83393e54b 100644 --- a/modules/t/gene.t +++ b/modules/t/gene.t @@ -3,7 +3,7 @@ use warnings; BEGIN { $| = 1; use Test; - plan tests => 76; + plan tests => 81; } use Bio::EnsEMBL::Test::MultiTestDB; @@ -643,7 +643,9 @@ $gene = $ga->fetch_by_dbID(18271); my @factors = @{$gene->fetch_coded_for_regulatory_factors()}; ok($factors[0]->dbID() == 5); +# # tests for multiple versions of genes in a database +# $gene = $ga->fetch_by_stable_id('ENSG00000355555'); debug("fetch_by_stable_id"); @@ -681,3 +683,45 @@ $gene = $ga->fetch_by_dbID(18276); debug("fetch_by_dbID, non current"); ok( $gene->is_current == 0 ); +# store/update + +$gene = $ga->fetch_by_stable_id('ENSG00000355555'); +foreach my $t (@{ $gene->get_all_Transcripts }) { + $t->get_all_Exons; +} + +$multi->hide( "core", "gene", "transcript", "exon", 'xref', 'object_xref', + "exon_transcript", "translation", "gene_stable_id" ); + +$gene->version(3); +$gene->dbID(undef); +$gene->adaptor(undef); +$ga->store($gene); + +$gene->version(4); +$gene->is_current(0); +$gene->dbID(undef); +$gene->adaptor(undef); +$ga->store($gene); + +$gene = $ga->fetch_by_stable_id('ENSG00000355555'); +ok($gene->is_current == 1); + +@genes = @{ $ga->fetch_all_versions_by_stable_id('ENSG00000355555') }; +foreach my $g (@genes) { + next unless ($g->version == 4); + ok($g->is_current == 0); +} + +$gene->is_current(0); +$ga->update($gene); +my $g1 = $ga->fetch_by_stable_id('ENSG00000355555'); +ok(!$g1); + +$gene->is_current(1); +$ga->update($gene); +$gene = $ga->fetch_by_stable_id('ENSG00000355555'); +ok($gene->is_current == 1); + +$multi->restore; + diff --git a/modules/t/transcript.t b/modules/t/transcript.t index 235c551947ed8c007125fd11fa5e04629cf10906..06b7748c414d8faaa8291836e7ba1ce168471d28 100644 --- a/modules/t/transcript.t +++ b/modules/t/transcript.t @@ -4,7 +4,7 @@ use vars qw( $verbose ); BEGIN { $| = 1; use Test; - plan tests => 140; + plan tests => 152; } use Bio::EnsEMBL::Test::MultiTestDB; @@ -117,7 +117,7 @@ ok ( $tr->display_xref->dbID() == 97759 ); ok( test_getter_setter( $tr, "display_xref", 42 )); ok( test_getter_setter( $tr, "dbID", 100000 )); -ok( test_getter_setter( $tr, "type", "NOVEL" )); +ok( test_getter_setter( $tr, "biotype", "NOVEL" )); ok( test_getter_setter( $tr, "created_date", time() )); ok( test_getter_setter( $tr, "modified_date", time() )); @@ -501,7 +501,9 @@ ok(count_rows($db, 'transcript_attrib') == 2); $multi->restore('core'); +# # tests for multiple versions of transcripts in a database +# $tr = $ta->fetch_by_stable_id('ENST00000355555'); debug("fetch_by_stable_id"); @@ -536,6 +538,52 @@ $tr = $ta->fetch_by_display_label('MX_HUMAN'); debug("fetch_by_display_label"); ok( $tr->dbID == 21740 ); +# store/update + +$tr = $ta->fetch_by_stable_id('ENST00000355555'); +$g = $db->get_GeneAdaptor->fetch_by_transcript_id($tr->dbID); +$tr->get_all_Exons; + +$multi->hide( "core", "gene", "transcript", "exon", 'xref', 'object_xref', + "exon_transcript", "translation", "transcript_stable_id" ); + +$tr->version(3); +$tr->dbID(undef); +$tr->adaptor(undef); +$ta->store($tr, $g->dbID); + +$tr->version(4); +$tr->is_current(0); +$tr->dbID(undef); +$tr->adaptor(undef); +$ta->store($tr, $g->dbID); + +$tr = $ta->fetch_by_stable_id('ENST00000355555'); +ok($tr->is_current == 1); + +@transcripts = @{ $ta->fetch_all_versions_by_stable_id('ENST00000355555') }; +foreach my $t (@transcripts) { + next unless ($t->version == 4); + ok($t->is_current == 0); +} + +$tr->is_current(0); +$ta->update($tr); +my $t1 = $ta->fetch_by_stable_id('ENST00000355555'); +ok(!$t1); + +$tr->is_current(1); +$ta->update($tr); +$tr = $ta->fetch_by_stable_id('ENST00000355555'); +ok($tr->is_current == 1); + +$multi->restore; + + +# +# end main +# + sub test_trans_mapper_edits { $tr->edits_enabled(1);