Sha256: 4a479b5a267acf01939f361c6cc83dec4b582682f08d0e9b70fcbe329a5938e6
Contents?: true
Size: 564 Bytes
Versions: 312
Compression:
Stored size: 564 Bytes
Contents
module DNA (nucleotideCounts) where import Data.Map.Strict (Map, fromDistinctAscList, fromListWith, findWithDefault) nucleotideCounts :: String -> Either String (Map Char Int) nucleotideCounts xs = fromDistinctAscList <$> mapM count' "ACGT" where count' x = (\c -> (x, c)) <$> occur' x occur' x = findWithDefault 0 x . countOccurrences <$> mapM valid xs countOccurrences = fromListWith (+) . flip zip (repeat 1) valid :: Char -> Either String Char valid x | x `elem` "ACGT" = Right x | otherwise = Left $ "invalid nucleotide " ++ show x
Version data entries
312 entries across 312 versions & 1 rubygems