-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrph.hs
22 lines (18 loc) · 896 Bytes
/
grph.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- This program is free software. It comes without any warranty, to
-- the extent permitted by applicable law. You can redistribute it
-- and/or modify it under the terms of the Do What The Fuck You Want
-- To Public License, Version 2, as published by Sam Hocevar. See
-- http://sam.zoy.org/wtfpl/COPYING for more details.
import Rosalind
import Control.Applicative (liftA2)
import Data.List (isSuffixOf)
overlap :: String -> String -> Bool
overlap s1 s2 = (take 3 s2) `isSuffixOf` s1
overlapGraph :: [(String, String)] -> [(String, String)]
overlapGraph fasta = map (\((x, _), (y, _)) -> (x, y)) pairs'
where pairs' = filter (\(x, y) -> snd x `overlap` snd y) pairs
pairs = filter (\(x, y) -> x /= y) $ liftA2 (,) fasta fasta
main = do
contents <- readFile "grph.txt"
let fasta = parse contents
mapM_ putStrLn . map (\(x, y) -> x ++ " " ++ y) $ overlapGraph fasta