-
-
Save pditommaso/6ab5c9562cb161cd7cb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Environment | |
import Data.List.Split | |
import Data.List | |
import qualified Data.Map.Strict as Map | |
main = do | |
[f] <- getArgs | |
contents <- readFile f | |
putStr . unlines . map unwords . map (kmers 6) . getSequences $ contents | |
getSequences :: String -> [String] | |
getSequences = map (\x -> x !! 1) . splitEvery 4 . lines | |
kmers :: Int -> String -> [String] | |
kmers k seq = (unfoldr f seq) ++ (unfoldr f $ map revcomp $ seq) | |
where | |
f xs | |
| length xs >= k = Just ((take k xs), (tail xs)) | |
| otherwise = Nothing | |
revcomp 'A' = 'T' | |
revcomp 'T' = 'A' | |
revcomp 'G' = 'C' | |
revcomp 'C' = 'G' | |
revcomp _ = 'N' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment