Skip to content

Instantly share code, notes, and snippets.

@amonshiz
Created January 2, 2015 16:57
Show Gist options
  • Save amonshiz/0b5bbdbef61bc9072d73 to your computer and use it in GitHub Desktop.
Save amonshiz/0b5bbdbef61bc9072d73 to your computer and use it in GitHub Desktop.
module Bioinformatics.DNANucleotide (
DNANucleotide (..),
charToDNANucleotide
) 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
module Bioinformatics.RNANucleotide (
RNANucleotide (..),
charToRNANucleotide
) where
import Data.Char
import Data.List
data RNANucleotide = A | C | G | U deriving (Show, Eq, Ord, Read)
charToRNANucleotide :: Char -> RNANucleotide
charToRNANucleotide c = read [toUpper c] :: RNANucleotide
import Bioinformatics.DNANucleotide as D
import Bioinformatics.RNANucleotide as R
dnaToRNA :: D.DNANucleotide -> R.RNANucleotide
dnaToRNA d
| d == D.A = R.A
| d == D.C = R.C
| d == D.G = R.G
| otherwise = R.U
mainDNAToRNA = do
dna <- getLine
putStrLn $ concat . map show . map dnaToRNA $ map D.charToDNANucleotide dna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment