Skip to content
Snippets Groups Projects
Commit e815acb4 authored by Patrick Meidl's avatar Patrick Meidl
Browse files

some fixes for multi-version support

parent 5521bc2f
No related branches found
No related tags found
No related merge requests found
......@@ -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
);
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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();
......@@ -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;
......@@ -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);
......
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