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