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

View of /FigKernelScripts/pop_vec.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Sun Feb 24 15:21:29 2013 UTC (6 years, 8 months ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2014_0912, rast_rel_2014_0729, HEAD
Changes since 1.1: +1 -1 lines
compute correspondences for a pan genome

# DESCRIPTION OF check_consistency_of_sample.pl
# 
# You can use
# 
# 	perl pop_vec.pl < Sample > population.estimate
# 
# Sample can be a file in the 5-column format, or it can be a file
# of genus-species (in a 1-column format)

use Carp;
use Data::Dumper;
use strict;

my($sample);
my $usage = "usage: pop_vec [-k Column] <  sample";

my $N = 5;

while ( @ARGV && $ARGV[0] =~ s/^-// )
{
    $_ = shift;
    if ( s/^k// ) { $N    = $_ || shift; next }
    else
    {
        print STDERR "Bad flag '$_'\n", $usage;
        exit;
    }
}

my %gs;
while (defined($_ = <STDIN>))
{
    chomp; 
    my @flds = split(/\t/,$_);
    if ((@flds == 1) && $flds[0])
    {
	$gs{$flds[0]}++;
    }
    elsif (($N <= @flds) && $flds[$N-1])
    {
	$gs{$flds[$N-1]}++;
    }
    elsif ($flds[$N-1])
    {
	print STDERR "Invalid input: $_\n";
    }
}

foreach my $gsN (sort { $gs{$b} <=> $gs{$a} } keys(%gs))
{
    print join("\t",($gs{$gsN},$gsN)),"\n";
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3