Skip to content

Commit

Permalink
Change some of the sampleIO to sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
bredelings committed Oct 17, 2023
1 parent 5f85733 commit 7905082
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions haskell/Probability/Distribution/OnTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ instance (IsTree t, HasRoot (Rooted t), HasLabels t, HasBranchLengths (Rooted t)

return $ Unaligned $ CharacterData alphabet $ getLabelled tree sequenceForNode stateSequences

instance (IsTree t, HasRoot (Rooted t), HasLabels t, HasBranchLengths t, HasBranchLengths (Rooted t), SimpleSModel s) => Sampleable (CTMCOnTree t s) where
sample dist = RanDistribution2 dist do_nothing


----------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions scripts/Simulate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ getStartLength args = read startLength' :: Int

-- Sample substitution model parameters and define the substitution model
getSmodel = do
kappaPur <- sampleIO $ log_normal (log 2) 0.25
kappaPur <- sample $ log_normal (log 2) 0.25

kappaPyr <- sampleIO $ log_normal (log 2) 0.25
kappaPyr <- sample $ log_normal (log 2) 0.25

pi <- sampleIO $ symmetric_dirichlet_on (letters dna) 1
pi <- sample $ symmetric_dirichlet_on (letters dna) 2

return $ tn93' dna kappaPur kappaPyr pi

Expand All @@ -50,15 +50,15 @@ getImodel = do

model rootedTree startLength = do

smodel <- getSmodel
smodel <- run_lazy $ getSmodel

imodel <- getImodel
imodel <- run_lazy $ getImodel

-- Sample the sequences and their alignment
alignment <- sampleIO $ IndelsOnTree rootedTree imodel startLength

-- Sample ancestral sequence STATES
sequences <- sampleIO $ ctmc_on_tree rootedTree alignment smodel
sequences <- run_lazy $ sample $ ctmc_on_tree rootedTree alignment smodel

-- Print the aligned sequences
return $ align alignment sequences
Expand Down

0 comments on commit 7905082

Please sign in to comment.