Bio-Pipeline-Comparison

 view release on metacpan or  search on metacpan

lib/Bio/Pipeline/Comparison/Report/InputParameters.pm  view on Meta::CPAN

package Bio::Pipeline::Comparison::Report::InputParameters;

# ABSTRACT: Take in a set of input parameters for the evalute pipeline functionality, validate them, then manipulate them into a usable set.


use Moose;
use Cwd;
use File::Temp;
use File::Copy;
use File::Basename;
use Try::Tiny;
use Bio::SeqIO;
use Bio::Pipeline::Comparison::Types;
use Bio::Pipeline::Comparison::Exceptions;
use Vcf;

has 'known_variant_filenames'    => ( is => 'rw', isa => 'ArrayRef', required => 1 );
has 'observed_variant_filenames' => ( is => 'rw', isa => 'ArrayRef', required => 1 );

has 'bgzip_exec' => ( is => 'ro', isa => 'Bio::Pipeline::Comparison::Executable', default => 'bgzip' );
has 'tabix_exec' => ( is => 'ro', isa => 'Bio::Pipeline::Comparison::Executable', default => 'tabix' );

has 'known_to_observed_mappings' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build_known_to_observed_mappings' );

has '_temp_directory_obj' => ( is => 'ro', isa => 'File::Temp::Dir', lazy     => 1, builder => '_build__temp_directory_obj' );
has '_temp_directory'     => ( is => 'ro', isa => 'Str', lazy     => 1, builder => '_build__temp_directory' );
has 'debug'               => ( is => 'ro', isa => 'Bool', default => 0);

sub _build__temp_directory_obj {
    my ($self) = @_;
    
    my $cleanup = 1;
    $cleanup = 0 if($self->debug == 1);
    File::Temp->newdir( CLEANUP => $cleanup , DIR => getcwd() );
}

sub _build__temp_directory {
    my ($self) = @_;
    $self->_temp_directory_obj->dirname();
}

sub _build_known_to_observed_mappings
{
  my ($self) = @_;
  $self->_validate_input_files();
  my @known_to_observed_mappings;
  
  if(@{$self->known_variant_filenames} == 1)
  {
    #1 to N, expand into pairs
    for my $known_filename (@{$self->known_variant_filenames})
    {
      for my $observed_filename (@{$self->observed_variant_filenames})
      {
        push(@known_to_observed_mappings, { known_filename => $known_filename, observed_filename => $observed_filename });
      }
    }
  }
  elsif(@{$self->known_variant_filenames} == @{$self->observed_variant_filenames})
  {
    # N to N, pairs
    for(my $i = 0; $i < @{$self->known_variant_filenames}; $i++)
    {
      push(@known_to_observed_mappings, { known_filename => $self->known_variant_filenames->[$i], observed_filename => $self->observed_variant_filenames->[$i] });
    }
  }
  return \@known_to_observed_mappings;
}

sub _validate_input_files
{



( run in 1.681 second using v1.01-cache-2.11-cpan-39bf76dae61 )