Skip to content

Instantly share code, notes, and snippets.

@natdempk
Created November 1, 2019 00:04
Show Gist options
  • Save natdempk/be35e8199171f31b2b8af1940252db45 to your computer and use it in GitHub Desktop.
Save natdempk/be35e8199171f31b2b8af1940252db45 to your computer and use it in GitHub Desktop.
import sequtils
from strutils import join
proc toRna*(dna: string): string =
var chars = toSeq(dna).map do (c: char) -> char:
case c:
of 'A':
return 'U'
of 'T':
return 'A'
of 'C':
return 'G'
of 'G':
return 'C'
else:
raise newException(ValueError, "invalid DNA character detected")
result = chars.join();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment