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

my($gi, $gb, $db);
while(<>) {

    if( /^>gi\|(\w+)\|gb\|(\w+)\|/ ) {
	$gi = $1;
	$gb = $2;
        $db->{$gi}->{'gb'} = $gb;
	next;
    }
    s/\n//;
    $db->{$gi}->{'seq'} .= $_;
}

foreach my $gi (keys %{$db}) {
    
    my $len = length($db->{$gi}->{'seq'});
    $db->{$gi}->{'stat'}->{'len'} = $len;
    print "gi = $gi : Length = $len\n";

    foreach my $nuc ('A','C','G','T') {
	my $cnt = 0;
	while( $db->{$gi}->{'seq'} =~ /$nuc/g ) {$cnt++;}
	push(@{ $db->{$gi}->{'stat'}->{'nucs'} }, $cnt);
    }
}
print "\n";

foreach my $gi (keys %{$db}) {
    
    print "gi = $gi\n\t";
    foreach my $cnt (@{ $db->{$gi}->{'stat'}->{'nucs'} }) {
	printf "%-5d ", $cnt;
    }
    print "\n";

}
