Method: Bio::GCG::Seq.calc_checksum

Defined in:
lib/bio/appl/gcg/seq.rb

.calc_checksum(str) ⇒ Object

Calculates checksum from given string.



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/bio/appl/gcg/seq.rb', line 141

def self.calc_checksum(str)
  # Reference: Bio::SeqIO::gcg of BioPerl-1.2.3
  idx = 0
  sum = 0
  str.upcase.tr('^A-Z.~', '').each_byte do |c|
    idx += 1
    sum += idx * c
    idx = 0 if idx >= 57
  end
  (sum % 10000)
end