Commit 8005e93b authored by Patrick Meidl's avatar Patrick Meidl
Browse files

tests for new and rewritten methods

parent 23d445ba
......@@ -4,7 +4,7 @@ no warnings qw(uninitialized);
BEGIN { $| = 1;
use Test;
plan tests => 9;
plan tests => 20;
}
use Bio::EnsEMBL::Test::MultiTestDB;
......@@ -19,21 +19,40 @@ our $verbose = 0;
#
ok(1);
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new;
my $db = $multi->get_DBAdaptor('core');
my $asia = $db->get_ArchiveStableIdAdaptor();
my $asi = $asia->fetch_by_stable_id( "G1" );
_print_asi( $asi );
#
# 2-4 ArchiveStableId retrieval
#
my $asi = $asia->fetch_by_stable_id("T1");
ok( $asi->release == 2);
$asi = $asia->fetch_by_stable_id_version("T2", 3);
ok( $asi->release == 3);
$asi = $asia->fetch_by_stable_id_dbname("T1", "release_2");
ok( $asi->release == 2);
#
# 2 retrieval of an archiveStableId
# 5 retrieval of an archiveStableId
#
$asi = $asia->fetch_by_stable_id( "G1" );
_print_asi( $asi );
ok( $asi );
#
# 6 how many predecessors does it have
#
my $pre_asis = $asi->get_all_predecessors();
ok( scalar( @$pre_asis ) == 2 );
for my $asi ( @$pre_asis ) {
debug( "\tPre G1" );
......@@ -42,41 +61,35 @@ for my $asi ( @$pre_asis ) {
#
# 3 how many predecessors does it have
# 7 transcripts for a gene
#
ok( scalar( @$pre_asis ) == 2 );
my $transcripts = $pre_asis->[0]->get_all_transcript_archive_ids();
for my $asi ( @$transcripts ) {
debug( "\tTranscripts G1" );
_print_asi( $asi );
#get_translation_archive_id was changed to give back listref.
#this makes the function poorly named, but it is what the
#webteam uses so....
my $tl = $asi->get_all_translation_archive_ids();
foreach my $asi2 (@$tl) {
_print_asi( $asi2 );
}
}
#
# 4 transcripts for a gene
#
ok( scalar( @$transcripts ) == 1);
#
# 8 no predecessor case
#
$pre_asis = $pre_asis->[0]->get_all_predecessors();
debug( "\tPredecessors: ".scalar( @$pre_asis ) );
ok( scalar( @$pre_asis ) == 0 );
#
# 5 no predecessor case
# 9 successor case
#
ok( scalar( @$pre_asis ) == 0 );
$asi = $asia->fetch_by_stable_id_dbname( "G4", "release_1" );
my $succ_asis = $asi->get_all_successors();
......@@ -85,11 +98,11 @@ for my $asi ( @$succ_asis ) {
_print_asi( $asi );
}
#
# 6 successor case
#
ok( scalar( @$succ_asis ) == 1 );
#
# 10 no successor case
#
$succ_asis = $succ_asis->[0]->get_all_successors();
for my $asi ( @$succ_asis ) {
......@@ -97,17 +110,12 @@ for my $asi ( @$succ_asis ) {
_print_asi( $asi );
}
#
# 7 no successor case
#
ok( scalar( @$succ_asis ) == 0 );
#
# 8 fetch_successor_history
# 11 fetch_successor_history
#
$asi = $asia->fetch_by_stable_id_dbname( "G2", "release_1" );
my $asis = $asia->fetch_successor_history( $asi );
......@@ -119,15 +127,57 @@ for my $asi ( @$asis ) {
ok(( $asis->[-1]->db_name eq "release_4" ) &&
( scalar @$asis == 5 ));
#
# 12-16 history tree
#
$asi = $asia->fetch_by_stable_id_dbname( "G2", "release_1" );
my $history = $asi->get_history_tree;
my @asis = @{ $history->get_all_ArchiveStableIds };
ok( scalar(@asis) == 9);
my @events = @{ $history->get_all_StableIdEvents };
ok( scalar(@events) == 10);
ok( scalar(@{ $history->get_release_display_names }) == 4);
ok( scalar(@{ $history->get_unique_stable_ids }) == 3);
my ($x, $y) = @{ $history->coords_by_ArchiveStableId($asi) };
ok( $x == 0 and $y == 1 );
#
# 17-18 check for current version and fetch latest incarnation
#
ok( ! $asi->is_latest );
$asi = $asi->get_latest_incarnation;
ok( $asi->is_latest and $asi->version == 4 );
#
# 9 reject unknown stable ids
# 19 associated IDs in archive
#
$asi = $asia->fetch_by_stable_id_version( "G2", "2" );
my @assoc = @{ $asi->get_all_associated_archived };
ok( scalar(@assoc) == 2 and
$assoc[0]->[0]->type eq 'Gene' and
$assoc[0]->[1]->type eq 'Transcript' and
$assoc[0]->[2]->type eq 'Translation' and
$assoc[0]->[3] =~ /^PT/
);
ok( ! defined $asia->fetch_by_stable_id_dbname( "FooBar", "release_unknown" ));
#
# 20 archived peptide sequence
#
$asi = $asia->fetch_by_stable_id_version("P2", 1);
ok( $asi->get_peptide eq 'PTWOVERSIONONE*' );
#
# debug helper
#
sub _print_asi {
my $asi = shift;
......
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