From 7569fabc4ea6cc3cc283cd4201a942722e4d6418 Mon Sep 17 00:00:00 2001 From: Laurent Gil Date: Thu, 12 Jul 2018 13:13:32 +0100 Subject: [PATCH 1/2] Fix an issue with the flag '--shift_hgvs' --- modules/Bio/EnsEMBL/VEP/BaseRunner.pm | 17 ++++++++- modules/Bio/EnsEMBL/VEP/Constants.pm | 2 +- t/OutputFactory.t | 55 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/modules/Bio/EnsEMBL/VEP/BaseRunner.pm b/modules/Bio/EnsEMBL/VEP/BaseRunner.pm index 568afb2d5..dd29a0fea 100644 --- a/modules/Bio/EnsEMBL/VEP/BaseRunner.pm +++ b/modules/Bio/EnsEMBL/VEP/BaseRunner.pm @@ -423,6 +423,16 @@ sub _set_package_variables { $self->{_verbose_bak} = Bio::EnsEMBL::Utils::Exception::verbose(); Bio::EnsEMBL::Utils::Exception::verbose(1999); + # HGVS shifting + # Variable used when DB connection + $self->{_shift_hgvs_db_bak} = $Bio::EnsEMBL::Variation::DBSQL::DBAdaptor::DEFAULT_SHIFT_HGVS_VARIANTS_3PRIME; + # Variable used when offline + $self->{_shift_hgvs_bak} = $Bio::EnsEMBL::Variation::DBSQL::TranscriptVariationAdaptor::DEFAULT_SHIFT_HGVS_VARIANTS_3PRIME; + if (defined($self->param('shift_hgvs')) && $self->param('shift_hgvs') =~ /(0|1)/ ) { + $Bio::EnsEMBL::Variation::DBSQL::DBAdaptor::DEFAULT_SHIFT_HGVS_VARIANTS_3PRIME = $self->param('shift_hgvs'); + $Bio::EnsEMBL::Variation::DBSQL::TranscriptVariationAdaptor::DEFAULT_SHIFT_HGVS_VARIANTS_3PRIME = $self->param('shift_hgvs'); + } + # up/downstream distance if(my $distances = $self->param('distance')) { my ($u, $d) = @$distances; @@ -439,7 +449,7 @@ sub _set_package_variables { =head2 _reset_package_variables - Example : $runner->_set_package_variables(); + Example : $runner->_reset_package_variables(); Description: Re-sets package variables altered by _set_package_variables Returntype : none Exceptions : none @@ -457,8 +467,11 @@ sub _reset_package_variables { Bio::EnsEMBL::Utils::Exception::verbose($self->{_verbose_bak}); + $Bio::EnsEMBL::Variation::DBSQL::TranscriptVariationAdaptor::DEFAULT_SHIFT_HGVS_VARIANTS_3PRIME = $self->{_shift_hgvs_bak} if defined($self->{_shift_hgvs_bak}); + $Bio::EnsEMBL::Variation::DBSQL::DBAdaptor::DEFAULT_SHIFT_HGVS_VARIANTS_3PRIME = $self->{_shift_hgvs_db_bak} if defined($self->{_shift_hgvs_db_bak}); + $Bio::EnsEMBL::Variation::Utils::VariationEffect::UPSTREAM_DISTANCE = $self->{_upstream_bak} if defined($self->{_upstream_bak}); $Bio::EnsEMBL::Variation::Utils::VariationEffect::DOWNSTREAM_DISTANCE = $self->{_downstream_bak} if defined($self->{_downstream_bak}); } -1; \ No newline at end of file +1; diff --git a/modules/Bio/EnsEMBL/VEP/Constants.pm b/modules/Bio/EnsEMBL/VEP/Constants.pm index ede006770..cb1b7848f 100644 --- a/modules/Bio/EnsEMBL/VEP/Constants.pm +++ b/modules/Bio/EnsEMBL/VEP/Constants.pm @@ -53,7 +53,7 @@ use warnings; use base qw(Exporter); our $VEP_VERSION = 92; -our $VEP_SUB_VERSION = 5; +our $VEP_SUB_VERSION = 6; our @EXPORT_OK = qw( @FLAG_FIELDS diff --git a/t/OutputFactory.t b/t/OutputFactory.t index ada3c5c85..9efa50bc6 100644 --- a/t/OutputFactory.t +++ b/t/OutputFactory.t @@ -1903,12 +1903,63 @@ ok($tmp =~ /went wrong/, 'run_plugins - new fails message'); open(STDERR, ">&SAVE") or die "Can't restore STDERR\n"; +## HGVS shifting +################ + +$of->{hgvs} = 1; +$of->{hgvsg} = 1; +my $input_file_example = $test_cfg->create_input_file([qw(21 25592985 hgvsins A ATAAA . . .)]); + +# Shifting ON +$ib = get_annotated_buffer({ + input_file => $input_file_example, + shift_hgvs => 1 +},1); + +my $vfoa = $of->get_all_VariationFeatureOverlapAlleles($ib->buffer->[0])->[0]; +is_deeply( + $of->VariationFeatureOverlapAllele_to_output_hash($vfoa, {}, $ib->buffer->[0]), + { + "IMPACT" => "MODIFIER", + "Consequence" => [ + "intron_variant" + ], + "HGVSg" => "21:g.25592986_25592989dup", + "Allele" => "TAAA" + }, + 'HGVS 3prime shifting - ON' +); + +# Shifting OFF +$ib = get_annotated_buffer({ + input_file => $input_file_example, + shift_hgvs => 0 +},1); + +$vfoa = $of->get_all_VariationFeatureOverlapAlleles($ib->buffer->[0])->[0]; +is_deeply( + $of->VariationFeatureOverlapAllele_to_output_hash($vfoa, {}, $ib->buffer->[0]), + { + "IMPACT" => "MODIFIER", + "Consequence" => [ + "intron_variant" + ], + "HGVSg" => "21:g.25592982_25592985dup", + "Allele" => "TAAA" + }, + 'HGVS 3prime shifting - OFF' +); + +$of->{hgvs} = 0; +$of->{hgvsg} = 0; + # done done_testing(); sub get_annotated_buffer { my $tmp_cfg = shift; + my $set_package_variables = shift; my $runner = Bio::EnsEMBL::VEP::Runner->new({ %$cfg_hash, @@ -1917,6 +1968,10 @@ sub get_annotated_buffer { }); $runner->init; + # Force setting the package variables as the 'run' method is not used here + if ($set_package_variables) { + $runner->_set_package_variables(); + } my $ib = $runner->get_InputBuffer; $ib->next(); From cb76e2c421b00b4d65b789740f9a0e39cc2bf284 Mon Sep 17 00:00:00 2001 From: Laurent Gil Date: Tue, 17 Jul 2018 15:51:46 +0100 Subject: [PATCH 2/2] Fix test --- t/OutputFactory.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/OutputFactory.t b/t/OutputFactory.t index 9efa50bc6..76590e50c 100644 --- a/t/OutputFactory.t +++ b/t/OutputFactory.t @@ -1916,7 +1916,7 @@ $ib = get_annotated_buffer({ shift_hgvs => 1 },1); -my $vfoa = $of->get_all_VariationFeatureOverlapAlleles($ib->buffer->[0])->[0]; +$vfoa = $of->get_all_VariationFeatureOverlapAlleles($ib->buffer->[0])->[0]; is_deeply( $of->VariationFeatureOverlapAllele_to_output_hash($vfoa, {}, $ib->buffer->[0]), {