Bio-Pipeline-Comparison
view release on metacpan or search on metacpan
lib/Bio/Pipeline/Comparison/Report/ParseVCFCompare.pm view on Meta::CPAN
package Bio::Pipeline::Comparison::Report::ParseVCFCompare;
# ABSTRACT: Take in the output of VCF compare and return details about intersection of variants.
use Moose;
use Try::Tiny;
use Bio::Pipeline::Comparison::Types;
use Bio::Pipeline::Comparison::Exceptions;
has 'known_variant_filename' => ( is => 'rw', isa => 'Str', required => 1 );
has 'observed_variant_filename' => ( is => 'rw', isa => 'Str', required => 1 );
has 'vcf_compare_exec' => ( is => 'ro', isa => 'Bio::Pipeline::Comparison::Executable', default => 'vcf-compare' );
has '_venn_diagram_regex' => ( is => 'ro', isa => 'Str', default => '^VN\t(\d+)\t([^\s]+)\s\(([\d\.]+)%\)(\t([^\s]+)\s\(([\d\.]+)%\))?$' );
has '_vcf_compare_fh' => ( is => 'ro', lazy => 1, builder => '_build__vcf_compare_fh' );
has '_raw_venn_diagram_results' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__raw_venn_diagram_results' );
sub number_of_false_positives
{
my ($self) = @_;
if(@{$self->_raw_venn_diagram_results} == 1)
{
return 0;
}
return $self->_number_of_uniques_for_filename($self->observed_variant_filename);
}
sub number_of_false_negatives
{
my ($self) = @_;
if(@{$self->_raw_venn_diagram_results} == 1)
{
return 0;
}
return $self->_number_of_uniques_for_filename($self->known_variant_filename);
}
sub number_of_known_variants
{
my ($self) = @_;
$self->_number_of_variants($self->known_variant_filename);
}
sub number_of_observed_variants
{
my ($self) = @_;
$self->_number_of_variants($self->observed_variant_filename);
}
sub _number_of_variants
{
my ($self,$filename) = @_;
my $number_of_variants = 0;
for my $row_results (@{$self->_raw_venn_diagram_results})
{
my $number_of_files_with_overlap = @{$row_results->{files_to_percentage}};
if($number_of_files_with_overlap > 0)
{
for(my $i = 0; $i < $number_of_files_with_overlap; $i++ )
{
if(defined($row_results->{files_to_percentage}->[$1]->{file_name})
( run in 2.081 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )