Skip to content

Commit

Permalink
fix for multiple custom annotations at same locus
Browse files Browse the repository at this point in the history
  • Loading branch information
William McLaren committed Feb 20, 2017
1 parent e79ac34 commit 11c3214
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 6 deletions.
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 = 24;
our $VEP_SUB_VERSION = 25;

our @EXPORT_OK = qw(
@FLAG_FIELDS
Expand Down
4 changes: 2 additions & 2 deletions modules/Bio/EnsEMBL/VEP/OutputFactory.pm
Expand Up @@ -806,10 +806,10 @@ sub _add_custom_annotations_to_hash {
my ($self, $hash, $custom_name, $annots) = @_;

foreach my $annot(@$annots) {
$hash->{$custom_name} = $annot->{name};
push @{$hash->{$custom_name}}, $annot->{name};

foreach my $field(keys %{$annot->{fields} || {}}) {
$hash->{$custom_name.'_'.$field} = $annot->{fields}->{$field};
push @{$hash->{$custom_name.'_'.$field}}, $annot->{fields}->{$field};
}
}

Expand Down
41 changes: 40 additions & 1 deletion t/OutputFactory.t
Expand Up @@ -240,7 +240,25 @@ is_deeply(
);
delete($of->{individual});

$of->get_all_output_hashes_by_VariationFeature($ib->buffer->[0]);

$ib->buffer->[0]->{_custom_annotations} = {
custom1 => [ {name => 'foo'} ],
custom2 => [ {name => 'bar'}, {name => 'car'} ],
custom3 => [ {allele => 'A', name => 'shoe'} ], # this one will be ignored as it has allele key
};
is_deeply(
$of->VariationFeature_to_output_hash($ib->buffer->[0]),
{
'Uploaded_variation' => 'indtest',
'Location' => '21:25587759',
'IND' => 'dave',
'ZYG' => 'HET',
'custom1' => ['foo'],
'custom2' => ['bar', 'car'],
},
'VariationFeature_to_output_hash - custom annotations'
);




Expand Down Expand Up @@ -589,6 +607,27 @@ $of->{flag_pick} = 0;



$ib->buffer->[0]->{_custom_annotations} = {
custom1 => [ {allele => 'T', name => 'foo'} ],
custom2 => [ {name => 'bar'}, {name => 'car'} ], # this one will be ignored as it has no allele key
custom3 => [ {allele => 'T', name => 'shoe'}, {allele => 'T', name => 'moo'} ],
};
is_deeply(
$of->VariationFeatureOverlapAllele_to_output_hash($vfoa, {}, $ib->buffer->[0]),
{
'IMPACT' => 'MODIFIER',
'Consequence' => [
'3_prime_UTR_variant'
],
'Allele' => 'T',
'PICK' => 1,
'custom1' => ['foo'],
'custom3' => ['shoe', 'moo'],
},
'VariationFeatureOverlapAllele_to_output_hash - custom annotations'
);



## frequency tests
##################
Expand Down
30 changes: 29 additions & 1 deletion t/OutputFactory_JSON.t
Expand Up @@ -462,7 +462,7 @@ SKIP: {
no warnings 'once';

## REMEMBER TO UPDATE THIS SKIP NUMBER IF YOU ADD MORE TESTS!!!!
skip 'Bio::DB::HTS::Tabix module not available', 1 unless $Bio::EnsEMBL::VEP::AnnotationSource::File::CAN_USE_TABIX_PM;
skip 'Bio::DB::HTS::Tabix module not available', 2 unless $Bio::EnsEMBL::VEP::AnnotationSource::File::CAN_USE_TABIX_PM;

$ib = get_annotated_buffer({
input_file => $test_cfg->{test_vcf},
Expand All @@ -488,6 +488,34 @@ SKIP: {
},
'custom_annotations'
);

$ib = get_annotated_buffer({
input_data => "21\t25585733\t.\tCATG\tTACG",
everything => 1,
dir => $test_cfg->{cache_root_dir},
custom => [$test_cfg->{custom_vcf}.',test,vcf,overlap'],
});
$of = Bio::EnsEMBL::VEP::OutputFactory::JSON->new({config => $ib->config});
@lines = @{$of->get_all_lines_by_InputBuffer($ib)};

is_deeply(
$json->decode($lines[0])->{custom_annotations},
{
"test" => [
{
"name" => "test1",
},
{
"name" => "del1",
},
{
"name" => "del2",
}

]
},
'custom_annotations overlap'
);
}
}

Expand Down
19 changes: 18 additions & 1 deletion t/OutputFactory_VCF.t
Expand Up @@ -356,7 +356,7 @@ SKIP: {
no warnings 'once';

## REMEMBER TO UPDATE THIS SKIP NUMBER IF YOU ADD MORE TESTS!!!!
skip 'Bio::DB::HTS::Tabix module not available', 1 unless $Bio::EnsEMBL::VEP::AnnotationSource::File::CAN_USE_TABIX_PM;
skip 'Bio::DB::HTS::Tabix module not available', 2 unless $Bio::EnsEMBL::VEP::AnnotationSource::File::CAN_USE_TABIX_PM;

$runner = get_runner({
input_file => $test_cfg->{test_vcf},
Expand All @@ -373,6 +373,23 @@ SKIP: {
"T|upstream_gene_variant|MODIFIER||ENSG00000260583|Transcript|ENST00000567517||||||||||||2407|-1|||test1|BAR\tGT\t0|0",
'get_all_lines_by_InputBuffer - custom'
);


$runner = get_runner({
input_data => "21\t25585733\t.\tCATG\tTACG",
custom => [$test_cfg->{custom_vcf}.',test,vcf,overlap'],
output_format => 'vcf',
});
$of = $runner->get_OutputFactory;

is(
$of->get_all_lines_by_InputBuffer($runner->get_InputBuffer)->[0],
"21\t25585733\t.\tCATG\tTACG\t.\t.\t".
"CSQ=TACG|3_prime_UTR_variant|MODIFIER||ENSG00000154719|Transcript|ENST00000307301||||||1119-1122|||||||-1|||test1&del1&del2,".
"TACG|missense_variant|MODERATE||ENSG00000154719|Transcript|ENST00000352957||||||1030-1033|988-991|330-331|HA/RT|CATGca/CGTAca|||-1|||test1&del1&del2,".
"TACG|upstream_gene_variant|MODIFIER||ENSG00000260583|Transcript|ENST00000567517||||||||||||2407|-1|||test1&del1&del2",
'get_all_lines_by_InputBuffer - custom overlap'
);
}

# test converting to VCF from different input
Expand Down

0 comments on commit 11c3214

Please sign in to comment.