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

updated tests for new toplevel implementation

parent 6fbe1d5a
No related branches found
No related tags found
No related merge requests found
......@@ -10,16 +10,17 @@ our $verbose = 0;
BEGIN { $| = 1;
use Test;
plan tests => 8;
plan tests => 12;
}
my $name = 'chromosome';
my $version = 'NCBI33';
my $dbID = 1;
my $top_level = 1;
my $top_level = 0;
my $sequence_level = 0;
my $default = 1;
my $rank = 1;
#
# Test constructor
......@@ -29,6 +30,7 @@ my $coord_system = Bio::EnsEMBL::CoordSystem->new
-VERSION => $version,
-DBID => $dbID,
-TOP_LEVEL => $top_level,
-RANK => $rank,
-SEQUENCE_LEVEL => $sequence_level,
-DEFAULT => 1);
......@@ -49,7 +51,7 @@ ok($coord_system->version() eq $version);
#
# Test is_top_level()
#
ok($coord_system->is_top_level());
ok(!$coord_system->is_top_level());
#
# Test is_sequence_level()
......@@ -61,6 +63,10 @@ ok(!$coord_system->is_sequence_level());
#
ok($coord_system->is_default());
#
# Test rank()
#
ok($coord_system->rank() == $rank);
#
# Test equals()
......@@ -70,6 +76,7 @@ my $coord_system2 = Bio::EnsEMBL::CoordSystem->new
(-NAME => $name,
-VERSION => $version,
-DBID => 123,
-RANK => $rank,
-TOP_LEVEL => $top_level);
ok($coord_system->equals($coord_system2));
......@@ -78,10 +85,24 @@ $coord_system2 = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
-VERSION => 'NCBI34',
-DBID => 123,
-RANK => $rank,
-TOP_LEVEL => $top_level);
ok(!$coord_system->equals($coord_system2));
#
# test creation of toplevel system
#
$name = 'toplevel';
$top_level = 1;
#
# Test constructor
#
$coord_system = Bio::EnsEMBL::CoordSystem->new
(-NAME => $name,
-TOP_LEVEL => $top_level);
ok($coord_system->name() eq $name);
ok($coord_system->is_top_level());
ok($coord_system->rank() == 0);
......@@ -3,7 +3,7 @@ use strict;
BEGIN { $| = 1;
use Test ;
plan tests => 25;
plan tests => 32;
}
use MultiTestDB;
......@@ -33,7 +33,7 @@ my $cs = $csa->fetch_by_name('chromosome');
ok($cs->name eq 'chromosome');
ok($cs->dbID());
ok($cs->version eq 'NCBI33');
ok($cs->is_top_level());
ok(!$cs->is_top_level());
ok(!$cs->is_sequence_level());
ok($cs->is_default());
......@@ -48,6 +48,7 @@ ok(@cs_list == 1);
ok($cs_list[0]->equals($cs));
#
# Test fetch_by_dbID()
#
......@@ -59,22 +60,26 @@ ok($cs->version() eq '');
#
# 11 Test fetch_top_level
# Test fetch_top_level
#
$cs = $csa->fetch_top_level();
ok($cs->name eq 'chromosome');
ok($cs->name eq 'toplevel');
ok($cs->is_top_level());
ok($cs->rank == 0);
#
# 12 Test fetch_all_top_level
# Test fetch_by_rank
#
($cs) = @{$csa->fetch_all_top_level()};
$cs = $csa->fetch_by_rank(1);
ok($cs->name() eq 'chromosome' && $cs->rank() == 1);
ok($cs->name eq 'chromosome');
$cs = $csa->fetch_by_rank(0);
ok($cs->name() eq 'toplevel' && $cs->rank() == 0);
#
# 13-14 Test fetch_sequence_level
# Test fetch_sequence_level
#
$cs = $csa->fetch_sequence_level();
......@@ -83,7 +88,22 @@ ok($cs->is_sequence_level());
#
# 15-16 Test get_mapping_path
# Test fetch_all
#
@cs_list = @{$csa->fetch_all()};
my $prev_cs;
#make sure that they are ordered by rank
foreach my $cs (@cs_list) {
if($prev_cs) {
ok($prev_cs->rank < $cs->rank);
}
$prev_cs = $cs;
}
#
# Test get_mapping_path
#
my $ctg_cs = $csa->fetch_by_name('contig');
......@@ -116,11 +136,11 @@ ok(@$path == 3 &&
$multi->save('core', 'coord_system');
$cs = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
(-NAME => 'newsystem',
-VERSION => 'NCBI35',
-DEFAULT => 0,
-DEFAULT => 1,
-SEQUENCE_LEVEL => 0,
-TOP_LEVEL => 1);
-RANK => 10);
$csa->store($cs);
......@@ -128,19 +148,20 @@ ok($cs->adaptor == $csa);
ok($cs->dbID());
#now make sure we can retrieve this
$cs = $csa->fetch_by_name('chromosome', 'NCBI35');
ok($cs->name eq 'chromosome');
$cs = $csa->fetch_by_name('newsystem', 'NCBI35');
ok($cs->name eq 'newsystem');
ok($cs->version eq 'NCBI35');
ok(!$cs->is_default);
ok($cs->is_default);
ok(!$cs->is_sequence_level);
ok($cs->is_top_level);
ok(!$cs->is_top_level);
ok($cs->rank() == 10);
my $sth = $db->prepare('SELECT attrib FROM coord_system ' .
'WHERE name = ? and version = ?');
$sth->execute('chromosome', 'NCBI35');
$sth->execute('newsystem', 'NCBI35');
my ($attrib) = $sth->fetchrow_array();
ok($attrib eq 'top_level');
ok($attrib eq 'default_version');
$sth->finish();
$multi->restore('core', 'coord_system');
......
......@@ -5,7 +5,7 @@ use lib 't';
BEGIN { $| = 1;
use Test;
plan tests => 92;
plan tests => 97;
}
use TestUtils qw( debug test_getter_setter );
......@@ -26,7 +26,7 @@ my $coord_system = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
-VERSION => 'NCBI34',
-DBID => 123,
-TOP_LEVEL => 1);
-RANK => 1);
my $analysis = Bio::EnsEMBL::Analysis->new(-LOGIC_NAME => 'test');
......@@ -158,6 +158,8 @@ ok($feature->slice->seq_region_name() eq 'AL359765.6.1.13780');
ok($feature->slice->coord_system->name() eq 'contig');
#
# Test Transform contig -> clone
#
......@@ -176,6 +178,30 @@ ok($feature->slice->seq_region_name() eq 'AL359765.6');
ok($feature->slice->coord_system->name() eq 'clone');
#
# Test transform clone -> toplevel
#
$feature = $feature->transform('toplevel');
debug("\nclone -> toplevel");
debug("start = " . $feature->start());
debug("end = " . $feature->end());
debug("strand = " . $feature->strand());
debug("seq_region = " . $feature->slice->seq_region_name());
ok($feature->start() == 300 + $slice->start() - 1);
ok($feature->end() == 500 + $slice->start() - 1);
ok($feature->strand() == 1);
ok($feature->slice->coord_system->name() eq 'chromosome');
ok($feature->slice->seq_region_name() eq '20');
#put back to clone
$feature = $feature->transform('clone');
#
# Test transform to into gap
#
......
......@@ -22,7 +22,7 @@ my $coord_system = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
-VERSION => 'NCBI34',
-DBID => 123,
-TOP_LEVEL => 1);
-RANK => 1);
my $analysis = Bio::EnsEMBL::Analysis->new(-LOGIC_NAME => 'test');
......
......@@ -361,7 +361,7 @@ debug( "checking external references" );
$multi->restore();
$slice = $db->get_SliceAdaptor()->fetch_by_region
( "toplevel", "20", 30_252_000, 31_252_001 );
( "chromosome", "20", 30_252_000, 31_252_001 );
my $known = 0;
my $unknown = 0;
......
......@@ -22,7 +22,7 @@ my $coord_system = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
-VERSION => 'NCBI34',
-DBID => 123,
-TOP_LEVEL => 1);
-RANK => 1);
my $slice = Bio::EnsEMBL::Slice->new(-COORD_SYSTEM => $coord_system,
......
......@@ -24,7 +24,7 @@ my $coord_system = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
-VERSION => 'NCBI34',
-DBID => 123,
-TOP_LEVEL => 1);
-RANK => 1);
my $analysis = Bio::EnsEMBL::Analysis->new(-LOGIC_NAME => 'test');
......
......@@ -47,7 +47,7 @@ ok($slice->adaptor == $slice_adaptor);
#
#TEST - Slice::new
#
my $coord_system = $csa->fetch_by_name('toplevel');
my $coord_system = $csa->fetch_by_name('chromosome');
$slice = new Bio::EnsEMBL::Slice
(-seq_region_name => $CHR,
......
......@@ -36,7 +36,7 @@ ok($slice_adaptor->db);
#
# fetch_by_region
#
my $slice = $slice_adaptor->fetch_by_region('toplevel',$CHR, $START, $END);
my $slice = $slice_adaptor->fetch_by_region('chromosome',$CHR, $START, $END);
ok($slice->seq_region_name eq $CHR);
ok($slice->start == $START);
ok($slice->end == $END);
......
use lib 't';
use strict;
BEGIN { $| = 1;
use Test ;
plan tests => 7;
}
use MultiTestDB;
use TestUtils qw(debug test_getter_setter);
our $verbose = 0; #set to 1 to turn on debug printouts
my $multi = MultiTestDB->new();
my $db = $multi->get_DBAdaptor( 'core' );
my $asma = $db->get_AssemblyMapperAdaptor();
#
# Test fetch_by_CoordSystems
#
my $csa = $db->get_CoordSystemAdaptor();
my $toplevel_cs = $csa->fetch_by_name('toplevel');
my $cln_cs = $csa->fetch_by_name('clone');
my $superctg_cs = $csa->fetch_by_name('supercontig');
my $cln_toplevel_mapper =
$asma->fetch_by_CoordSystems($toplevel_cs, $cln_cs);
my $superctg_toplevel_mapper =
$asma->fetch_by_CoordSystems($toplevel_cs, $superctg_cs);
ok($cln_toplevel_mapper &&
$cln_toplevel_mapper->isa('Bio::EnsEMBL::TopLevelAssemblyMapper'));
#
# test db has chr 20 (50KB -> 62MB)
#
#
# Test map
#
debug("MAP 'AL359765.6'->toplevel");
my @coords = $cln_toplevel_mapper->map('AL359765.6', 1, 13780, 1, $cln_cs);
print_coords(@coords);
ok(@coords);
debug("MAP NT_028392->toplevel");
@coords = $superctg_toplevel_mapper->map('NT_028392', 600_000, 1e6, 1,
$superctg_cs);
print_coords(@coords);
ok(@coords);
#
# Test list_seq_regions
#
my @seq_regions =
$cln_toplevel_mapper->list_seq_regions('AL359765.6', 1, 13780, $cln_cs);
my $str = join("\n", "----------", @seq_regions);
debug("$str\n");
ok(@seq_regions == 1 && $seq_regions[0] eq '20');
@seq_regions = $superctg_toplevel_mapper->list_seq_regions('NT_028392',
6e5, 1e6,
$superctg_cs);
$str = join("\n", "----------", @seq_regions);
debug("$str\n");
ok(@seq_regions == 1 && $seq_regions[0] eq '20');
#
# Test list_seq_ids
#
my @ids =
$cln_toplevel_mapper->list_ids('AL359765.6', 1, 13780, $cln_cs);
$str = join("\n", "----------", @ids);
debug("$str\n");
ok(@ids == 1 && $ids[0] == 469283);
@ids = $superctg_toplevel_mapper->list_ids('NT_028392',
6e5, 1e6,
$superctg_cs);
$str = join("\n", "----------", @ids);
debug("$str\n");
ok(@ids == 1 && $ids[0] == 469283);
sub print_coords {
my @coord_list = @_;
return if(!$verbose);
foreach my $coord (@coord_list) {
if($coord->isa('Bio::EnsEMBL::Mapper::Gap')) {
debug("GAP");
next;
}
my $cs = $coord->coord_system();
my $cs_str = ($cs) ? $cs->name() . $cs->version() : '';
debug($coord->id()."\t". $coord->start()."-".$coord->end().
" (".$coord->strand.") [$cs_str]");
}
}
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