Sha256: bc1b5928ed81d899b1b3caa6488216371b4252850e91ae0096b606e1d0d2bc25
Contents?: true
Size: 569 Bytes
Versions: 12
Compression:
Stored size: 569 Bytes
Contents
package dna import ( "errors" "strings" ) type Histogram map[byte]int type DNA string func (dna DNA) Count(nucleotide byte) (count int, err error) { validNucleotides := "ACGT" if !strings.Contains(validNucleotides, string(nucleotide)) { return 0, errors.New("dna: invalid nucleotide " + string(nucleotide)) } return strings.Count(string(dna), string(nucleotide)), nil } func (dna DNA) Counts() Histogram { a, _ := dna.Count('A') c, _ := dna.Count('C') t, _ := dna.Count('T') g, _ := dna.Count('G') return Histogram{'A': a, 'C': c, 'T': t, 'G': g} }
Version data entries
12 entries across 12 versions & 1 rubygems