tests/testthat/test-jtree.R

context("jtree input and output")

rstfile <- system.file("extdata/PAML_Codeml", "rst", package="treeio")
mlcfile <- system.file("extdata/PAML_Codeml", "mlc", package="treeio")
ml <- read.codeml(rstfile, mlcfile)

jtree_text <- write.jtree(ml)
jtree_file <- tempfile()

write.jtree(ml, jtree_file)

js <- jsonlite::fromJSON(jtree_file)

tree <- read.jtree(jtree_file)

test_that("write.jtree output a json file", {
    expect_gt(file.info(jtree_file)$size, 0)
    expect_true(is(js, "list"))
    expect_true(all(c("tree", "data") %in% names(js)))
    expect_true(all(c("edge_num", "dN", "dS") %in% names(js$data)))
    expect_true(treeio:::is.tree(tree))
    expect_true(treeio:::has.slot(tree, "data"))
})

Try the treeio package in your browser

Any scripts or data that you put into this service are public.

treeio documentation built on Nov. 21, 2020, 2:01 a.m.