Skip to content

Commit

Permalink
Merge a43ff9e into b08f11a
Browse files Browse the repository at this point in the history
  • Loading branch information
ramprasadn committed Nov 10, 2020
2 parents b08f11a + a43ff9e commit 4daa67c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 31 deletions.
25 changes: 22 additions & 3 deletions lib/MIP/Program/Bcftools.pm
Expand Up @@ -1134,6 +1134,8 @@ sub bcftools_norm {
## : $output_type => 'b' compressed BCF; 'u' uncompressed BCF; 'z' compressed VCF; 'v' uncompressed VCF [v]
## : $reference_path => Human genome reference path
## : $regions_ref => Regions to process {REF}
## : $remove_duplicates => If a record is present in multiple files, output only the first instance.
## : $remove_duplicates_type => Controls how to treat records with duplicate positions (snps|indels|both|all|some|none|id).
## : $samples_file_path => File of samples to annotate
## : $samples_ref => Samples to include or exclude if prefixed with "^"
## : $stderrfile_path => Stderr file path to write to {OPTIONAL}
Expand All @@ -1149,6 +1151,7 @@ sub bcftools_norm {
my $outfile_path;
my $reference_path;
my $regions_ref;
my $remove_duplicates;
my $samples_file_path;
my $samples_ref;
my $stderrfile_path;
Expand All @@ -1157,6 +1160,7 @@ sub bcftools_norm {

## Default(s)
my $multiallelic_type;
my $remove_duplicates_type;
my $output_type;

my $tmpl = {
Expand Down Expand Up @@ -1184,12 +1188,22 @@ sub bcftools_norm {
strict_type => 1,
},
reference_path => {
defined => 1,
required => 1,
store => \$reference_path,
strict_type => 1,
},
regions_ref => { default => [], store => \$regions_ref, strict_type => 1, },
regions_ref => { default => [], store => \$regions_ref, strict_type => 1, },
remove_duplicates => {
allow => [qw{ 0 1 }],
default => 0,
store => \$remove_duplicates,
strict_type => 1,
},
remove_duplicates_type => {
allow => [qw{ snps indels both all some none id }],
default => q{none},
store => \$remove_duplicates_type,
strict_type => 1,
},
samples_file_path => { store => \$samples_file_path, strict_type => 1, },
samples_ref => {
default => [],
Expand Down Expand Up @@ -1229,6 +1243,11 @@ sub bcftools_norm {
push @commands, q{--fasta-ref} . $SPACE . $reference_path;
}

if ( $remove_duplicates eq q{1} ) {

push @commands, q{--rm-dup} . $SPACE . $remove_duplicates_type;
}

if ($infile_path) {

push @commands, $infile_path;
Expand Down
53 changes: 36 additions & 17 deletions lib/MIP/Recipes/Analysis/Expansionhunter.pm
Expand Up @@ -133,11 +133,11 @@ sub analysis_expansionhunter {
use MIP::Get::Parameter qw{ get_recipe_attributes get_recipe_resources };
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ print_wait submit_recipe };
use MIP::Program::Bcftools qw{ bcftools_rename_vcf_samples bcftools_view };
use MIP::Program::Bcftools qw{ bcftools_index bcftools_norm bcftools_rename_vcf_samples bcftools_view };
use MIP::Program::Expansionhunter qw{ expansionhunter };
use MIP::Program::Htslib qw{ htslib_bgzip };
use MIP::Program::Stranger qw{ stranger };
use MIP::Program::Svdb qw{ svdb_merge };
use MIP::Program::Vt qw{ vt_decompose };
use MIP::Sample_info
qw{ get_pedigree_sample_id_attributes set_file_path_to_store set_recipe_outfile_in_sample_info };
use MIP::Script::Setup_script qw{ setup_script };
Expand Down Expand Up @@ -263,8 +263,9 @@ sub analysis_expansionhunter {

## Expansion hunter calling per sample id
# Expansionhunter sample infiles needs to be lexiographically sorted for svdb merge
my @vt_infile_paths;
my @vt_outfile_paths;
my @decompose_infile_paths;
my @decompose_infile_path_prefixes;
my @decompose_outfile_paths;

SAMPLE_ID:
while ( my ( $sample_id_index, $sample_id ) =
Expand Down Expand Up @@ -309,10 +310,11 @@ sub analysis_expansionhunter {
}
);
say {$filehandle} $AMPERSAND, $NEWLINE;
push @vt_infile_paths, $sample_outfile_path_prefix . $outfile_suffix;
push @vt_outfile_paths,
push @decompose_infile_paths, $sample_outfile_path_prefix . $outfile_suffix;
push @decompose_infile_path_prefixes, $sample_outfile_path_prefix;
push @decompose_outfile_paths,
$outfile_path_prefix
. $UNDERSCORE . q{vt}
. $UNDERSCORE . q{decompose}
. $UNDERSCORE
. $sample_id
. $outfile_suffix;
Expand All @@ -323,17 +325,34 @@ sub analysis_expansionhunter {
## Split multiallelic variants
say {$filehandle} q{## Split multiallelic variants};
## Create iterator object
my $vt_file_paths_iter = each_array( @vt_infile_paths, @vt_outfile_paths );
my $decompose_file_paths_iter = each_array( @decompose_infile_paths, @decompose_infile_path_prefixes, @decompose_outfile_paths );

VT_FILES_ITER:
while ( my ( $vt_infile_path, $vt_outfile_path ) = $vt_file_paths_iter->() ) {
DECOMPOSE_FILES_ITER:
while ( my ( $decompose_infile_path, $decompose_infile_path_prefix, $decompose_outfile_path ) = $decompose_file_paths_iter->() ) {

vt_decompose(
htslib_bgzip (
{
filehandle => $filehandle,
infile_path => $vt_infile_path,
outfile_path => $vt_outfile_path,
smart_decomposition => 1,
infile_path => $decompose_infile_path,
stdoutfile_path => $decompose_infile_path_prefix . q{.bcf},
write_to_stdout => 1,
}
);
say {$filehandle} $NEWLINE;
bcftools_index (
{
filehandle => $filehandle,
infile_path => $decompose_infile_path_prefix . q{.bcf},
output_type => q{tbi},
}
);
say {$filehandle} $NEWLINE;
bcftools_norm(
{
filehandle => $filehandle,
infile_path => $decompose_infile_path_prefix . q{.bcf},
multiallelic => q{-},
outfile_path => $decompose_outfile_path,
}
);
say {$filehandle} $NEWLINE;
Expand All @@ -342,12 +361,12 @@ sub analysis_expansionhunter {
## Get parameters
## Expansionhunter sample infiles needs to be lexiographically sorted for svdb merge
my $svdb_outfile_path =
$outfile_path_prefix . $UNDERSCORE . q{vt_svdbmerge} . $outfile_suffix;
$outfile_path_prefix . $UNDERSCORE . q{decompose_svdbmerge} . $outfile_suffix;

svdb_merge(
{
filehandle => $filehandle,
infile_paths_ref => \@vt_outfile_paths,
infile_paths_ref => \@decompose_outfile_paths,
notag => 1,
stdoutfile_path => $svdb_outfile_path,
}
Expand All @@ -357,7 +376,7 @@ sub analysis_expansionhunter {
say {$filehandle} q{## Stranger annotation};

my $stranger_outfile_path =
$outfile_path_prefix . $UNDERSCORE . q{vt_svdbmerge_ann} . $outfile_suffix;
$outfile_path_prefix . $UNDERSCORE . q{decompose_svdbmerge_ann} . $outfile_suffix;
stranger(
{
filehandle => $filehandle,
Expand Down
26 changes: 15 additions & 11 deletions t/bcftools_norm.t
Expand Up @@ -80,17 +80,17 @@ my %base_argument = (
## Can be duplicated with %base_argument and/or %specific_argument
## to enable testing of each individual argument
my %required_argument = (
outfile_path => {
input => q{outfile.txt},
expected_output => q{--output outfile.txt},
},
multiallelic => {
input => q{+},
expected_output => q{--multiallelics +both},
},
reference_path => {
input => q{path_to_fasta_ref},
expected_output => q{--fasta-ref path_to_fasta_ref},
outfile_path => {
input => q{outfile.txt},
expected_output => q{--output outfile.txt},
},
remove_duplicates => {
input => q{1},
expected_output => q{--rm-dup none},
},
);

Expand All @@ -99,10 +99,6 @@ my %specific_argument = (
input => q{infile.test},
expected_output => q{infile.test},
},
multiallelic => {
input => q{+},
expected_output => q{--multiallelics +both},
},
multiallelic_type => {
input => q{snps},
expected_output => q{--multiallelics +snps},
Expand All @@ -111,6 +107,14 @@ my %specific_argument = (
input => q{v},
expected_output => q{--output-type v},
},
reference_path => {
input => q{path_to_fasta_ref},
expected_output => q{--fasta-ref path_to_fasta_ref},
},
remove_duplicates_type => {
input => q{all},
expected_output => q{--rm-dup all},
},
);

## Coderef - enables generalized use of generate call
Expand Down

0 comments on commit 4daa67c

Please sign in to comment.