[Biojava-l] GCG checkSums

Matthew Pocock matthew_pocock@yahoo.co.uk
Thu, 31 Jan 2002 12:18:02 +0000


Hi Russell,

Is this code in BioJava? I sugest re-writing this to move 
seq.toUpperCase() out of the loop over i as this is potentialy 
expensive. Something like:

 >       int GCG_Checksum(String seq){
 >         int count = 0,
 >             check = 0;
           String seq_uc = seq.toUpperCase();
 >         for(int i = 0; i < seq.length(); i++) {
 >          count++;
 >          //check += count * seq.toUpperCase().charAt(i);
            check += count * seq_uc.charAt(i);
 >             if(count == 57)count = 0;
 >          }
 >           return  check %= 10000;
 >       }


Russell Smithies wrote:
> Don't panic, I found it :-)
> 
> Here's my version:
> -------------------------------------------------
>       int GCG_Checksum(String seq){
>         int count = 0,
>             check = 0;
>         for(int i = 0; i < seq.length(); i++) {
>          count++;
>          check += count * seq.toUpperCase().charAt(i);
>             if(count == 57)count = 0;
>          }
>           return  check %= 10000;
>       }
> 
> ---------------------------------------------------
> 
> Russell Smithies
> University of Otago
> Dunedin
> New Zealand
> 
> 
> _________________________________________________________________
> Join the world's largest e-mail service with MSN Hotmail. 
> http://www.hotmail.com
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
> 




_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com