[Bio] / FigKernelScripts / pop_vec.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/pop_vec.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : overbeek 1.1 # DESCRIPTION OF check_consistency_of_sample.pl
2 :     #
3 :     # You can use
4 :     #
5 :     # perl pop_vec.pl < Sample > population.estimate
6 :     #
7 :     # Sample can be a file in the 5-column format, or it can be a file
8 :     # of genus-species (in a 1-column format)
9 :    
10 :     use Carp;
11 :     use Data::Dumper;
12 :     use strict;
13 :    
14 :     my($sample);
15 :     my $usage = "usage: perl [-k Column] pop_vec.pl < sample";
16 :    
17 :     my $N = 5;
18 :    
19 :     while ( @ARGV && $ARGV[0] =~ s/^-// )
20 :     {
21 :     $_ = shift;
22 :     if ( s/^k// ) { $N = $_ || shift; next }
23 :     else
24 :     {
25 :     print STDERR "Bad flag '$_'\n", $usage;
26 :     exit;
27 :     }
28 :     }
29 :    
30 :     my %gs;
31 :     while (defined($_ = <STDIN>))
32 :     {
33 :     chomp;
34 :     my @flds = split(/\t/,$_);
35 :     if ((@flds == 1) && $flds[0])
36 :     {
37 :     $gs{$flds[0]}++;
38 :     }
39 :     elsif (($N <= @flds) && $flds[$N-1])
40 :     {
41 :     $gs{$flds[$N-1]}++;
42 :     }
43 :     elsif ($flds[$N-1])
44 :     {
45 :     print STDERR "Invalid input: $_\n";
46 :     }
47 :     }
48 :    
49 :     foreach my $gsN (sort { $gs{$b} <=> $gs{$a} } keys(%gs))
50 :     {
51 :     print join("\t",($gs{$gsN},$gsN)),"\n";
52 :     }
53 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3