Skip to content
Snippets Groups Projects
Commit 621c4e2f authored by Graham McVicker's avatar Graham McVicker
Browse files

added some regression tests

parent a7eb76a0
No related branches found
No related tags found
No related merge requests found
......@@ -3,15 +3,16 @@ use strict;
BEGIN { $| = 1;
use Test ;
plan tests => 9;
plan tests => 18;
}
my $loaded = 0;
END {print "not ok 1\n" unless $loaded;}
use MultiTestDB;
use TestUtils qw(debug test_getter_setter);
my $verbose = 1;
our $verbose = 0; #set to 1 to turn on debug printouts
$loaded = 1;
my $multi = MultiTestDB->new();
......@@ -34,28 +35,49 @@ ok($exonad);
my $exon = Bio::EnsEMBL::Exon->new();
$exon->start(31_200);
ok(&test_getter_setter($exon, 'start', 200));
$exon->start(10);
ok($exon->start == 10);
$exon->end(20);
ok($exon->end == 20);
$exon->end(31_400);
ok(&test_getter_setter($exon, 'end', 400));
$exon->strand(1);
ok($exon->strand == 1);
ok(&test_getter_setter($exon, 'strand', -1));
$exon->phase(0);
ok($exon->phase == 0);
ok(&test_getter_setter($exon, 'phase', -1));
$exon->contig( $contig );
ok(&test_getter_setter($exon, 'contig', $contig));
# should try to store (!)
$exon->end_phase( -1 );
ok(&test_getter_setter($exon, 'end_phase', 1));
$multi->hide( "core", "exon" );
#
# find supporting evidence for the exon
#
my @evidence = ();
my @fs = ();
push @fs, @{$db->get_DnaAlignFeatureAdaptor->fetch_all_by_RawContig($contig)};
push @fs, @{$db->get_ProteinAlignFeatureAdaptor->fetch_all_by_RawContig($contig)};
while(my $f = shift @fs) {
#debug("feature at: " . $f->start . "-" . $f->end);
next if $f->start > $exon->end || $f->end < $exon->start;
push(@evidence, $f);
}
my $count = scalar(@evidence);
debug("adding $count supporting features");
$exon->add_supporting_features(@evidence);
$exonad->store($exon);
ok($exon->dbID() == 1);
ok($exon->dbID() == 1 && $exon->adaptor == $exonad);
# now test fetch_by_dbID
......@@ -63,14 +85,44 @@ my $newexon = $exonad->fetch_by_dbID($exon->dbID);
ok($newexon);
$multi->restore();
#
# Test transform to empty Slice
#
my $slice = new Bio::EnsEMBL::Slice(-empty => 1,
-adaptor => $db->get_SliceAdaptor);
$exon = $newexon->transform($slice);
debug("exon chr start = " . $exon->start);
debug("exon chr end = " . $exon->end);
debug("exon chr strand = " . $exon->strand);
ok($exon->start == 30_961_059 && $exon->end == 30_961_259 && $exon->strand==1);
#
# Test transform to another slice
#
my $slice = $db->get_SliceAdaptor->fetch_by_chr_start_end($slice->chr_name,
$exon->start - 10,
$exon->end + 10);
$exon = $exon->transform($slice);
debug("exon chr start = " . $exon->start);
debug("exon chr end = " . $exon->end);
debug("exon chr strand = " . $exon->strand);
ok($exon->start == 11 && $exon->end == 211 && $exon->strand==1);
#
# Test Transform back to Raw Contig
#
$exon = $exon->transform;
ok($exon->start == 31_200);
ok($exon->end == 31_400);
ok($exon->strand == 1);
ok($exon->contig->name eq $exon->contig->name);
sub debug {
my $txt = shift;
if( $verbose ) {
print STDERR $txt,"\n";
}
}
#regression test, supporting evidence was lost post transform before...
ok(scalar(@{$exon->get_all_supporting_features} == $count));
$multi->restore();
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