App-Fasops
view release on metacpan or search on metacpan
lib/App/Fasops/Command/check.pm view on Meta::CPAN
package App::Fasops::Command::check;
use strict;
use warnings;
use autodie;
use App::Fasops -command;
use App::RL::Common;
use App::Fasops::Common;
sub abstract {
return 'check genome locations in (blocked) fasta headers';
}
sub opt_spec {
return (
[ "outfile|o=s", "Output filename. [stdout] for screen." ],
[ "name|n=s", "Which species to be checked, omit this will check all sequences" ],
{ show_defaults => 1, }
);
}
sub usage_desc {
return "fasops check [options] <infile> <genome.fa>";
}
sub description {
my $desc;
$desc .= ucfirst(abstract) . ".\n";
$desc .= <<'MARKDOWN';
* <infiles> are paths to axt files, .axt.gz is supported
* infile == stdin means reading from STDIN
* <genome.fa> is one multi fasta file contains genome sequences
MARKDOWN
return $desc;
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
if ( @{$args} != 2 ) {
my $message = "This command need two input files.\n\tIt found";
$message .= sprintf " [%s]", $_ for @{$args};
$message .= ".\n";
$self->usage_error($message);
}
for ( @{$args} ) {
next if lc $_ eq "stdin";
if ( !Path::Tiny::path($_)->is_file ) {
$self->usage_error("The input file [$_] doesn't exist.");
}
}
if ( !exists $opt->{outfile} ) {
$opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".check.txt";
}
# samtools should be in $PATH
if ( !IPC::Cmd::can_run("samtools") ) {
$self->usage_error("Can't find [samtools].");
}
}
sub execute {
my ( $self, $opt, $args ) = @_;
my $in_fh;
if ( lc $args->[0] eq "stdin" ) {
$in_fh = *STDIN{IO};
( run in 1.697 second using v1.01-cache-2.11-cpan-aadc1410aed )