BioHMM 1.0.0 → 1.0.1
raw patch · 4 files changed
+110/−4 lines, 4 files
Files
- BioHMM.cabal +4/−3
- README.md +1/−1
- changelog +2/−0
- src/Bio/HMMCompareResult.hs +103/−0
BioHMM.cabal view
@@ -1,5 +1,5 @@ name: BioHMM-version: 1.0.0+version: 1.0.1 synopsis: Libary containing parsing and visualisation functions and datastructures for Hidden Markov Models in HMMER3 format. -- description: license: GPL-3@@ -20,14 +20,15 @@ source-repository this type: git- location: https://github.com/eggzilla/HMM/tree/1.0.0- tag: 1.0.0+ location: https://github.com/eggzilla/HMM/tree/1.0.1+ tag: 1.0.1 library -- Modules exported by the library. exposed-modules: Bio.HMMData Bio.HMMParser Bio.HMMDraw+ Bio.HMMCompareResult -- compiler-options: ghc-options: -Wall -O2 -fno-warn-unused-do-bind
README.md view
@@ -1,4 +1,4 @@-HMM+BioHMM [](https://hackage.haskell.org/package/BioHMM) [](https://travis-ci.org/eggzilla/BioHMM) ==== Libary containing parsing and visualisation functions, as well as datastructures for Hidden Markov Models in HMMER3 format.
changelog view
@@ -1,3 +1,5 @@ -*-change-log-*-+1.0.1 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 22. December 2016+ * Bugfix - added Bio.HMMCompare to exported modules 1.0.0 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 22. December 2016 * Initial release
+ src/Bio/HMMCompareResult.hs view
@@ -0,0 +1,103 @@+-- | Parse HMMCompare output++module Bio.HMMCompareResult+ (+ HMMCompareResult,+ parseHMMCompareResult,+ readHMMCompareResult,+ model1Name,+ model2Name,+ linkscore1, + linkscore2,+ linksequence,+ model1matchednodes,+ model2matchednodes,+ getHMMCompareResults,+ getModelsNames,+ getModelNames+ ) where++import Text.ParserCombinators.Parsec +import Control.Monad++-- | Datastructure for result strings of comparisons between covariance models by HMMCompare+data HMMCompareResult = HMMCompareResult + { model1Name :: String,+ model2Name :: String,+ linkscore1 :: Double,+ linkscore2 :: Double,+ linksequence :: String,+ model1matchednodes :: [Int],+ model2matchednodes :: [Int]+ } deriving (Show)++-- | parse HMMCompareResult model from input string+parseHMMCompareResult :: [Char] -> Either ParseError [HMMCompareResult]+parseHMMCompareResult input = parse genParseHMMCompareResults "HMMCompareResult" input++-- | parse HMMCompareResult from input filePath +readHMMCompareResult :: String -> IO (Either ParseError [HMMCompareResult]) +readHMMCompareResult filePath = do + parsedFile <- parseFromFile genParseHMMCompareResults filePath+ return parsedFile++-- | Parse the input as HMMCompareResult datatype+genParseHMMCompareResults :: GenParser Char st [HMMCompareResult]+genParseHMMCompareResults = do+ hmmcs <- many1 (try genParseHMMCompareResult)+ eof+ return hmmcs++readDouble :: String -> Double+readDouble = read ++readInt :: String -> Int+readInt = read++-- | Parse a HMMCompare result string+genParseHMMCompareResult :: GenParser Char st HMMCompareResult+genParseHMMCompareResult = do+ name1 <- many1 (noneOf " ")+ _ <- many1 space+ name2 <- many1 (noneOf " ")+ _ <- many1 space+ score1 <- many1 (noneOf " ")+ _ <- many1 space+ score2 <- many1 (noneOf " ")+ _ <- many1 space+ linkseq <- many1 (oneOf "AGTCUagtcu")+ _ <- many1 space+ _ <- char '['+ nodes1 <- many1 parseMatchedNodes+ _ <- char ']'+ _ <- many1 space+ _ <- char '['+ nodes2 <- many1 parseMatchedNodes+ _ <- char ']'+ newline+ return $ HMMCompareResult name1 name2 (readDouble score1) (readDouble score2) linkseq nodes1 nodes2++-- | Parse indices of matched nodes between models as integers+parseMatchedNodes :: GenParser Char st Int +parseMatchedNodes = do+ nodeNumber <- many1 digit+ optional (char ',')+ return $ (readInt nodeNumber)++-- | Parser for HMMCompare result strings+getHMMCompareResults :: FilePath -> IO [Either ParseError HMMCompareResult] +getHMMCompareResults filePath = let+ fp = filePath+ doParseLine' = parse genParseHMMCompareResult "genParseHMMCompareResults"+ --doParseLine l = case (doParseLine' l) of+ -- Right x -> x+ -- Left _ -> error "Failed to parse line"+ in do+ fileContent <- liftM lines $ readFile fp+ return $ map doParseLine' fileContent++getModelsNames :: [HMMCompareResult] -> [String]+getModelsNames models = concat (map getModelNames models)++getModelNames :: HMMCompareResult -> [String]+getModelNames model = [model1Name model,model2Name model]