2016-05-13 02:26:52 +00:00
|
|
|
module NucleotideCount exposing (..)
|
2016-03-17 01:36:38 +00:00
|
|
|
|
|
|
|
import String
|
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2016-04-10 02:48:05 +00:00
|
|
|
version : Int
|
2016-03-26 18:34:31 +00:00
|
|
|
version =
|
2016-06-19 21:46:13 +00:00
|
|
|
2
|
2016-03-26 18:34:31 +00:00
|
|
|
|
|
|
|
|
2016-04-10 02:48:05 +00:00
|
|
|
type alias NucleotideCounts =
|
2016-06-19 21:46:13 +00:00
|
|
|
{ a : Int
|
|
|
|
, t : Int
|
|
|
|
, c : Int
|
|
|
|
, g : Int
|
|
|
|
}
|
2016-04-10 02:48:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
init : NucleotideCounts
|
|
|
|
init =
|
2016-06-19 21:46:13 +00:00
|
|
|
{ a = 0
|
|
|
|
, t = 0
|
|
|
|
, c = 0
|
|
|
|
, g = 0
|
|
|
|
}
|
2016-04-10 02:48:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
update : Char -> NucleotideCounts -> NucleotideCounts
|
|
|
|
update char counts =
|
2016-06-19 21:46:13 +00:00
|
|
|
case char of
|
|
|
|
'A' ->
|
|
|
|
{ counts | a = counts.a + 1 }
|
2016-04-10 02:48:05 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
'T' ->
|
|
|
|
{ counts | t = counts.t + 1 }
|
2016-04-10 02:48:05 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
'C' ->
|
|
|
|
{ counts | c = counts.c + 1 }
|
2016-04-10 02:48:05 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
'G' ->
|
|
|
|
{ counts | g = counts.g + 1 }
|
2016-04-10 02:48:05 +00:00
|
|
|
|
2016-06-19 21:46:13 +00:00
|
|
|
_ ->
|
|
|
|
counts
|
2016-04-10 02:48:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
nucleotideCounts : String -> NucleotideCounts
|
2016-03-17 01:38:51 +00:00
|
|
|
nucleotideCounts sequence =
|
2016-06-19 21:46:13 +00:00
|
|
|
String.foldl update init sequence
|