Bio-MUST-Drivers

 view release on metacpan or  search on metacpan

lib/Bio/MUST/Drivers/Mafft.pm  view on Meta::CPAN

package Bio::MUST::Drivers::Mafft;
# ABSTRACT: Bio::MUST driver for running the MAFFT program
# CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
$Bio::MUST::Drivers::Mafft::VERSION = '0.252830';
use Moose;
use namespace::autoclean;

use autodie;
use feature qw(say);

use Smart::Comments '###';

use Carp;
use IPC::System::Simple qw(system);
use Module::Runtime qw(use_module);
use Path::Class qw(file);

use Bio::MUST::Core;
extends 'Bio::FastParsers::Base';

use Bio::MUST::Drivers::Utils qw(stringify_args);
use aliased 'Bio::MUST::Core::Ali';


sub align_all {                             ## no critic (RequireArgUnpacking)
    return shift->_mafft('align_all', @_);
}

sub profile2profile {                       ## no critic (RequireArgUnpacking)
    my $out = shift->_mafft('profile2profile' , @_);
    return $out if $out;

    carp '[BMD] Warning: cannot align profiles; returning nothing!';
    return;
}

sub seqs2profile {
    my $self    = shift;
    my $profile = shift;
    my $args    = shift // {};

    # setup specialized options
    my $mode = 'seqs2profile';
    for my $suffix ( qw(long fragments) ) {
        my $opt = '--' . $suffix;
        if (exists $args->{$opt}) {
            $mode =~ s/seqs/$suffix/xms;
            delete $args->{$opt};
        }
    }
    #### $mode

    return $self->_mafft($mode, $profile, $args);
}

sub _mafft {
    my $self    = shift;
    my $mode    = shift;
    my $profile;            # conditional declaring is bad...
       $profile = shift unless $mode eq 'align_all';
    my $args    = shift // {};

    #### in _mafft

    # provision executable
    my $app = use_module('Bio::MUST::Provision::Mafft')->new;



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