App-Egaz

 view release on metacpan or  search on metacpan

lib/App/Egaz/Command/raxml.pm  view on Meta::CPAN

package App::Egaz::Command::raxml;
use strict;
use warnings;
use autodie;

use App::Egaz -command;
use App::Egaz::Common;

sub abstract {
    return 'raxml wrapper to construct phylogenetic trees';
}

sub opt_spec {
    return (
        [ "outfile|o=s",   "Output filename. [stdout] for screen", { default => "stdout" }, ],
        [ "outgroup=s",    "the name of outgroup if exists", ],
        [ "seed|s=i",      "specify a random number seed", ],
        [ "bootstrap|b=i", "the number of alternative runs",       { default => 100 }, ],
        [ "tmp=s",         "user defined tempdir", ],
        [ "parallel|p=i",  "number of threads",                    { default => 2 }, ],
        [ "verbose|v",     "verbose mode", ],
        { show_defaults => 1, }
    );
}

sub usage_desc {
    return "egaz raxml [options] <infile> [more infiles]";
}

sub description {
    my $desc;
    $desc .= ucfirst(abstract) . ".\n";
    $desc .= <<'MARKDOWN';

* <infile> should be a blocked fasta file (*.fas)
* use `fasops concat` to create a temp relaxed phylip file
* `raxmlHPC` or `raxmlHPC-*` should be in $PATH
* `raxml` is very sensitive to CPU resources. Any competitions on cores will dramatically slow down it.

MARKDOWN

    return $desc;
}

sub validate_args {
    my ( $self, $opt, $args ) = @_;

    if ( @{$args} < 1 ) {
        my $message = "This command need one or more input files.\n\tIt found";
        $message .= sprintf " [%s]", $_ for @{$args};
        $message .= ".\n";
        $self->usage_error($message);
    }
    for ( @{$args} ) {
        if ( !Path::Tiny::path($_)->is_file ) {
            $self->usage_error("The input file [$_] doesn't exist.");
        }
    }

}

sub execute {
    my ( $self, $opt, $args ) = @_;

    # absolute pathes as we will chdir to tempdir later
    my @infiles;
    for my $infile ( @{$args} ) {
        push @infiles, Path::Tiny::path($infile)->absolute->stringify;
    }

    if ( lc $opt->{outfile} ne "stdout" ) {
        $opt->{outfile} = Path::Tiny::path( $opt->{outfile} )->absolute->stringify;
    }

    # record cwd, we'll return there
    my $cwd = Path::Tiny->cwd;
    my $tempdir;
    if ( $opt->{tmp} ) {
        $tempdir = Path::Tiny->tempdir(
            TEMPLATE => "raxml_XXXXXXXX",



( run in 1.344 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )