#!/usr/bin/perl -w
use strict;

my $familycount = @ARGV -1;
my $family = $ARGV[$familycount];
chomp($family);
my %orgas = ();

my $count = 0;
for(;$count < $familycount;$count++)
{
    open(F,$ARGV[$count].".blastout.cluster");
    my $line;
    while($line=<F>)
    {
	my $orga = `echo '$line' | gawk '{print \$1;}'`;
	$orga = (split(/-/,$orga))[0];
	chomp($orga);
	if(!exists($orgas{$orga}))
	{
	    $orgas{$orga}="";
	}
	$orgas{$orga} = $orgas{$orga}.$line;
    }

    close(F);
}




open(OO,">",$family.".cluster.koords");

for my $k (keys %orgas)
{
    open(O,">",$family.".cluster.koords-".$k);
   
    print O $orgas{$k}."\n";
    print OO $orgas{$k}."\n";
    
    close(O);

     `./clusterpix2.pl $family.cluster.koords-$k -ps $family.cluster.koords-$k.ps`;
}


close(OO);


