| 1 |
import Probability |
| 2 |
import Probability.Random |
| 3 |
import Probability.Distribution.Tree.Coalescent |
| 4 |
import qualified Data.Text as T |
| 5 |
import Tree.Newick |
| 6 |
import Data.JSON as J |
| 7 |
import Data.Char |
| 8 |
|
| 9 |
model taxa = do |
| 10 |
theta <- sample $ logLaplace 2 2 |
| 11 |
|
| 12 |
let nTaxa = length taxa |
| 13 |
taxonAges = zip taxa [0..] |
| 14 |
rateShifts = [(0,theta)] |
| 15 |
|
| 16 |
tree <- sample $ coalescentTree taxonAges rateShifts |
| 17 |
|
| 18 |
let loggers = ["tree" %=% writeNewick tree, "theta" %=% theta] |
| 19 |
return (tree, loggers) |
| 20 |
|
| 21 |
name i | i < 26 = [chr(65+i)] |
| 22 |
| otherwise = [chr(65+m)] ++ name d |
| 23 |
where (d,m) = divMod i 26 |
| 24 |
|
| 25 |
main = do |
| 26 |
let n = 20 |
| 27 |
taxa = fmap T.pack $ fmap name [0..n-1] |
| 28 |
|
| 29 |
(tree,loggers) <- runRandomStrict (model taxa) |
| 30 |
putStrLn $ show $ J.Object loggers |