packages feed

tlynx 0.6.1.1 → 0.7.0.1

raw patch · 20 files changed

+134/−125 lines, 20 filesdep +randomdep −mwc-randomdep −primitivePVP ok

version bump matches the API change (PVP)

Dependencies added: random

Dependencies removed: mwc-random, primitive

API changes (from Hackage documentation)

- TLynx.Grabble: grabble :: PrimMonad m => [a] -> Int -> Int -> Gen (PrimState m) -> m [[a]]
+ TLynx.Grabble: grabble :: StatefulGen g m => [a] -> Int -> Int -> g -> m [[a]]

Files

ChangeLog.md view
@@ -5,9 +5,16 @@ ## Unreleased changes  +## Version 0.7.0.1++-   Random 1.2: Parallel functions now require an \`IOGenM\` random number+    generator.+-   Fix splitting of the random number generator.++ ## Version 0.6.1.1 --   Remove plotting functionality (gnuplot incompatible with ghc921).+-   Remove plotting functionality (gnuplot incompatible with ghc922). -   Read files strictly. -   Refactor; flatten model hierarchy. 
README.md view
@@ -2,7 +2,7 @@  # The ELynx Suite -Version: 0.6.1.1.+Version: 0.7.0.0. Reproducible evolution made easy.  <p align="center"><img src="https://travis-ci.org/dschrempf/elynx.svg?branch=master"/></p>@@ -74,9 +74,9 @@     # OR: slynx --help      Up to date-    ELynx Suite version 0.6.1.1.+    ELynx Suite version 0.7.0.0.     Developed by Dominik Schrempf.-    Compiled on February 22, 2022, at 15:10 pm, UTC.+    Compiled on July 10, 2022, at 08:48 am, UTC.          Usage: slynx [-v|--verbosity VALUE] [-o|--output-file-basename NAME]                  [-f|--force] [--no-elynx-file] COMMAND@@ -144,16 +144,16 @@     # OR: slynx simulate --help      Up to date-    ELynx Suite version 0.6.1.1.+    ELynx Suite version 0.7.0.0.     Developed by Dominik Schrempf.-    Compiled on February 22, 2022, at 15:10 pm, UTC.+    Compiled on July 10, 2022, at 08:48 am, UTC.          Usage: slynx simulate (-t|--tree-file Name) [-s|--substitution-model MODEL]                           [-m|--mixture-model MODEL] [-e|--edm-file NAME]                           [-p|--siteprofile-files NAMES]                           [-w|--mixture-model-weights "[DOUBLE,DOUBLE,...]"]                           [-g|--gamma-rate-heterogeneity "(NCAT,SHAPE)"]-                          (-l|--length NUMBER) [-S|--seed [INT]]+                          (-l|--length NUMBER) [-S|--seed INT]       Simulate multi sequence alignments.          Available options:@@ -175,8 +175,7 @@       -g,--gamma-rate-heterogeneity "(NCAT,SHAPE)"                                Number of gamma rate categories and shape parameter       -l,--length NUMBER       Set alignment length to NUMBER-      -S,--seed [INT]          Seed for random number generator; list of 32 bit-                               integers with up to 256 elements (default: random)+      -S,--seed INT            Seed for random number generator (default: random)       -h,--help                Show this help text          Substitution models:
app/Main.hs view
@@ -1,7 +1,7 @@ -- | -- Module      :  Main -- Description :  Work with phylogenetic trees--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Compare/Compare.hs view
@@ -4,7 +4,7 @@ -- | -- Module      :  TLynx.Compare.Compare -- Description :  Compare two phylogenies--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Compare/Options.hs view
@@ -3,7 +3,7 @@ -- | -- Module      :  TLynx.Compare.Options -- Description :  Options for the compare subcommand--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -66,14 +66,16 @@ normalize :: Parser Bool normalize =   switch $-    long "normalize" <> short 'n'+    long "normalize"+      <> short 'n'       <> help         "Normalize trees before comparison"  bipartitions :: Parser Bool bipartitions =   switch $-    long "bipartitions" <> short 'b'+    long "bipartitions"+      <> short 'b'       <> help         "Print and plot common and missing bipartitions" 
src/TLynx/Connect/Connect.hs view
@@ -4,7 +4,7 @@ -- | -- Module      :  TLynx.Connect.Connect -- Description :  Connect two phylogenies--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Connect/Options.hs view
@@ -3,7 +3,7 @@ -- | -- Module      :  TLynx.Connect.Options -- Description :  Options for the connect subcommand--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Distance/Distance.hs view
@@ -3,7 +3,7 @@  -- | -- Description :  Compute distances between trees--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -52,7 +52,8 @@  header :: Int -> Int -> DistanceMeasure -> BL.ByteString header n m d =-  alignLeft (n + 2) "Tree 1" <> alignLeft (n + 2) "Tree 2"+  alignLeft (n + 2) "Tree 1"+    <> alignLeft (n + 2) "Tree 2"     <> alignRight       (m + 2)       (BL.pack $ show d)@@ -166,7 +167,6 @@         Just masterTree -> [(0, i, distanceMeasure masterTree t') | (i, t') <- zip [1 ..] trees]       ds = map (\(_, _, x) -> x) dsTriplets       dsVec = V.fromList ds-  -- TODO: This should never happen (hPutStrLn??).   liftIO $     hPutStrLn outH $       "Summary statistics of "@@ -187,9 +187,6 @@       T.justifyLeft 10 ' ' "Variance: "         <> T.pack           (printf pf (variance dsVec))-  -- BS.putStrLn $ BS.unlines $ map toNewick ts-  -- BS.putStrLn $ BS.unlines $ map toNewick tsN-  -- BS.putStrLn $ BS.unlines $ map toNewick tsC    unless     (argsSummaryStatistics l)
src/TLynx/Distance/Options.hs view
@@ -4,7 +4,7 @@ -- | -- Module      :  TLynx.Distance.Options -- Description :  Options of tree-dist--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -150,7 +150,8 @@ summaryStatisticsSwitch :: Parser Bool summaryStatisticsSwitch =   switch $-    long "summary-statistics" <> short 's'+    long "summary-statistics"+      <> short 's'       <> help         "Report summary statistics only" 
src/TLynx/Examine/Examine.hs view
@@ -3,7 +3,7 @@  -- | -- Description :  Analyze trees--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Examine/Options.hs view
@@ -3,7 +3,7 @@ -- | -- Module      :  TLynx.Examine.Options -- Description :  Tree analysis options--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Grabble.hs view
@@ -1,7 +1,7 @@ -- | -- Module      :  TLynx.Grabble -- Description :  Grabble a list--- Copyright   :  (c) 2021 Dominik Schrempf+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -15,20 +15,19 @@ where  import Control.Monad-import Control.Monad.Primitive import Control.Monad.ST import Data.Vector (Vector) import qualified Data.Vector as V import qualified Data.Vector.Mutable as M-import System.Random.MWC+import System.Random.Stateful  -- | @grabble xs m n@ is /O(m*n')/, where @n' = min n (length xs)@. Choose @n'@ -- elements from @xs@, without replacement, and that @m@ times.-grabble :: PrimMonad m => [a] -> Int -> Int -> Gen (PrimState m) -> m [[a]]+grabble :: StatefulGen g m => [a] -> Int -> Int -> g -> m [[a]] grabble xs m n gen = do   swapss <- replicateM m $     forM [0 .. min (l - 1) n] $ \i -> do-      j <- uniformR (i, l) gen+      j <- uniformRM (i, l) gen       return (i, j)   return $ map (V.toList . V.take n . swapElems (V.fromList xs)) swapss   where
src/TLynx/Options.hs view
@@ -3,7 +3,7 @@ -- | -- Module      :  TLynx.Options -- Description :  TLynx general options--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Parsers.hs view
@@ -1,7 +1,7 @@ -- | -- Module      :  TLynx.Parsers -- Description :  Parse Newick/Nexus tree files--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
src/TLynx/Shuffle/Options.hs view
@@ -3,7 +3,7 @@ -- | -- Module      :  TLynx.Shuffle.Options -- Description :  Options for the connect subcommand--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -55,7 +55,10 @@ n :: Parser Int n =   option auto $-    long "replicates" <> short 'n' <> metavar "N" <> value 1+    long "replicates"+      <> short 'n'+      <> metavar "N"+      <> value 1       <> help         "Number of trees to generate" 
src/TLynx/Shuffle/Shuffle.hs view
@@ -4,7 +4,7 @@ -- | -- Module      :  TLynx.Shuffle.Shuffle -- Description :  Shuffle a phylogeny--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -36,7 +36,7 @@     toReconstructedTree,   ) import System.IO (hClose)-import System.Random.MWC (GenIO, initialize)+import System.Random.Stateful import TLynx.Grabble import TLynx.Parsers import TLynx.Shuffle.Options@@ -68,22 +68,22 @@   logDebugS $ "Number of leaves: " <> show (length ls)   logDebugS "The coalescent times are: "   logDebugS $ show cs-  gen <- liftIO $-    initialize $ case argsSeed l of-      RandomUnset -> error "Seed not available; please contact maintainer."-      RandomSet s -> s-      Fixed s -> s+  gen <- newIOGenM $ mkStdGen $ case argsSeed l of+    RandomUnset -> error "Seed not available; please contact maintainer."+    RandomSet s -> s+    Fixed s -> s   ts <- liftIO $ shuffleT (nReplicates l) (height t) cs ls gen   liftIO $ BL.hPutStr h $ BL.unlines $ map (toNewick . lengthToPhyloTree) ts   liftIO $ hClose h  shuffleT ::+  StatefulGen g m =>   Int -> -- How many?   Length -> -- Stem length.   [Length] -> -- Coalescent times.   [Name] -> -- Leave names.-  GenIO ->-  IO (Forest Length Name)+  g ->+  m (Forest Length Name) shuffleT n o cs ls gen = do   css <- grabble cs n (length cs) gen   lss <- grabble ls n (length ls) gen
src/TLynx/Simulate/Options.hs view
@@ -6,7 +6,7 @@ -- | -- Module      :  TLynx.Simulate.Options -- Description :  Argument parser for seq-ana--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -234,7 +234,9 @@ sumStatOpt :: Parser Bool sumStatOpt =   switch $-    long "summary-statistics" <> short 's' <> showDefault+    long "summary-statistics"+      <> short 's'+      <> showDefault       <> help         "For each branch, print length and number of children" 
src/TLynx/Simulate/Simulate.hs view
@@ -5,7 +5,7 @@  -- | --   Description :  Simulate reconstructed trees---   Copyright   :  (c) Dominik Schrempf 2021+--   Copyright   :  2021 Dominik Schrempf --   License     :  GPL-3.0-or-later -- --   Maintainer  :  dominik.schrempf@gmail.com@@ -32,7 +32,6 @@   ) import Control.Monad import Control.Monad.IO.Class-import Control.Monad.Primitive import Control.Monad.Trans.Reader hiding (local) import Control.Parallel.Strategies import qualified Data.ByteString.Builder as BB@@ -41,8 +40,6 @@ import Data.Maybe import qualified Data.Sequence as Seq import qualified Data.Set as Set-import qualified Data.Vector.Unboxed as VU-import Data.Word import ELynx.Tools.ELynx import ELynx.Tools.Environment import ELynx.Tools.Logger@@ -50,18 +47,10 @@ import ELynx.Tree import qualified ELynx.Tree.Simulate.Coalescent as CS import qualified ELynx.Tree.Simulate.PointProcess as PP-import System.Random.MWC+import System.Random.Stateful import TLynx.Grabble import TLynx.Simulate.Options --- Split a generator.-splitGen :: PrimMonad m => Int -> Gen (PrimState m) -> m [Gen (PrimState m)]-splitGen n gen-  | n <= 0 = return []-  | otherwise = do-    seeds :: [VU.Vector Word32] <- replicateM (n -1) $ uniformVector gen 256-    fmap (gen :) (mapM initialize seeds)- -- For a given number of capabilities and number of calculations, get chunk -- sizes. The chunk sizes will be as evenly distributed as possible and sum up -- to the number of calculations.@@ -75,13 +64,18 @@ -- | Simulate phylogenetic trees using birth and death process. simulate :: ELynx SimulateArguments () simulate = do-  l@(SimulateArguments nTrees nLeaves pr subS sumS (Fixed s)) <- localArguments <$> ask+  l@(SimulateArguments nTrees nLeaves pr subS sumS sOpt) <- localArguments <$> ask+  let s = case fromSeedOpt sOpt of+        Nothing -> error "simulate: No seed."+        Just x -> x   c <- liftIO getNumCapabilities   logInfoNewSection "Arguments"   logInfoS $ reportSimulateArguments l   logInfoNewSection "Simulation"   logInfoS $ "Number of used cores: " <> show c-  gs <- liftIO $ initialize s >>= \gen -> splitGen c gen+  gen <- newIOGenM $ mkStdGen s+  rs <- replicateM c $ splitGenM gen+  gs <- mapM newIOGenM rs   let chunks = getChunks c nTrees   trs <- case pr of     (BirthDeath lambda mu mRho timeSpec) -> do@@ -109,13 +103,14 @@   out "simulated trees" res ".tree"  bdSimulateNTreesConcurrently ::+  RandomGen g =>   Int ->   Double ->   Double ->   Double ->   PP.TimeSpec ->   [Int] ->-  [GenIO] ->+  [IOGenM g] ->   IO (Forest Length Int) bdSimulateNTreesConcurrently nLeaves l m r timeSpec chunks gs = do   let l' = l * r@@ -127,9 +122,10 @@   return $ concat trss  coalSimulateNTreesConcurrently ::+  RandomGen g =>   Int ->   [Int] ->-  [GenIO] ->+  [IOGenM g] ->   IO (Forest Length Int) coalSimulateNTreesConcurrently nL chunks gs = do   trss <-@@ -139,6 +135,7 @@   return $ concat trss  bdSimulateAndSubSampleNTreesConcurrently ::+  RandomGen g =>   Int ->   Double ->   Double ->@@ -146,7 +143,7 @@   Double ->   PP.TimeSpec ->   [Int] ->-  [GenIO] ->+  [IOGenM g] ->   ELynx SimulateArguments (Forest Length Int) bdSimulateAndSubSampleNTreesConcurrently nLeaves l m r p timeSpec chunks gs = do   let nLeavesBigTree = (round $ fromIntegral nLeaves / p) :: Int@@ -175,10 +172,11 @@   return $ map prune trs  coalSimulateAndSubSampleNTreesConcurrently ::+  RandomGen g =>   Int ->   Double ->   [Int] ->-  [GenIO] ->+  [IOGenM g] ->   ELynx SimulateArguments (Forest Length Int) coalSimulateAndSubSampleNTreesConcurrently nL p chunks gs = do   let nLeavesBigTree = (round $ fromIntegral nL / p) :: Int@@ -210,21 +208,21 @@ -- sub-sampling as well as lookup are fast and so that these data structures do -- not have to be recomputed when many sub-samples are requested. nSubSamples ::-  Ord a =>+  (Ord a, StatefulGen g m) =>   Int ->   Seq.Seq a ->   Int ->   Tree e a ->-  GenIO ->-  IO [Maybe (Tree e a)]+  g ->+  m [Maybe (Tree e a)] nSubSamples m lvs n tree g   | Seq.length lvs < n =-    error-      "Given list of leaves is shorter than requested number of leaves."+      error+        "Given list of leaves is shorter than requested number of leaves."   | otherwise = do-    lss <- grabble (toList lvs) m n g-    let lsSets = map Set.fromList lss-    return [dropLeavesWith (`Set.notMember` ls) tree | ls <- lsSets]+      lss <- grabble (toList lvs) m n g+      let lsSets = map Set.fromList lss+      return [dropLeavesWith (`Set.notMember` ls) tree | ls <- lsSets]  -- Pair of branch length with number of extant children. type BrLnNChildren = (Length, Int)
src/TLynx/TLynx.hs view
@@ -1,7 +1,7 @@ -- | -- Module      :  TLynx.TLynx -- Description :  TLynx module--- Copyright   :  (c) Dominik Schrempf 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com
tlynx.cabal view
@@ -1,80 +1,81 @@-cabal-version:  3.0-name:           tlynx-version:        0.6.1.1-synopsis:       Handle phylogenetic trees-description:    Examine, compare, and simulate phylogenetic trees in a reproducible way. Please see the README on GitHub at <https://github.com/dschrempf/elynx>.-category:       Bioinformatics-homepage:       https://github.com/dschrempf/elynx#readme-bug-reports:    https://github.com/dschrempf/elynx/issues-author:         Dominik Schrempf-maintainer:     dominik.schrempf@gmail.com-copyright:      Dominik Schrempf (2021)-license:        GPL-3.0-or-later-license-file:   LICENSE-build-type:     Simple+cabal-version:      3.0+name:               tlynx+version:            0.7.0.1+synopsis:           Handle phylogenetic trees+description:+  Examine, compare, and simulate phylogenetic trees in a reproducible way. Please see the README on GitHub at <https://github.com/dschrempf/elynx>. +category:           Bioinformatics+homepage:           https://github.com/dschrempf/elynx#readme+bug-reports:        https://github.com/dschrempf/elynx/issues+author:             Dominik Schrempf+maintainer:         dominik.schrempf@gmail.com+copyright:          2021 Dominik Schrempf+license:            GPL-3.0-or-later+license-file:       LICENSE+build-type:         Simple extra-source-files:-    README.md-    ChangeLog.md+  ChangeLog.md+  README.md  source-repository head-  type: git+  type:     git   location: https://github.com/dschrempf/elynx  library   exposed-modules:-      TLynx.Compare.Compare-      TLynx.Compare.Options-      TLynx.Connect.Connect-      TLynx.Connect.Options-      TLynx.Distance.Distance-      TLynx.Distance.Options-      TLynx.Examine.Examine-      TLynx.Examine.Options-      TLynx.Grabble-      TLynx.Options-      TLynx.Parsers-      TLynx.Shuffle.Options-      TLynx.Shuffle.Shuffle-      TLynx.Simulate.Options-      TLynx.Simulate.Simulate-      TLynx.TLynx-  other-modules:-      Paths_tlynx-  autogen-modules:-      Paths_tlynx-  hs-source-dirs: src-  ghc-options: -Wall -Wunused-packages+    TLynx.Compare.Compare+    TLynx.Compare.Options+    TLynx.Connect.Connect+    TLynx.Connect.Options+    TLynx.Distance.Distance+    TLynx.Distance.Options+    TLynx.Examine.Examine+    TLynx.Examine.Options+    TLynx.Grabble+    TLynx.Options+    TLynx.Parsers+    TLynx.Shuffle.Options+    TLynx.Shuffle.Shuffle+    TLynx.Simulate.Options+    TLynx.Simulate.Simulate+    TLynx.TLynx++  other-modules:    Paths_tlynx+  autogen-modules:  Paths_tlynx+  hs-source-dirs:   src+  ghc-options:      -Wall -Wunused-packages   build-depends:-      aeson+    , aeson     , async     , attoparsec-    , base >=4.7 && <5+    , base                  >=4.7 && <5     , bytestring     , comonad     , containers     , data-default-class     , elynx-tools     , elynx-tree-    , mwc-random     , optparse-applicative     , parallel-    , primitive+    , random     , statistics     , text     , transformers     , vector+   default-language: Haskell2010  executable tlynx-  main-is: Main.hs-  other-modules:-      Paths_tlynx-  autogen-modules:-      Paths_tlynx-  hs-source-dirs: app-  ghc-options: -Wall -Wunused-packages -threaded -rtsopts -with-rtsopts=-N+  main-is:          Main.hs+  other-modules:    Paths_tlynx+  autogen-modules:  Paths_tlynx+  hs-source-dirs:   app+  ghc-options:+    -Wall -Wunused-packages -threaded -rtsopts -with-rtsopts=-N+   build-depends:-      base >=4.7 && <5+    , base   >=4.7 && <5     , tlynx+   default-language: Haskell2010