App-Anchr
view release on metacpan or search on metacpan
lib/App/Anchr/Command/orient.pm view on Meta::CPAN
package App::Anchr::Command::orient;
use strict;
use warnings;
use autodie;
use App::Anchr -command;
use App::Anchr::Common;
use constant abstract => "orient overlapped sequences to the same strand";
sub opt_spec {
return (
[ "outfile|o=s", "output filename, [stdout] for screen", ],
[ "restrict|r=s", "limit to known pairs", ],
[ "len|l=i", "minimal length of overlaps", { default => 1000 }, ],
[ "idt|i=f", "minimal identity of overlaps", { default => 0.85 }, ],
[ "parallel|p=i", "number of threads", { default => 4 }, ],
[ "verbose|v", "verbose mode", ],
{ show_defaults => 1, }
);
}
sub usage_desc {
return "anchr orient [options] <infiles>";
}
sub description {
my $desc;
$desc .= ucfirst(abstract) . ".\n";
$desc .= "\tThis command is for small files.\n";
$desc .= "\tAll operations are running in a tempdir and no intermediate files are kept.\n";
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.");
}
}
if ( exists $opt->{restrict} ) {
if ( !Path::Tiny::path( $opt->{restrict} )->is_file ) {
$self->usage_error("The restrict file [$opt->{restrict}] doesn't exist.\n");
}
}
if ( !exists $opt->{outfile} ) {
$opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".rc.fasta";
}
}
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;
}
if ( $opt->{restrict} ) {
$opt->{restrict} = Path::Tiny::path( $opt->{restrict} )->absolute->stringify;
}
( run in 0.651 second using v1.01-cache-2.11-cpan-39bf76dae61 )