ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/ntstat
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (8 years, 1 month ago) by gpertea
File size: 1258 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3 use Getopt::Std;
4 my $usage = q/Usage:
5 ntstat [-a][-q][-t] input_fasta_files..
6
7 -a if all input should be treated as a single fasta sequence
8 (so only the final overall summary is shown)
9 -q omit table header in the output
10 -t omit the summary line for multiple input files
11
12 /;
13 getopts('qat:f:') || die($usage."\n");
14
15 my ($allinone, $nototal) =
16 ($Getopt::Std::opt_a, $Getopt::Std::opt_t);
17 $nototal=0 if $allinone;
18 print join("\t",'#/seqid ','nt ', 'bad ', '%bad')."\n"
19 unless ($Getopt::Std::opt_q);
20 my ($seqcount, $ntcount, $xcount);
21 {
22 local $/="\n>";
23 my $rlinefunc;
24 while (<>) {
25 s/^>//;
26 chomp;
27 my ($seqname, $ann, $seq)=(m/^(\S+)[ \t\x01]*(.*?)\n(.+)/s);
28 $seq =~ tr/\t \n\r//d;
29 my $seqlen=length($seq);
30 my $seqbad=($seq=~tr/ACGT//c);
31 $seqcount++;
32 $ntcount+=$seqlen;
33 $xcount+=$seqbad;
34 unless ($allinone) {
35 print join("\t",$seqname, $seqlen, $seqbad,
36 sprintf("%.2f",($seqbad*100.00)/$seqlen) )."\n";
37 }
38 }#while fasta records
39 }
40
41 unless ($nototal || $seqcount<2) {
42 # print '#','-'x 10,' Total: ','-'x 10, "\n";
43 print join("\t",'Total '.$seqcount.' seqs', $ntcount, $xcount,
44 sprintf("%.2f",($xcount*100.00)/$ntcount) )."\n";
45 }

Properties

Name Value
svn:executable *