2016-05-13 02:26:52 +00:00
|
|
|
module RNATranscription exposing (toRNA)
|
2016-03-11 23:44:46 +00:00
|
|
|
|
|
|
|
import String
|
|
|
|
|
|
|
|
|
|
|
|
toRNA : String -> Result Char String
|
|
|
|
toRNA dna =
|
2016-06-19 21:46:13 +00:00
|
|
|
dna
|
|
|
|
|> String.toList
|
|
|
|
|> List.map toRNANucleotide
|
|
|
|
|> resultExtraCombine
|
|
|
|
|> Result.map (List.map String.fromChar)
|
|
|
|
|> Result.map (String.join "")
|
2016-03-11 23:44:46 +00:00
|
|
|
|
|
|
|
|
2016-03-19 18:43:27 +00:00
|
|
|
|
2016-03-11 23:44:46 +00:00
|
|
|
-- Copied from elm-result-extra
|
2016-03-19 18:43:27 +00:00
|
|
|
|
|
|
|
|
2016-03-11 23:44:46 +00:00
|
|
|
resultExtraCombine : List (Result x a) -> Result x (List a)
|
2016-03-19 18:43:27 +00:00
|
|
|
resultExtraCombine =
|
2016-06-19 21:46:13 +00:00
|
|
|
List.foldr (Result.map2 (::)) (Ok [])
|
2016-03-11 23:44:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
toRNANucleotide : Char -> Result Char Char
|
|
|
|
toRNANucleotide nuc =
|
2016-06-19 21:46:13 +00:00
|
|
|
case nuc of
|
|
|
|
'C' ->
|
|
|
|
Ok 'G'
|
2016-03-19 18:43:27 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
'G' ->
|
|
|
|
Ok 'C'
|
2016-03-19 18:43:27 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
'A' ->
|
|
|
|
Ok 'U'
|
2016-03-19 18:43:27 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
'T' ->
|
|
|
|
Ok 'A'
|
2016-03-19 18:43:27 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
_ ->
|
|
|
|
Err nuc
|