Bio-MUST-Core

 view release on metacpan or  search on metacpan

bin/inst-split-seqs.pl  view on Meta::CPAN

#!/usr/bin/env perl
# PODNAME: inst-split-seqs.pl
# ABSTRACT: Split sequences of FASTA files into shorter sequences (optimized)
# CONTRIBUTOR: Valerian LUPO <valerian.lupo@doct.uliege.be>

use Modern::Perl '2011';
use autodie;

use Getopt::Euclid qw(:vars);
use Smart::Comments '###';

use Bio::MUST::Core;
use Bio::MUST::Core::Utils qw(secure_outfile);
use aliased 'Bio::MUST::Core::Ali';
use aliased 'Bio::MUST::Core::Seq';


my $split = sub {
    my $seq = shift;

    my $base_id = ( split /\s+/xms, $seq->full_id )[0];
    my $max_pos = $seq->seq_len - $ARGV_chunk;

    my $n = 0;
    my $out_str;
    for (my $pos = 0; $pos <= $max_pos; $pos += $ARGV_step, $n++) {     ## no critic (ProhibitCommaSeparatedStatements)
        $out_str .= ">$base_id.$n\n" . (
            Seq->new( seq_id => "seq$n", seq => $seq->edit_seq($pos,
            $pos + $ARGV_chunk <= $max_pos ? $ARGV_chunk : 2 * $ARGV_chunk) )
        )->wrapped_str;
    }

    return $out_str;
};

for my $infile (@ARGV_infiles) {
    my $outfile = secure_outfile($infile, $ARGV_out_suffix);

    ### Processing: $infile
    Ali->instant_store(
        $outfile, { infile => $infile, coderef => $split }
    );
}

__END__

=pod

=head1 NAME

inst-split-seqs.pl - Split sequences of FASTA files into shorter sequences (optimized)

=head1 VERSION

version 0.240390

=head1 USAGE

   inst-split-seqs.pl <infiles> --out=<suffix> [optional arguments]

=head1 REQUIRED ARGUMENTS

=over

=item <infiles>

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.500 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )