Skip to content

Commit

Permalink
Haplo - fix chromosome match (#487)
Browse files Browse the repository at this point in the history
* Fix chromosome comparison

* Test non numeric chromosome
  • Loading branch information
dglemos authored and ens-lgil committed Jun 6, 2019
1 parent c9cbd42 commit 0f37f44
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/VEP/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use warnings;
use base qw(Exporter);

our $VEP_VERSION = 96;
our $VEP_SUB_VERSION = 1;
our $VEP_SUB_VERSION = 2;

our @EXPORT_OK = qw(
@FLAG_FIELDS
Expand Down
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/VEP/Haplo/InputBuffer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ sub next {
return $buffer unless $max;

# Continue to add VF to buffer until VF start > max or VF on different chromosome
while($vf && $vf->{start} <= $max && $vf->{chr} == $current_chr) {
while($vf && $vf->{start} <= $max && $vf->{chr} eq $current_chr) {
push @$buffer, $vf;
$vf = $parser->next;
}
Expand Down
17 changes: 15 additions & 2 deletions t/Haplo_InputBuffer.t
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,24 @@ SKIP: {

# Chr 21
$vfs = $ib->next;
ok(scalar(@$vfs) == 3 && $vfs->[0]->{chr} == 21, 'The 3 entries from chr21 are in the same buffer');
ok(scalar(@$vfs) == 3 && $vfs->[0]->{chr} == 21, 'The 3 entries from chromosome 21 are in the same buffer');

# Chr 22
$vfs = $ib->next;
ok(scalar(@$vfs) == 1 && $vfs->[0]->{chr} == 22, 'The entry from chr22 is in a different buffer');
ok(scalar(@$vfs) == 1 && $vfs->[0]->{chr} == 22, 'The entry from chromosome 22 is in a different buffer');

# Test non numeric chromosomes
my $runner3 = Bio::EnsEMBL::VEP::Haplo::Runner->new({%{$test_cfg->base_testing_cfg}, input_file => $test_cfg->{test_vcf4}});

$ib = $runner3->get_InputBuffer;

# chr21
$vfs = $ib->next;
ok(scalar(@$vfs) == 3 && $vfs->[0]->{chr} eq 'chr21', 'The 3 entries from chr21 are in the same buffer');

# chr22
$vfs = $ib->next;
ok(scalar(@$vfs) == 1 && $vfs->[0]->{chr} eq 'chr22', 'The entry from chr22 is in a different buffer');

}

Expand Down
1 change: 1 addition & 0 deletions t/VEPTestingConfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ our %DEFAULTS = (
test_vcf => $Bin.'/testdata/input/test.vcf',
test_vcf2 => $Bin.'/testdata/input/test2.vcf',
test_vcf3 => $Bin.'/testdata/input/test3.vcf',
test_vcf4 => $Bin.'/testdata/input/test4.vcf',
vr_vcf => $Bin.'/testdata/input/idt_test.vcf',
windows_vcf => $Bin.'/testdata/input/windows.vcf',
test_gzvcf => $Bin.'/testdata/input/test.vcf.gz',
Expand Down
7 changes: 7 additions & 0 deletions t/testdata/input/test4.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##fileformat=VCFv4.1
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT P1
chr21 25769083 var2_chr21 CT C . PASS . GT 0|1
chr21 25769085 var3_chr21 T TT . PASS . GT 0|1
chr21 25769093 var4_chr21 A G . PASS . GT 0|1
chr22 25769065 var5_chr22 G T . PASS . GT 0|1

0 comments on commit 0f37f44

Please sign in to comment.