Skip to content

Commit

Permalink
Fix for custom VCF overlapping insertions
Browse files Browse the repository at this point in the history
  • Loading branch information
William McLaren committed Jan 5, 2017
1 parent 3cf03f2 commit 46b97d5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
7 changes: 6 additions & 1 deletion modules/Bio/EnsEMBL/VEP/AnnotationSource/File.pm
Expand Up @@ -216,7 +216,12 @@ sub _record_overlaps_VF {
my $type = $self->type();

if($type eq 'overlap') {
return overlap($parser->get_start, $parser->get_end, $vf->{start}, $vf->{end});

# account for insertions in Ensembl world where s = e+1
my ($vs, $ve) = ($vf->{start}, $vf->{end});
($vs, $ve) = ($ve, $vs) if $vs > $ve;

return overlap($parser->get_start, $parser->get_end, $vs, $ve);
}
elsif($type eq 'exact') {
return $parser->get_start == $vf->{start} && $parser->get_end == $vf->{end};
Expand Down
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/VEP/Constants.pm
Expand Up @@ -20,7 +20,7 @@ use warnings;
use base qw(Exporter);

our $VEP_VERSION = 87;
our $VEP_SUB_VERSION = 17;
our $VEP_SUB_VERSION = 18;

our @EXPORT_OK = qw(
@FLAG_FIELDS
Expand Down
37 changes: 36 additions & 1 deletion t/AnnotationSource_File_VCF.t
Expand Up @@ -80,8 +80,42 @@ SKIP: {
'annotate_InputBuffer - overlap'
);

# overlap with insertions
$ib = Bio::EnsEMBL::VEP::InputBuffer->new({
config => $cfg,
parser => Bio::EnsEMBL::VEP::Parser::VEP_input->new({
config => $cfg,
file => $test_cfg->create_input_file([qw(21 25585746 25585745 -/C)]),
valid_chromosomes => [21]
})
});
$ib->next;
$as->annotate_InputBuffer($ib);

is_deeply(
$ib->buffer->[0]->{_custom_annotations},
{
'test.vcf.gz' => [
{
'name' => 'ins2'
}
]
},
'annotate_InputBuffer - overlap - insertion'
);


# report_coords
delete($ib->buffer->[0]->{_custom_annotations});
$ib = Bio::EnsEMBL::VEP::InputBuffer->new({
config => $cfg,
parser => Bio::EnsEMBL::VEP::Parser::VEP_input->new({
config => $cfg,
file => $test_cfg->create_input_file([qw(21 25585733 25585733 C/T + rs142513484)]),
valid_chromosomes => [21]
})
});
$ib->next;

$as->report_coords(1);
$as->annotate_InputBuffer($ib);
is_deeply(
Expand All @@ -96,6 +130,7 @@ SKIP: {
$as->report_coords(0);



# VCF info fields
delete($ib->buffer->[0]->{_custom_annotations});
$as->fields(['FOO', 'GOO']);
Expand Down
Binary file modified t/testdata/custom/test.vcf.gz
Binary file not shown.
Binary file modified t/testdata/custom/test.vcf.gz.tbi
Binary file not shown.

0 comments on commit 46b97d5

Please sign in to comment.