slice.t 17.7 KB
Newer Older
1
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
2 3 4 5 6 7 8 9 10 11 12 13 14
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15 16
use strict;
use warnings;
17

18
use Test::More;
19

20
use Bio::EnsEMBL::Test::TestUtils;
Andy Yates's avatar
Andy Yates committed
21
use IO::String;
22
use Bio::EnsEMBL::Test::MultiTestDB;
23
use Bio::EnsEMBL::Slice;
24
use Bio::EnsEMBL::ProjectionSegment;
25
use Test::Exception;
26
use Test::Differences;
27

28
our $verbose = 0;
29

30
#
31
# TEST - Slice Compiles
32
#
33
ok(1);
34 35


36
my $CHR           = '20';
Graham McVicker's avatar
Graham McVicker committed
37
my $START         = 30_270_000;
38 39
my $END           = 31_200_000;
my $STRAND        = 1;
40
my $SEQ_REGION_LENGTH = 50e6;
41

42
my $multi_db = Bio::EnsEMBL::Test::MultiTestDB->new;
43
my $db = $multi_db->get_DBAdaptor('core');
44

45
#
46
# TEST - Slice creation from adaptor
47 48
#
my $slice_adaptor = $db->get_SliceAdaptor;
49
my $csa = $db->get_CoordSystemAdaptor();
50

51
my $slice = $slice_adaptor->fetch_by_region('chromosome', $CHR, $START, $END);
52 53 54 55 56
is($slice->seq_region_name, $CHR, "Slice name is $CHR");
is($slice->start, $START, "Slice start is $START");
is($slice->end, $END, "Slice end is $END");
is($slice->seq_region_length, 62842997, "Slice length is correct");
is($slice->adaptor, $slice_adaptor, "Slice has adaptor $slice_adaptor");
57 58


59
#
60
#TEST - Slice::new
61
#
62
my $coord_system = $csa->fetch_by_name('chromosome');
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

my $test_seq = 'ATGCATGCATGCATGCATGCATGC';
my $test_slice = new Bio::EnsEMBL::Slice
  (-seq_region_name  => 'misc',
   -seq_region_length => 24,
   -start            => 1,
   -end              => 24,
   -strand           => 1,
   -coord_system     => $coord_system,
   -seq              => $test_seq,
   );




79
is($test_slice->length, 24, 'Tested slice length');
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

my $hash = $test_slice->get_base_count;
my $a = $hash->{'a'};
my $c = $hash->{'c'};
my $t = $hash->{'t'};
my $g = $hash->{'g'};
my $n = $hash->{'n'};
my $gc_content = $hash->{'%gc'};

ok($a == 6
   && $c == 6 
   && $t == 6 
   && $g == 6 
   && $n == 0 
   && $gc_content == 50 
   && $a+$c+$t+$g+$n == $test_slice->length);


#
# test that subseq works correctly with attached sequence
#

my $subseq = $test_slice->subseq(2, 6);
103
is($subseq, 'TGCAT', "Subseq is $subseq");
104 105

$subseq = $test_slice->subseq(2,6,-1);
106
is($subseq, 'ATGCA', "Subseq is $subseq");
107

108 109 110
# test that subslice works correctly with attached sequence

my $sub_slice = $test_slice->sub_Slice(2, 6);
111
is($sub_slice->seq, 'TGCAT', "Sub slice seq is correct");
112 113

# test that invert works correctly with attached sequence
114
is($sub_slice->invert()->seq(), 'ATGCA', "Inverted sub slice seq is correct");
115 116 117


# test that slice can be created without db, seq or coord system
Andy Yates's avatar
Andy Yates committed
118 119 120 121 122 123 124 125 126 127 128
{
  my $warnings = q{};
  my $new_stderr = IO::String->new(\$warnings);
  my $oldfh = select(STDERR);
  local *STDERR = $new_stderr;
  $test_slice = Bio::EnsEMBL::Slice->new('-seq_region_name' => 'test',
                                         '-start'           => 1,
                                         '-end'             => 3);
  my $check = qr/MSG: Slice without coordinate system/;
  like($warnings, $check, 'Checking we are still warning about lack of coordinate system');
}
129 130

ok($test_slice);
131
is($test_slice->seq(), 'NNN', "Test slice seq is only N's");
132

133
is($test_slice->name(), '::test:1:3:1', "Slice name is $test_slice->name");
134

135

136
$slice = new Bio::EnsEMBL::Slice
137 138 139 140 141 142
  (-seq_region_name   => $CHR,
   -seq_region_length => $SEQ_REGION_LENGTH,
   -start             => $START,
   -end               => $END,
   -strand            => $STRAND,
   -coord_system      => $coord_system);
143 144


145
is($slice->seq_region_name, $CHR);
146

147 148 149 150
is($slice->start, $START, "Slice start is $START");
is($slice->end, $END, "Slice end is $END");
is($slice->strand, $STRAND, "Slice strand is $STRAND");
is($slice->seq_region_length, $SEQ_REGION_LENGTH, "Slice length is $SEQ_REGION_LENGTH");
151

152
#
153
#Test - Slice::adaptor
154 155
#
$slice->adaptor($slice_adaptor);
156
is($slice->adaptor, $slice_adaptor, "Slice has adaptor $slice_adaptor");
157 158


159
#
160
#1 Test Slice::name
161 162 163
#
#verify that chr_name start and end are contained in the name
my $name = $slice->name;
164
is($name, "chromosome:NCBI33:$CHR:$START:$END:$STRAND", "Chromosome name is $name");
165 166 167 168

#
# Test Slice::length
#
169
is($slice->length, ($END-$START + 1));
170

171 172
# Test exception name
is($slice->assembly_exception_type(), 'REF', 'Type of region is REF');
173

174
#
175
# Test get_attributes
176
#
177

178 179
my $clone = $slice_adaptor->fetch_by_region('clone','AL121583.25');

180
my @attrib = @{$clone->get_all_Attributes('htg_phase')};
181

182 183
is(@attrib, 1, "Attrib found");
is($attrib[0]->value(), 4, "First attrib is 4");
184

185 186 187 188 189 190 191 192
#
# Test get_all_DitagFeatures
#

my @ditags = @{ $slice->get_all_DitagFeatures() };

is(scalar(@ditags), 0, "Fetched ditag features from slice");

193
#
194
# Test expand
195
#
196 197 198
my $len = $clone->length();

$clone = $clone->expand(100,100);
199 200
is($clone->start, -99, "Clone start is correct");
is($clone->end(), $len+100, "Clone end is correct");
201 202

$clone = $clone->expand(-100,-100);
203 204
is($clone->start, 1, "Clone start matches 1");
is($clone->end(), $len, "Clone end matches $len");
205 206

$clone = $clone->expand(0,1000);
207 208
is($clone->start, 1, "Clone start matches 1");
is($clone->end(), $len + 1000, "Clone end matches $len + 1000");
209

210 211 212
$clone = $clone->expand(-1000, 0, 1);
is($clone->start, 1001, "Expanded clone start is correct if forced");
is($clone->end(), $len + 1000, "Expanded clone end is correct if forced");
213

214 215 216 217 218
#
# Test constrain_to_seq_region
#
my $tidy_clone = $clone->expand(1000000,10000000);
$tidy_clone = $tidy_clone->constrain_to_seq_region;
219 220
is($tidy_clone->start, 1, "Tidy clone is correct");
is($tidy_clone->end, 84710, 'Huge expand call truncates nicely');
221 222 223

$tidy_clone = $clone->expand(0,-1000);
$tidy_clone = $tidy_clone->constrain_to_seq_region;
224 225
is($tidy_clone->start, 1001, "Tidy clone $tidy_clone->start and $tidy_clone->end are correct");
is($tidy_clone->end(), 84710, 'constrain_to_seq_region does no harm');
226

227

228
#
229
# Test Slice::invert
230 231 232 233
#
my $inverted_slice = $slice->invert;
ok($slice != $inverted_slice); #slice is not same object as inverted slice
#inverted slice on opposite strand
234
is($slice->strand, ($inverted_slice->strand * -1), "Inverted slice on opposite strand is identical to initial slice"); 
235
#slice still on same strand
236
is($slice->strand, $STRAND, "Slice is still on the same strand");
237 238


239
#
240
# Test Slice::seq
241
#
Graham McVicker's avatar
Graham McVicker committed
242 243
my $seq = uc $slice->seq;
my $invert_seq = uc $slice->invert->seq;
244

245
is(length($seq), $slice->length, "Sequence is correct length");
Graham McVicker's avatar
Graham McVicker committed
246 247 248 249

$seq = reverse $seq;  #reverse complement seq
$seq =~ tr/ACTG/TGAC/; 

250
eq_or_diff($seq, $invert_seq, "revcom same as seq on inverted slice");
251

252
#
253
# Test Slice::subseq
254 255
#
my $SPAN = 10;
Graham McVicker's avatar
Graham McVicker committed
256 257 258 259
my $sub_seq = uc $slice->subseq(-$SPAN,$SPAN);
my $invert_sub_seq = uc $slice->invert->subseq( $slice->length - $SPAN + 1, 
						$slice->length + $SPAN + 1);

260
ok(length $sub_seq == (2*$SPAN) + 1 ); 
Graham McVicker's avatar
Graham McVicker committed
261 262 263
$sub_seq = reverse $sub_seq;
$sub_seq =~ tr/ACTG/TGAC/;

264
eq_or_diff($sub_seq, $invert_sub_seq);
Graham McVicker's avatar
Graham McVicker committed
265 266

#
267
# Test Slice::get_all_PredictionTranscripts
Graham McVicker's avatar
Graham McVicker committed
268 269
#
my $pts = $slice->get_all_PredictionTranscripts;
270
ok(@$pts == 24);
Graham McVicker's avatar
Graham McVicker committed
271

272 273 274 275
#
# Test Slice::get_seq_region_id
#
ok($slice->get_seq_region_id());
Graham McVicker's avatar
Graham McVicker committed
276 277

#
278
# Test Slice::get_all_DnaAlignFeatures
Graham McVicker's avatar
Graham McVicker committed
279 280 281
#
my $count = 0;
my $dafs = $slice->get_all_DnaAlignFeatures;
282
is(scalar(@$dafs), 27081, 'Checking count of returned DnaAlignFeatures');
Graham McVicker's avatar
Graham McVicker committed
283 284 285
$count += scalar @$dafs;

#
286
# Test Slice::get_all_ProteinAlignFeatures
Graham McVicker's avatar
Graham McVicker committed
287 288
#
my $pafs = $slice->get_all_ProteinAlignFeatures;
289
is(scalar(@$pafs),7205, 'Checking count of returned ProteinAlignFeatures');
Graham McVicker's avatar
Graham McVicker committed
290 291 292
$count += scalar @$pafs;

#
293
# Test Slice::get_all_SimilarityFeatures
Graham McVicker's avatar
Graham McVicker committed
294
#
295
is($count, scalar @{$slice->get_all_SimilarityFeatures}, "Checking count of returned similarity features");
Graham McVicker's avatar
Graham McVicker committed
296 297

#
298
#  Test Slice::get_all_SimpleFeatures
Graham McVicker's avatar
Graham McVicker committed
299 300 301 302
#
ok(scalar @{$slice->get_all_SimpleFeatures});

#
303
#  Test Slice::get_all_RepeatFeatures
Graham McVicker's avatar
Graham McVicker committed
304 305 306 307
#
ok(scalar @{$slice->get_all_RepeatFeatures});

#
308
#  Test Slice::get_all_Genes
Graham McVicker's avatar
Graham McVicker committed
309 310 311 312
#
ok(scalar @{$slice->get_all_Genes});

#
313
#  Test Slice::get_all_Genes_by_type
Graham McVicker's avatar
Graham McVicker committed
314
#
315
ok(scalar @{$slice->get_all_Genes_by_type('protein_coding')});
Graham McVicker's avatar
Graham McVicker committed
316

317 318 319 320 321
#
#  Test Slice::get_all_Genes_by_source
#
ok(scalar @{$slice->get_all_Genes_by_source('ensembl')});

322 323 324 325 326
#
#  Test Slice::get_all_Transcripts
#
ok(scalar @{$slice->get_all_Transcripts});

327 328 329 330 331 332
#
# Test Slice:get_all_Exons
#

my @exons = @{$slice->get_all_Exons};
is(scalar(@exons), 155, "Fetched all exons");
Graham McVicker's avatar
Graham McVicker committed
333 334 335


#
336
# Test Slice::get_all_KaryotypeBands
Graham McVicker's avatar
Graham McVicker committed
337 338
#
ok(scalar @{$slice->get_all_KaryotypeBands});
339 340


Graham McVicker's avatar
Graham McVicker committed
341
#
342
# Test Slice::get_RepeatMaskedSeq
Graham McVicker's avatar
Graham McVicker committed
343 344 345 346 347 348 349 350 351
#
$seq = $slice->seq;
ok(length($slice->get_repeatmasked_seq->seq) == length($seq));

my $softmasked_seq = $slice->get_repeatmasked_seq(['RepeatMask'], 1)->seq;

ok($softmasked_seq ne $seq);
ok(uc($softmasked_seq) eq $seq);

352
$softmasked_seq = $seq = undef;
Graham McVicker's avatar
Graham McVicker committed
353 354

#
355
# Test Slice::get_all_MiscFeatures
Graham McVicker's avatar
Graham McVicker committed
356
#
357
ok(scalar @{$slice->get_all_MiscFeatures()});
Graham McVicker's avatar
Graham McVicker committed
358 359

#
360
# Test Slice::project
Graham McVicker's avatar
Graham McVicker committed
361
#
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377

my @segments = @{$slice->project( 'seqlevel' )};
ok(scalar @segments );

eval {
  my @sub_slices = map { $_->to_Slice() } @segments;
  my @starts = map { $_->from_start() } @segments;
  my @ends = map { $_->from_end() } @segments;
};

if( $@ ) {
  debug( "to_Slice call failed on segment of projection" );
  ok(0);
} else {
  ok(1)
}
Graham McVicker's avatar
Graham McVicker committed
378

379

380
#
381
# get_base_count
382
#
383 384 385 386 387 388 389
$hash = $slice->get_base_count;
$a = $hash->{'a'};
$c = $hash->{'c'};
$t = $hash->{'t'};
$g = $hash->{'g'};
$n = $hash->{'n'};
$gc_content = $hash->{'%gc'};
390 391 392 393 394 395 396 397 398 399

debug( "Base count: a=$a c=$c t=$t g=$g n=$n \%gc=$gc_content");
ok($a == 234371 
   && $c == 224761 
   && $t == 243734 
   && $g == 227135 
   && $n == 0 
   && $gc_content == 48.59 
   && $a+$c+$t+$g+$n == $slice->length);

400 401 402 403 404 405 406 407

$slice = $slice_adaptor->fetch_by_region('chromosome', '20', 10, 30);

my $sr_slice = $slice->seq_region_Slice();

ok($sr_slice->start() == 1 &&
   $sr_slice->end()   == $slice->seq_region_length() &&
   $sr_slice->strand() == 1);
408 409


410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427






# synonym tests
debug("START syn test");
my $multi = $multi_db;
$multi->save("core", "seq_region_synonym");

debug("get slice");
$slice = $slice_adaptor->fetch_by_region('chromosome', 20, 1, 10);

my @alt_names = @{$slice->get_all_synonyms()};
foreach my $syn (@alt_names){
  debug("syn\t".$syn->name."\n");
}
428
is(@alt_names, 2, "Got 2 altnames");
429 430 431 432 433


$slice->add_synonym("20ish");
@alt_names = @{$slice->get_all_synonyms()};

434
is(@alt_names, 3, "Got 3 alt names");
435 436 437 438 439 440 441 442 443 444 445 446


#slcie aleady stored so need to store syns
my $syn_adap =  $db->get_SeqRegionSynonymAdaptor; 
foreach my $syn (@alt_names){
 $syn_adap->store($syn);	
}

$slice = $slice_adaptor->fetch_by_region('chromosome', 20, 1, 10);

@alt_names = @{$slice->get_all_synonyms()};

447
is(@alt_names, 3, "Got 3 altnames");
448 449 450 451 452 453 454 455 456 457 458

$multi->restore();



$multi->save("core", 'seq_region_synonym');

$slice = $slice_adaptor->fetch_by_region('chromosome', 1, 1, 10);

@alt_names = @{$slice->get_all_synonyms()};

459 460
is(@alt_names, 0, "No altnames returned");

461 462 463 464 465

$slice->add_synonym("1ish");

@alt_names = @{$slice->get_all_synonyms()};

466
is(@alt_names, 1, "One synonym retrieved");
467 468 469 470 471 472 473 474 475 476

foreach my $syn (@alt_names){
 $syn_adap->store($syn);	
}


$slice = $slice_adaptor->fetch_by_region('chromosome', 1, 1, 10);

@alt_names = @{$slice->get_all_synonyms()};

477
is(@alt_names, 1, "One synonym found");
478 479

$multi->restore();
480

481 482 483 484 485 486 487 488 489 490 491
# Testing synonym searching
{
  my $chr_20 = $slice_adaptor->fetch_by_region('chromosome', 20);
  my ($syn) = @{$chr_20->get_all_synonyms('RFAM')};
  is($syn->name(), 'anoth_20', 'We have the right synonym');
  dies_ok { $chr_20->get_all_synonyms('RFAM', 'wibble') } 'Bad external DB version means dying code';
  dies_ok { $chr_20->get_all_synonyms('RFAMing', 'wibble') } 'Bad external DB name means dying code';
  ($syn) = @{$chr_20->get_all_synonyms('RFAM', 1)};
  is($syn->name(), 'anoth_20', 'We have the right synonym');
}

492 493 494 495 496 497 498

#Test assembly exception type on HAP
my $hap_slice = $slice_adaptor->fetch_by_region(undef, '20_HAP1');
is($hap_slice->assembly_exception_type(), 'HAP', 'Ensuring haplotype regions are HAP');
my $chr_one_slice = $slice_adaptor->fetch_by_region('chromosome', '1', 1, 10);
is($chr_one_slice->assembly_exception_type(), 'REF', 'Ensuring reference regions are REF');

499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
#Test slice iterator
{
  my $large_slice = $slice_adaptor->fetch_by_region('chromosome', 1, 1, 21);
  my $map = sub { $_->length() };
  my $si = sub {
    my ($chunk) = @_;
    return $large_slice->sub_Slice_Iterator($chunk)->map($map)->to_arrayref();
  };
  is_deeply($si->(100), [21], 'Subslice larger than actual slice gives just 1 slice back');
  is_deeply($si->(10), [10,10,1], 'Subslice smaller than actual slice gives 3 slices back');
  is_deeply($si->(20), [20,1], 'Subslice just smaller than actual slice gives 2 slices back');
  is_deeply($si->(21), [21], 'Subslice equal to slice size gives 1 slice back');
  my $slice_count = $large_slice->sub_Slice_Iterator(1)->reduce(sub { $_[0]+1 }, 0);
  is($slice_count, 21, 'Giving a subslice size of 1 means 21 slices');
  
  {
    my $fake_slice = Bio::EnsEMBL::Slice->new(-SEQ => 'AAACCCTTTGGGA', 
      -START => 1, -END => 13, -SEQ_REGION_NAME => 'fake', 
      -COORD_SYSTEM => $coord_system);
    my $subseqs = $fake_slice->sub_Slice_Iterator(3)->map(sub { $_->seq() })->to_arrayref();
    my $expected = ['AAA','CCC','TTT','GGG','A'];
    is_deeply($subseqs, $expected, 'Calling seq on subslices returns only the sequence for the bounds');
  }
  
  {
    my $one_bp_slice = Bio::EnsEMBL::Slice->new(-SEQ => 'A', 
      -START => 1, -END => 1, -SEQ_REGION_NAME => 'fake', 
      -COORD_SYSTEM => $coord_system);
    my $subseqs = $one_bp_slice->sub_Slice_Iterator(1)->map(sub { $_->seq() })->to_arrayref();
    my $expected = ['A'];
    is_deeply($subseqs, $expected, 'Calling seq on subslices for 1bp slice returns only an A');
  }
}

533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
# Test alternative region mappings from fetch_by_seq_region_id()
{
  my $current_slice = $slice_adaptor->fetch_by_region('chromosome', $CHR, $START, $END);
  my $alternative_seq_region_id = 1;

  #Get the alternative seq region id. Expect nothing
  ok(! defined $slice_adaptor->fetch_by_seq_region_id($alternative_seq_region_id), 'Asking for a non-existent ID results in no slice returned');

  #Save the tables and add the mapping values in
  my @tables = ('seq_region_mapping', 'mapping_set');
  $multi_db->save('core', @tables);
  my $ms_sql = 'insert into mapping_set (mapping_set_id, internal_schema_build, external_schema_build) values (?,?,?)';
  $db->dbc->sql_helper->execute_update(-SQL => $ms_sql, -PARAMS => [1, $db->_get_schema_build(), 'oldbuild']);
  my $srm_sql = 'insert into seq_region_mapping (mapping_set_id, internal_seq_region_id, external_seq_region_id) values (?,?,?)';
  $db->dbc->sql_helper->execute_update(-SQL => $srm_sql, -PARAMS => [1, $current_slice->get_seq_region_id(), $alternative_seq_region_id]);


  #Force a refresh in CSA
  delete $db->get_CoordSystemAdaptor->{$_} for qw/_internal_seq_region_mapping _external_seq_region_mapping/;
  $db->get_CoordSystemAdaptor->_cache_seq_region_mapping();
  my $alternative_slice = $slice_adaptor->fetch_by_seq_region_id($alternative_seq_region_id);
  ok(!defined $alternative_slice, 'Cannot retrieve the alternative slice without asking to look at alternatives');
  $alternative_slice = $slice_adaptor->fetch_by_seq_region_id($alternative_seq_region_id, undef, undef, undef, 1); #don't care about start,end,strand
  ok(defined $alternative_slice, 'Got a slice after asking for it');
  cmp_ok($current_slice->get_seq_region_id(), '==', $alternative_slice->get_seq_region_id(), 'Seq region IDs should be equivalent even though query seq_region_id was different');
  
  #Restore & force a refresh
  $multi_db->restore('core', @tables);
  delete $db->get_CoordSystemAdaptor->{$_} for qw/_internal_seq_region_mapping _external_seq_region_mapping/;
  $db->get_CoordSystemAdaptor->_cache_seq_region_mapping();

  # Just checking we are back to normal
  $alternative_slice = $slice_adaptor->fetch_by_seq_region_id($alternative_seq_region_id);
  ok(!defined $alternative_slice, 'Cannot retrieve the alternative slice post restore');
}

569 570 571 572

# Test slice attributes
my $current_slice = $slice_adaptor->fetch_by_region('chromosome', $CHR, $START, $END);
is($current_slice->is_chromosome, 1, "Slice is a chromosome");
573 574
is($current_slice->has_karyotype, 1, "Slice has a karyotype attribute");
is($current_slice->karyotype_rank, 20, "Karyotype rank is 20 could be found");
575

576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
#
# Test get_genome_component
#
debug("Testing fetch_all_by_genome_component");
my $multi_polyploid = Bio::EnsEMBL::Test::MultiTestDB->new("polyploidy");
my $wheatdb = $multi_polyploid->get_DBAdaptor("core");
my $wheat_slice_adaptor = Bio::EnsEMBL::DBSQL::SliceAdaptor->new($wheatdb);
isa_ok($wheat_slice_adaptor, 'Bio::EnsEMBL::DBSQL::SliceAdaptor');

# should get an empty result for a slice on human chr (not polyploidy)
$slice = $slice_adaptor->fetch_by_region('chromosome', $CHR, $START, $END);
isa_ok($slice, 'Bio::EnsEMBL::Slice');
my $genome_component = $slice->get_genome_component();
ok(!$genome_component, "Genome component for human slice");

# test with slices on polyploid genome
$slice = $wheat_slice_adaptor->fetch_by_region('scaffold', 'IWGSC_CSS_5AL_scaff_2697823', 100, 10000);
isa_ok($slice, 'Bio::EnsEMBL::Slice');
$genome_component = $slice->get_genome_component();
is($genome_component, 'A', "Genome component from slice");

$slice = $wheat_slice_adaptor->fetch_by_region('scaffold', 'IWGSC_CSS_6BS_scaff_233977', 1000, 5000, -1);
isa_ok($slice, 'Bio::EnsEMBL::Slice');
$genome_component = $slice->get_genome_component();
is($genome_component, 'B', "Genome component from slice");

$slice = $wheat_slice_adaptor->fetch_by_region('scaffold', 'IWGSC_CSS_6DS_scaff_2121653', 1000, 3000);
isa_ok($slice, 'Bio::EnsEMBL::Slice');
$genome_component = $slice->get_genome_component($slice);
is($genome_component, 'D', "Genome component from slice");

607 608
done_testing();