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.119 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.118 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.117 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.116 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.115 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.114 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.113 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.111 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.110 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.109 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.108 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.107 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.106 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.105 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.104 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.103 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.102 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.101 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.100 tracks/nim/exercises/nucleotide-count/example.nim
trackler-2.2.1.99 tracks/nim/exercises/nucleotide-count/example.nim