blib/script/bg_fastat.pl untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 18 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 85 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 # created on 2014-08-10
3  
4 use warnings;
5 use strict;
6 use 5.010;
7 use Bio::Gonzales::Stat::Util qw/hist_text nstat/;
8  
9 use Pod::Usage;
10 use Getopt::Long;
11 use Number::Format;
12  
13 use Bio::Gonzales::Seq::IO qw/faiterate/;
14  
15 my %opt = ();
16 GetOptions( \%opt, 'n=f','min_len=i', 'log10|l', 'breaks|b=i', 'help|h' ) or pod2usage(2);
17  
18 pod2usage( -exitval => 0, -verbose => 2 ) if ( $opt{help} );
19  
20 my $nfmt_nice = new Number::Format(
21 -thousands_sep => ',',
22 -decimal_point => '.',
23 -decimal_fill => 0
24 );
25  
26 my @files = @ARGV;
27  
28 if ( @files == 1 && $files[0] eq '-' ) {
29 @files = ( \*STDIN );
30 }
31  
32 for my $file (@files) {
33 my @values;
34 my @lengths;
35 if ( $file && -f $file ) {
36 say STDERR "FILE $file";
37 }
38  
39 my $seqin = faiterate($file);
40 while ( my $s = $seqin->() ) {
41 push @values, $s->length if(!$opt{min_len} || ($opt{min_len} && $s->length>= $opt{min_len} ));
42 }
43 say "only sequences >= $opt{min_len} taken into account" if($opt{min_len});
44 if ( $opt{n} && $opt{n} > 0 ) {
45 my $frac = $opt{n};
46 my ( $n, $count, $t ) = nstat( $frac , \@values);
47  
48 say "total sequence length: " . $nfmt_nice->format_number($t);
49  
50 say "N" . $nfmt_nice->format_number( $frac * 100, 3 ) . ": " . $nfmt_nice->format_number($n);
51 }
52 print hist_text( \@values, { skip_empty => 1, breaks => $opt{breaks}, 'log10' => $opt{'log10'} } );
53 }
54  
55 =head1 NAME
56  
57 bg_fastat.pl - fasta file statistics
58  
59 =head1 SYNOPSIS
60  
61 bg_fastat.pl [options] [<files>|-]
62  
63 Options:
64  
65 --help Detailed help message
66 --version Show script version
67 --n <float> Calculate N-values 0.9 = N90, 0.5 = N50.
68 --min_len <int> Set minimum sequence length
69 (Everything lower will not be considered)
70 -l, --log10 Apply log scale
71 -b, --breaks <int> Set the number of breaks
72  
73  
74 =head1 EXAMPLES
75  
76  
77  
78 =head1 SEE ALSO
79  
80 =head1 AUTHOR
81  
82 jw bargsten, C<< <jw at bargsten dot org> >>
83  
84 =cut