Skip to content

Commit

Permalink
Merge 1284218 into da0f402
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstranneheim committed Jul 13, 2019
2 parents da0f402 + 1284218 commit d80ffc9
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 33 deletions.
35 changes: 34 additions & 1 deletion lib/MIP/Vcfparser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ BEGIN {
our $VERSION = 1.00;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ build_interval_tree define_select_data_headers };
our @EXPORT_OK = qw{
build_interval_tree
define_select_data_headers
define_snpeff_annotations
};
}

sub build_interval_tree {
Expand Down Expand Up @@ -146,4 +150,33 @@ q{##INFO=<ID=No_hgnc_symbol,Number=.,Type=String,Description="Clinically relevan
return %select_data;
}

sub define_snpeff_annotations {

## Function : Defines the snpeff annotations that can be parsed and modified from snpeff
## Returns : %snpeff_cmd
## Arguments: None

my %snpeff_cmd;

$snpeff_cmd{snpeff}{q{GERP++_RS_prediction_term}}{File} = q{SnpSift dbnsfp};
$snpeff_cmd{snpeff}{q{GERP++_RS_prediction_term}}{vcf_key} =
q{dbNSFP_GERP___RS};
$snpeff_cmd{snpeff}{q{GERP++_RS_prediction_term}}{info} =
q{##INFO=<ID=GERP++_RS_prediction_term,Number=A,Type=String,Description="GERP RS conservation prediction term">};
$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{File} =
q{SnpSift dbnsfp};
$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{vcf_key} =
q{dbNSFP_phastCons100way_vertebrate};
$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{info} =
q{##INFO=<ID=phastCons100way_vertebrate_prediction_term,Number=A,Type=String,Description="PhastCons conservation prediction term">};
$snpeff_cmd{snpeff}{phyloP100way_vertebrate_prediction_term}{File} =
q{SnpSift dbnsfp};
$snpeff_cmd{snpeff}{phyloP100way_vertebrate_prediction_term}{vcf_key} =
q{dbNSFP_phyloP100way_vertebrate};
$snpeff_cmd{snpeff}{phyloP100way_vertebrate_prediction_term}{info} =
q{##INFO=<ID=phyloP100way_vertebrate_prediction_term,Number=A,Type=String,Description="PhyloP conservation prediction term">};

return %snpeff_cmd;
}

1;
3 changes: 2 additions & 1 deletion t/define_select_data_headers.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ diag( q{Test define_select_data_headers from Vcfparser.pm v}
my %select_data = define_select_data_headers();

my $hgnc_symbol_info_header =
q?##INFO=<ID=HGNC_symbol,Number=.,Type=String,Description="The HGNC gene symbol">?;
q{##INFO=<ID=HGNC_symbol,Number=.,Type=String,Description="The HGNC gene symbol">};

## Then keys should exist and header info should be set
ok( keys %select_data, q{Returned hash keys} );

Expand Down
75 changes: 75 additions & 0 deletions t/define_snpeff_annotations.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env perl

use 5.026;
use Carp;
use charnames qw{ :full :short };
use English qw{ -no_match_vars };
use File::Basename qw{ dirname };
use File::Spec::Functions qw{ catdir };
use FindBin qw{ $Bin };
use open qw{ :encoding(UTF-8) :std };
use Params::Check qw{ allow check last_error };
use Test::More;
use utf8;
use warnings qw{ FATAL utf8 };

## CPANM
use autodie qw { :all };
use Modern::Perl qw{ 2014 };
use Readonly;

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COMMA $SPACE };
use MIP::Test::Fixtures qw{ test_standard_cli };

my $VERBOSE = 1;
our $VERSION = 1.00;

$VERBOSE = test_standard_cli(
{
verbose => $VERBOSE,
version => $VERSION,
}
);

BEGIN {

use MIP::Test::Fixtures qw{ test_import };

### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Vcfparser} => [qw{ define_snpeff_annotations }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
);

test_import( { perl_module_href => \%perl_module, } );
}

use MIP::Vcfparser qw{ define_snpeff_annotations };

diag( q{Test define_snpeff_annotations from Vcfparser.pm v}
. $MIP::Vcfparser::VERSION
. $COMMA
. $SPACE . q{Perl}
. $SPACE
. $PERL_VERSION
. $SPACE
. $EXECUTABLE_NAME );

## Given snpeff annotations
my %snpeff_cmd = define_snpeff_annotations();

my $phastcons100way_vertebrate_prediction_term_file = q{SnpSift dbnsfp};

## Then keys should exist and annotation info should be set
ok( keys %snpeff_cmd, q{Returned hash keys} );

is(
$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{File},
$phastcons100way_vertebrate_prediction_term_file,
q{Got file info for annotation key}
);

done_testing();
32 changes: 1 addition & 31 deletions vcfparser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use MIP::File::Format::Feature_file qw{ read_feature_file };
use MIP::Log::MIP_log4perl qw{ initiate_logger };
use MIP::Script::Utils qw{ help };
use MIP::Vcfparser qw{ define_select_data_headers };
use MIP::Vcfparser qw{ define_select_data_headers define_snpeff_annotations };

our $USAGE = build_usage( {} );

Expand Down Expand Up @@ -282,36 +282,6 @@ sub build_usage {
END_USAGE
}

sub define_snpeff_annotations {

## Function : Defines the snpeff annotations that can be parsed and modified
## Returns : %snpeff_cmd
## Arguments: None

my %snpeff_cmd;

$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{File} =
q?SnpSift dbnsfp?;
$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{vcf_key} =
q?dbNSFP_phastCons100way_vertebrate?;
$snpeff_cmd{snpeff}{phastCons100way_vertebrate_prediction_term}{info} =
q?##INFO=<ID=phastCons100way_vertebrate_prediction_term,Number=A,Type=String,Description="PhastCons conservation prediction term">?;

$snpeff_cmd{snpeff}{phyloP100way_vertebrate_prediction_term}{File} =
q?SnpSift dbnsfp?;
$snpeff_cmd{snpeff}{phyloP100way_vertebrate_prediction_term}{vcf_key} =
q?dbNSFP_phyloP100way_vertebrate?;
$snpeff_cmd{snpeff}{phyloP100way_vertebrate_prediction_term}{info} =
q?##INFO=<ID=phyloP100way_vertebrate_prediction_term,Number=A,Type=String,Description="PhyloP conservation prediction term">?;

$snpeff_cmd{snpeff}{q{GERP++_RS_prediction_term}}{File} = q{SnpSift dbnsfp};
$snpeff_cmd{snpeff}{q{GERP++_RS_prediction_term}}{vcf_key} =
q{dbNSFP_GERP___RS};
$snpeff_cmd{snpeff}{q{GERP++_RS_prediction_term}}{info} =
q?##INFO=<ID=GERP++_RS_prediction_term,Number=A,Type=String,Description="GERP RS conservation prediction term">?;
return %snpeff_cmd;
}

sub define_consequence_severity {

## Function : Defines the precedence of consequences for SO-terms
Expand Down

0 comments on commit d80ffc9

Please sign in to comment.