Skip to content

Instantly share code, notes, and snippets.

@aivuk
Last active August 29, 2015 14:04
Show Gist options
  • Save aivuk/fa82b71f2804fe1a8bf6 to your computer and use it in GitHub Desktop.
Save aivuk/fa82b71f2804fe1a8bf6 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as TI
import System.IO
main = do
file <- TI.readFile "input.map"
output <- openFile "output.map" WriteMode
let fileColumns = map (T.split (== '\t')) $ T.lines file
extractAndSave = mapM_ ((TI.hPutStrLn output).getHla) $ filter testConditions fileColumns
testConditions (x1:x2:x3:x4:x5:_) = and [cond1, cond2, cond3]
where cond1 = not $ T.isInfixOf "HWI" x1
cond2 = '0' /= (T.head x4)
cond3 = T.isPrefixOf "HLA" x5
getHla (_:_:_:x3:x4:_) = T.unwords.(is:) $ take i $ T.split (== ',') x4
where i = read $ T.unpack is
is = head $ T.split (== ':') x3
extractAndSave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment