Skip to content

Instantly share code, notes, and snippets.

@amonshiz
Created January 10, 2015 16:38
Show Gist options
  • Select an option

  • Save amonshiz/28f335f3d793ebb911c0 to your computer and use it in GitHub Desktop.

Select an option

Save amonshiz/28f335f3d793ebb911c0 to your computer and use it in GitHub Desktop.
import Bioinformatics.DNANucleotide as D
main = do
substrand <- getLine
putStrLn . concat . map show . reverse . map D.nucleotideComplement $ map D.charToDNANucleotide substrand
module Bioinformatics.DNANucleotide (
DNANucleotide (..),
charToDNANucleotide,
nucleotideComplement
) where
import Data.Char
import Data.List
data DNANucleotide = A | C | G | T deriving(Show, Eq, Ord, Read)
charToDNANucleotide :: Char -> DNANucleotide
charToDNANucleotide c = read [toUpper c] :: DNANucleotide
nucleotideComplement :: DNANucleotide -> DNANucleotide
nucleotideComplement A = T
nucleotideComplement T = A
nucleotideComplement C = G
nucleotideComplement G = C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment