[Biojava-l] GCG check sums?

Russell Smithies russell.smithies@xtra.co.nz
Tue, 29 Jan 2002 21:23:39 +1300


Are there methods to validate and calculate GCG check sums for rich sequence
files?
It's in Bio-Perl but haven't seen the Bio-Java version of it yet.
If not, can anyone tell me how its done?
My Perl isn't too hot but here's a script I found:
------------------------------------------
sub GCG_checksum {
    my ($self,$seqobj) = @_;
    my $index = 0;
    my $checksum = 0;
    my $char;

    my $seq = $seqobj->seq();
    $seq =~ tr/a-z/A-Z/;

    foreach $char ( split(/[\.\-]*/, $seq)) {
	$index++;
	$checksum += ($index * (unpack("c",$char) || 0) );
	if( $index ==  57 ) {
	    $index = 0;
	}
    }

    return ($checksum % 10000);
}
--------------------------------------------

thanx

Russell Smithies
University of Otago
Dunedin
New Zealand