script/inst-split-seqs.pl untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 49 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 # PODNAME: inst-split-seqs.pl
3 # ABSTRACT: Split sequences of FASTA files into shorter sequences (optimized)
4 # CONTRIBUTOR: Valerian LUPO <valerian.lupo@uliege.be>
5  
6 use Modern::Perl '2011';
7 use autodie;
8  
9 use Getopt::Euclid qw(:vars);
10 use Smart::Comments '###';
11  
12 use Bio::MUST::Core;
13 use Bio::MUST::Core::Utils qw(secure_outfile);
14 use aliased 'Bio::MUST::Core::Ali';
15 use aliased 'Bio::MUST::Core::Seq';
16  
17  
18 my $split = sub {
19 my $seq = shift;
20  
21 my $base_id = ( split /\s+/xms, $seq->full_id )[0];
22 my $max_pos = $seq->seq_len - $ARGV_chunk;
23  
24 my $n = 0;
25 my $out_str;
26 for (my $pos = 0; $pos <= $max_pos; $pos += $ARGV_step, $n++) { ## no critic (ProhibitCommaSeparatedStatements)
27 $out_str .= ">$base_id.$n\n" . (
28 Seq->new( seq_id => "seq$n", seq => $seq->edit_seq($pos,
29 $pos + $ARGV_chunk <= $max_pos ? $ARGV_chunk : 2 * $ARGV_chunk) )
30 )->wrapped_str;
31 }
32  
33 return $out_str;
34 };
35  
36 for my $infile (@ARGV_infiles) {
37 my $outfile = secure_outfile($infile, $ARGV_out_suffix);
38  
39 ### Processing: $infile
40 Ali->instant_store(
41 $outfile, { infile => $infile, coderef => $split }
42 );
43 }
44  
45 __END__