#
# This program takes the formated sequence data and returns the consensus portion.
#

open(DATA, "site_seqs2.dat");

print("AT.GTCCGGAC.AT\n");

while($lengths = <DATA>)
{
    $lengths =~ /(\d*) (\d*)/;
    $insert = $1;
    $length = $2;
    $sequence = <DATA>;
    $sequence =~tr/a-z/A-Z/;

    if($insert < 4 || $length - $insert < 10 || $sequence =~ /N/)
    {
	next;
    }
    else
    {
	$consensus = substr($sequence, $insert-4, 14);
    }

    print($consensus . "\n");

    $count1{substr($consensus, 0, 1)}++;
    $count2{substr($consensus, 1, 1)}++;
    $count3{substr($consensus, 2, 1)}++;
    $count4{substr($consensus, 3, 1)}++;
    $count5{substr($consensus, 4, 1)}++;
    $count6{substr($consensus, 5, 1)}++;
    $count7{substr($consensus, 6, 1)}++;
    $count8{substr($consensus, 7, 1)}++;
    $count9{substr($consensus, 8, 1)}++;
    $count10{substr($consensus, 9, 1)}++;
    $count11{substr($consensus, 10, 1)}++;
    $count12{substr($consensus, 11, 1)}++;
    $count13{substr($consensus, 12, 1)}++;
    $count14{substr($consensus, 13, 1)}++;
}

foreach(("G","C","A","T"))
{
    print($count1{$_} . " ");
    print($count2{$_} . " ");
    print($count3{$_} . " ");
    print($count4{$_} . " ");
    print($count5{$_} . " ");
    print($count6{$_} . " ");
    print($count7{$_} . " ");
    print($count8{$_} . " ");
    print($count9{$_} . " ");
    print($count10{$_} . " ");
    print($count11{$_} . " ");
    print($count12{$_} . " ");
    print($count13{$_} . " ");
    print($count14{$_} . " ");
    print("\n");
}
