diff options
-rw-r--r-- | bin/cluster.hs | 9 | ||||
-rw-r--r-- | package.yaml | 1 | ||||
-rw-r--r-- | phylogenies.cabal | 1 |
3 files changed, 7 insertions, 4 deletions
diff --git a/bin/cluster.hs b/bin/cluster.hs index 4d67541..dd8f2c6 100644 --- a/bin/cluster.hs +++ b/bin/cluster.hs @@ -7,6 +7,7 @@ import Data.Fixed (mod') import Data.Foldable (toList) import Data.List import qualified Data.Map as M +import GHC.Compact import Numeric.Log hiding (sum) import Options.Applicative import PPL @@ -94,7 +95,7 @@ drawGraph path ps cl = writeFile path $ "digraph{" <> edges <> "}" -- Normalise to frequency of parent norm :: [Double] -> [Double] - norm xxs@(x : xs) = x : zipWith (\i y -> y / xxs !! parent i) [1..] xs + norm xxs@(x : xs) = x : zipWith (\i y -> y / xxs !! parent i) [1 ..] xs -- Command line args data Options = Options @@ -129,9 +130,9 @@ main = run =<< execParser opts run opts = do setStdGen . mkStdGen $ seed opts (hdr : lines) <- lines <$> readFile (input opts) - let parsed = map (map dbl . tail . words) lines - dbl = round . read :: String -> Int - ((ps, cl), _) <- foldl1' (\a c -> if mml a < mml c then a else c) . take (nsamples opts) <$> mh (mhfrac opts) (model parsed) + let dbl = round . read :: String -> Int + parsed <- compact $ map (map dbl . tail . words) lines + ((ps, cl), _) <- foldl1' (\a c -> if mml a < mml c then a else c) . take (nsamples opts) <$> mh (mhfrac opts) (model $ getCompact parsed) writeFile (propsPath opts) . unlines $ map (intercalate "," . map show) ps writeFile (clusterPath opts) . unlines $ map show cl when (dotPath opts /= "") $ drawGraph (dotPath opts) ps cl diff --git a/package.yaml b/package.yaml index 23b8f71..45e1f72 100644 --- a/package.yaml +++ b/package.yaml @@ -15,3 +15,4 @@ executable: - log-domain - random - optparse-applicative + - ghc-compact diff --git a/phylogenies.cabal b/phylogenies.cabal index 3702eaa..22d5728 100644 --- a/phylogenies.cabal +++ b/phylogenies.cabal @@ -22,6 +22,7 @@ executable phylogenies build-depends: base >=4.9 && <5 , containers + , ghc-compact , log-domain , optparse-applicative , ppl |