Sha256: 5fcde682d510039253eb87c76f37f2a12287736b3667c102e1a9fef505f4e260

Contents?: true

Size: 440 Bytes

Versions: 376

Compression:

Stored size: 440 Bytes

Contents

import sequtils
import tables

proc count*(nt: char, dna: string): int =
  let nts = toSeq(dna.items)
  var nt_count = 0

  for n in nts:
    if n == nt:
      nt_count += 1

  nt_count

proc count_dna*(dna: string): CountTable[char] =
  var counts = initCountTable[char]()

  for nt in toSeq(dna.items):
    if nt in ['A', 'C', 'G', 'T']:
      counts.inc(nt)
    else:
      raise newException(ValueError, "Invalid nucleotide")

  counts

Version data entries

376 entries across 376 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.158 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.157 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.156 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.155 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.154 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.153 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.152 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.151 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.150 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.149 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.148 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.147 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.146 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.145 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.144 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.143 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.142 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.141 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.140 tracks/nim/exercises/nucleotide-count/example.nim