Bio-Grep

 view release on metacpan or  search on metacpan

lib/Bio/Grep/Backend/Vmatch.pm  view on Meta::CPAN

            $query_desc = substr $query_desc, 0, $self->settings->showdesc;
            $query_desc =~ s/\s/_/gxms;
            $query_desc_lookup{$query_desc} = $query_seq;
        }
        $self->{_mapping} = \%query_desc_lookup;
    }
    return;
}

###########################################################################
# Usage      : _check_search_settings_vmatch()
# Purpose    : extends _check_search_settings() with some Vmatch specific
#              tests.
# Returns    : nothing
# Parameters : none
# Throws     : Bio::Root::BadParameter

sub _check_search_settings_vmatch {
    my ( $self, $query_file ) = @_;
    my $s = $self->settings;
    if ( ( $s->upstream > 0 || $s->downstream > 0 ) && $s->showdesc_isset ) {
        $self->throw(
            -class => 'Bio::Root::BadParameter',
            -text => q{You can't use showdesc() with upstream or downstream.},
        );
    }
    if ( $query_file && !$s->complete && !$s->query_length_isset ) {
        $self->throw(
            -class => 'Bio::Root::BadParameter',
            -text  => 'You have to specify complete or querylength. See '
                . 'the flags -complete and -l in the Vmatch documentation.',
        );
    }
    return 1;
}

sub get_databases {
    my $self = shift;
    return $self->_get_databases('.al1');
}

###########################################################################
# Usage      : generate_database()
# Purpose    : calling mkvtree to generate the suffix arrays
# Returns    : 1
# Parameters : hashref with mandatory argument 'file'. optional parameters
#              are format (not needed here), description, copy (instead of
#              symlink), datapath and the mkvtree parameters prefix_length
#              (-pl) and verbose (-v)
# Throws     : Bio::Root::BadParameter,
#              Bio::Root::SystemException

sub generate_database {
    my ( $self, @args ) = @_;
    my %args = $self->_prepare_generate_database(@args);

    if ( defined $args{skip} ) {
        return 0;
    }

    my $alphabet = $self->_guess_alphabet_of_file( $args{filename} );
    my $alphabet_specific_arguments = q{};

    my $verbose = q{};
    if ( defined $args{verbose} ) {
        $verbose = ' -v ';
    }

    my $pl = ' -pl ';
    if ( defined $args{prefix_length} ) {
        $pl .= $args{prefix_length} . q{ };
    }

    if ( $alphabet eq 'protein' ) {
        $alphabet_specific_arguments = ' -protein ';
    }
    elsif ( $alphabet eq 'dna' || $alphabet eq 'rna' ) {
        $alphabet_specific_arguments = ' -dna ';
    }
    else {
        $self->throw(
            -class => 'Bio::Root::BadParameter',
            -text  => 'Unsupported alphabet of file.',
            -value => $alphabet,
        );
    }
    my $command
        = $self->_cat_path_filename( $self->settings->execpath, 'mkvtree' )
        . ' -db '
        . $args{basefilename}
        . $alphabet_specific_arguments
        . $pl
        . ' -allout '
        . $verbose;

    if ( $ENV{BIOGREPDEBUG} ) {
        warn $command . "\n";
    }
    my $output_dir = $self->settings->datapath;
    system qq{ cd $output_dir ; exec $command };
    if ($CHILD_ERROR) {
        $self->throw(
            -class => 'Bio::Root::SystemException',
            -text  => 'mkvtree call failed. Cannot generate suffix array. '
                . "Command was:\n\t$command",
        );
    }
    return 1;
}

###########################################################################
# Usage      : _parse_next_res()
# Purpose    : Assumes that the output filehandle points to the beginning of
#              a hit. This method then parses this hit.
# Returns    : SearchResult object or 0 (end of file)
# Parameters : none

sub _parse_next_res {
    my $self                = shift;
    my @query_seqs          = $self->_query_seqs;
    my $s                   = $self->settings;



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