Skip to content

Commit

Permalink
Merge pull request #240 from ens-lgil/release/92
Browse files Browse the repository at this point in the history
Fix an issue with the flag '--shift_hgvs'
  • Loading branch information
aparton committed Jul 17, 2018
2 parents 8580ec6 + cb76e2c commit 1ee4188
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
17 changes: 15 additions & 2 deletions modules/Bio/EnsEMBL/VEP/BaseRunner.pm
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
1;
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/VEP/Constants.pm
Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions t/OutputFactory.t
Expand Up @@ -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);

$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,
Expand All @@ -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();
Expand Down

0 comments on commit 1ee4188

Please sign in to comment.