-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformatted tnt2newick which now works for tree files of any length a…
…nd has new functionalities, internal input verification, as well as several tests ready.
- Loading branch information
1 parent
8df9e25
commit f2feaa3
Showing
5 changed files
with
161 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: tbea | ||
Title: Tools for Pre- and Post-processing in Bayesian Evolutionary Analyses | ||
Version: 0.4.0 | ||
Version: 0.5.0 | ||
Authors@R: c(person("Gustavo A.", "Ballen", email = "[email protected]", role = c("aut", "cre")), | ||
person("Sandra", "Reinales", email = "[email protected]", role = c("aut"))) | ||
Description: Package for bayesian inference in phylogenetics and evolution. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# create some input tree and their expected outputs | ||
|
||
# create a file with multiple trees in TNT format to convert to newick format | ||
writeLines( | ||
text = c( | ||
"tread \'some comment\'", | ||
"(Taxon_A ((Taxon_B Taxon_C)(Taxon_D Taxon_E)))*", | ||
"(Taxon_A (Taxon_B (Taxon_C (Taxon_D Taxon_E))))*", | ||
"(Taxon_A (Taxon_C (Taxon_B (Taxon_D Taxon_E))));", | ||
"proc-;"), | ||
con = "someTrees.tre" | ||
) | ||
|
||
# create a file with multiple trees newick format to convert | ||
writeLines( | ||
text = c( | ||
"(Taxon_A,((Taxon_B,Taxon_C),(Taxon_D,Taxon_E)));", | ||
"(Taxon_A,(Taxon_B,(Taxon_C,(Taxon_D,Taxon_E))));", | ||
"(Taxon_A,(Taxon_C,(Taxon_B,(Taxon_D,Taxon_E))));"), | ||
con = "someTrees.newick" | ||
) | ||
|
||
|
||
|
||
#file, output = NULL, string = NULL, return = FALSE, subsetting = FALSE, name.sep = NULL | ||
|
||
test_that("input file does not exist while string is NULL", { | ||
expect_error(tnt2newick(file = "file_that_does_not_exist.tre", output = NULL, string = NULL, return = FALSE, subsetting = FALSE, name.sep = NULL), | ||
regexp = "does not exist", | ||
ignore.case = TRUE) | ||
}) | ||
|
||
test_that("output is NULL and return is FALSE", { | ||
expect_error(tnt2newick(file = "someTrees.tre", output = NULL, string = NULL, return = FALSE, subsetting = FALSE, name.sep = NULL), | ||
regexp = "output file is required", | ||
ignore.case = TRUE) | ||
}) | ||
|
||
test_that("output file and return can not be in effect at the same time", { | ||
expect_warning(tnt2newick(file = "someTrees.tre", output = "outputTrees.newick", string = NULL, return = TRUE, subsetting = FALSE, name.sep = NULL), | ||
regexp = "are in use when only one of them should be", | ||
ignore.case = TRUE) | ||
}) | ||
|
||
test_that("output file already exists", { | ||
expect_warning(tnt2newick(file = "someTrees.tre", output = "someTrees.newick", string = NULL, return = FALSE, subsetting = FALSE, name.sep = NULL), | ||
regexp = "already exists, it will be overwritten", | ||
ignore.case = TRUE) | ||
}) | ||
|
||
test_that("number of name separators got completely replaced using name.sep", { | ||
expect_equal(sum(sapply(gregexpr(pattern = "_", text = readLines(con = "someTrees.tre"), fixed=TRUE), function(i) sum(i > 0))), | ||
sum(sapply(gregexpr(pattern = "--", text = tnt2newick(file = "someTrees.tre", output = NULL, string = NULL, return = TRUE, subsetting = FALSE, name.sep = c("_", "--")), fixed=TRUE), function(i) sum(i > 0)))) | ||
}) | ||
|
||
# clean tesating files | ||
file.remove(dir(pattern = ".tre$")) | ||
file.remove(dir(pattern = ".newick$")) |