Skip to content

Commit

Permalink
Merge pull request #58 from xiangpin/read.mcmctree
Browse files Browse the repository at this point in the history
add read.mcmctree function
  • Loading branch information
GuangchuangYu authored Jun 4, 2021
2 parents b3295d4 + 5d2d3bf commit 063a2bc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export(read.hyphy.seq)
export(read.iqtree)
export(read.jplace)
export(read.jtree)
export(read.mcmctree)
export(read.mega)
export(read.mega_tabular)
export(read.mrbayes)
Expand Down
27 changes: 27 additions & 0 deletions R/MCMCTree.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
##' read MCMCTree output Tree
##'
##' @title read.mcmctree
##' @param file the output tree file of MCMCTree
##' @return treedata object
##' @export
##' @examples
##' file <- system.file("extdata/MCMCTree", "mcmctree_output.tree", package="treeio")
##' tr <- read.mcmctree(file)
##' tr
read.mcmctree <- function(file){
text <- readLines(file)
ind <- grep("^.*tree.*=.*", text, ignore.case=TRUE)
text[ind] <- gsub("^.*TREE", "TREE", text[ind], ignore.case=TRUE)
text <- paste(text, collapse="\n")
newfile <- tempfile()
writeLines(text, newfile)
obj <- read.beast(file=newfile)
if(inherits(obj, "treedata")){
obj@file <- filename(file)
}else{
for (i in seq_len(length(obj))){
obj[[i]]@file <- filename(file)
}
}
return(obj)
}
5 changes: 5 additions & 0 deletions inst/extdata/MCMCTree/mcmctree_output.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#NEXUS
BEGIN TREES;

UTREE 1 = ((((((((((((((((Dioscorea_villosa: 1.048609, ((Colchicum_autumnale: 0.680447, Smilax_bona-nox: 0.680447) [&95%={0.365, 0.913}]: 0.278870, ((((Sorghum_bicolor: 0.208728, Zea_mays: 0.208728) [&95%={0.090, 0.386}]: 0.272402, (Oryza_sativa: 0.348895, Brachypodium_distachyon: 0.348895) [&95%={0.194, 0.536}]: 0.132234) [&95%={0.319, 0.653}]: 0.301939, Sabal_bermudana: 0.783068) [&95%={0.624, 0.930}]: 0.111954, Yucca_filamentosa: 0.895023) [&95%={0.767, 1.029}]: 0.064294) [&95%={0.847, 1.091}]: 0.089292) [&95%={0.926, 1.175}]: 0.193469, Acorus_americanus: 1.242078) [&95%={1.151, 1.285}]: 0.419769, ((Sarcandra_glabra: 1.423141, ((Persea_americana: 1.182059, Liriodendron_tulipifera: 1.182059) [&95%={1.109, 1.388}]: 0.129237, (Houttuynia_cordata: 0.761429, Saruma_henryi: 0.761429) [&95%={0.513, 1.050}]: 0.549868) [&95%={1.190, 1.538}]: 0.111844) [&95%={1.282, 1.642}]: 0.120880, (((Vitis_vinifera: 1.069100, (((Hibiscus_cannabinus: 0.756565, (Arabidopsis_thaliana: 0.576251, Carica_papaya: 0.576251) [&95%={0.352, 0.782}]: 0.180314) [&95%={0.556, 0.920}]: 0.104741, Populus_trichocarpa: 0.861306) [&95%={0.698, 1.001}]: 0.104500, (Larrea_tridentata: 0.866345, (Medicago_truncatula: 0.736450, Boehmeria_nivea: 0.736450) [&95%={0.503, 0.913}]: 0.129895) [&95%={0.689, 1.005}]: 0.099462) [&95%={0.834, 1.089}]: 0.103293) [&95%={0.949, 1.168}]: 0.083046, (Kochia_scoparia: 1.070810, (Diospyros_malabarica: 0.972900, ((Rosmarinus_officinalis: 0.760149, ((Allamanda_cathartica: 0.362569, Catharanthus_roseus: 0.362569) [&95%={0.186, 0.573}]: 0.303962, Ipomoea_purpurea: 0.666532) [&95%={0.483, 0.834}]: 0.093617) [&95%={0.583, 0.908}]: 0.126433, (Inula_helenium: 0.455099, Tanacetum_parthenium: 0.455099) [&95%={0.229, 0.727}]: 0.431484) [&95%={0.741, 1.015}]: 0.086318) [&95%={0.837, 1.089}]: 0.097909) [&95%={0.943, 1.170}]: 0.081336) [&95%={1.047, 1.226}]: 0.109845, (Eschscholzia_californica: 1.014447, (Podophyllum_peltatum: 0.783067, Aquilegia_formosa: 0.783067) [&95%={0.472, 1.019}]: 0.231379) [&95%={0.782, 1.180}]: 0.247544) [&95%={1.210, 1.286}]: 0.282031) [&95%={1.390, 1.759}]: 0.117825) [&95%={1.474, 1.893}]: 0.251538, Kadsura_heteroclita: 1.913385) [&95%={1.671, 2.174}]: 0.200808, Nuphar_advena: 2.114193) [&95%={1.853, 2.341}]: 0.215161, Amborella_trichopoda: 2.329353) [&95%={2.068, 2.467}]: 1.186361, ((Ginkgo_biloba: 2.886743, ((Cycas_rumphii: 0.209910, Cycas_micholitzii: 0.209910) [&95%={0.067, 0.511}]: 0.742625, Zamia_vazquezii: 0.952535) [&95%={0.426, 1.932}]: 1.934209) [&95%={2.660, 3.182}]: 0.291213, (((Cedrus_libani: 0.630084, Pinus_taeda: 0.630084) [&95%={0.186, 1.268}]: 1.484077, (Ephedra_sinica: 1.252101, (Gnetum_montanum: 0.893096, Welwitschia_mirabilis: 0.893096) [&95%={0.507, 1.322}]: 0.359005) [&95%={0.835, 1.883}]: 0.862060) [&95%={1.425, 2.791}]: 0.323899, (Prumnopitys_andina: 1.139418, ((Taxus_baccata: 0.684232, (Cunninghamia_lanceolata: 0.346180, Juniperus_scopulorum: 0.346180) [&95%={0.135, 0.684}]: 0.338053) [&95%={0.364, 1.029}]: 0.268541, Sciadopitys_verticillata: 0.952774) [&95%={0.631, 1.329}]: 0.186644) [&95%={0.794, 1.627}]: 1.298642) [&95%={1.701, 3.048}]: 0.739896) [&95%={3.084, 3.372}]: 0.337758) [&95%={3.311, 3.651}]: 0.756559, ((Angiopteris_evecta: 3.572426, (Psilotum_nudum: 2.694459, Ophioglossum_petiolatum: 2.694459) [&95%={1.069, 3.563}]: 0.877967) [&95%={3.215, 3.938}]: 0.470243, ((Pteridium_aquilinum: 1.157837, Alsophila_spinulosa: 1.157837) [&95%={0.498, 2.476}]: 2.748774, Equisetum_diffusum: 3.906612) [&95%={3.848, 4.040}]: 0.136057) [&95%={3.923, 4.196}]: 0.229604) [&95%={4.131, 4.405}]: 0.194226, ((Huperzia_squarrosa: 1.262266, (Pseudolycopodiella_caroliniana: 0.880517, Dendrolycopodium_obscurum: 0.880517) [&95%={0.427, 1.586}]: 0.381749) [&95%={0.751, 2.345}]: 2.827336, (Selaginella_moellendorffii_1kp: 0.118093, Selaginella_moellendorffii_genome: 0.118093) [&95%={0.041, 0.278}]: 3.971509) [&95%={3.927, 4.322}]: 0.376897) [&95%={4.367, 4.509}]: 0.534649, (((Sphagnum_lescurii: 3.997941, (Polytrichum_commune: 3.397907, ((Ceratodon_purpureus: 1.778639, ((((Anomodon_attenuatus: 0.224757, Leucodon_brachypus: 0.224757) [&95%={0.098, 0.429}]: 0.065945, (Rhynchostegium_serrulatum: 0.228452, Thuidium_delicatulum: 0.228452) [&95%={0.104, 0.426}]: 0.062250) [&95%={0.161, 0.498}]: 0.573797, (Bryum_argenteum: 0.323689, Rosulabryum_cf_capillare: 0.323689) [&95%={0.126, 0.642}]: 0.540811) [&95%={0.545, 1.262}]: 0.178913, Hedwigia_ciliata: 1.043413) [&95%={0.699, 1.538}]: 0.735227) [&95%={0.972, 2.746}]: 1.045324, Physcomitrella_patens: 2.823964) [&95%={2.685, 3.177}]: 0.573944) [&95%={2.994, 3.957}]: 0.600034) [&95%={3.494, 4.493}]: 0.673778, ((Sphaerocarpos_texanus: 2.726549, (Ricciocarpos_natans: 1.227130, (Marchantia_emarginata: 0.794260, Marchantia_polymorpha: 0.794260) [&95%={0.332, 1.346}]: 0.432870) [&95%={0.707, 2.209}]: 1.499419) [&95%={2.283, 3.621}]: 1.457978, (Metzgeria_crassipilis: 2.439998, Bazzania_trilobata: 2.439998) [&95%={0.792, 3.922}]: 1.744529) [&95%={4.053, 4.461}]: 0.487192) [&95%={4.397, 4.916}]: 0.198909, (Nothoceros_aenigmaticus: 0.164270, Nothoceros_vincentianus: 0.164270) [&95%={0.053, 0.382}]: 4.706358) [&95%={4.632, 5.065}]: 0.130520) [&95%={4.766, 5.149}]: 0.553137, Chara_vulgaris: 5.554284) [&95%={5.118, 6.145}]: 0.390023, ((((Roya_obtusa: 3.347875, (Cosmarium_ochthodes: 2.066851, Penium_margaritaceum: 2.066851) [&95%={0.860, 3.533}]: 1.281024) [&95%={2.004, 4.445}]: 0.716665, Netrium_digitus: 4.064540) [&95%={2.936, 5.021}]: 0.451107, Spirogyra_sp: 4.515647) [&95%={3.554, 5.409}]: 0.456267, ((Mougeotia_sp: 3.595207, (Cylindrocystis_brebissonii: 3.075276, Cylindrocystis_cushleckae: 3.075276) [&95%={1.413, 4.250}]: 0.519931) [&95%={2.097, 4.690}]: 0.874829, Mesotaenium_endlicherianum: 4.470036) [&95%={3.452, 5.384}]: 0.501878) [&95%={4.089, 5.802}]: 0.972393) [&95%={5.403, 6.633}]: 0.284481, (Chaetosphaeridium_globosum: 4.738019, (Coleochaete_scutata: 3.176622, Coleochaete_irregularis: 3.176622) [&95%={1.125, 4.842}]: 1.561397) [&95%={3.116, 6.056}]: 1.490769) [&95%={5.607, 7.012}]: 0.416060, (Entransia_fimbriata: 4.686396, Klebsormidium_subtile: 4.686396) [&95%={2.547, 6.542}]: 1.958452) [&95%={5.906, 7.652}]: 0.661485, (Mesostigma_viride: 5.884836, (Chlorokybus_atmophyticus: 4.184455, Spirotaenia_minuta: 4.184455) [&95%={2.113, 6.224}]: 1.700381) [&95%={3.952, 7.700}]: 1.421497) [&95%={6.337, 8.634}]: 0.461171, ((Uronema_sp: 5.843147, (Monomastix_opisthostigma: 4.869119, Nephroselmis_pyriformis: 4.869119) [&95%={3.227, 6.683}]: 0.974029) [&95%={4.500, 7.406}]: 0.837307, Pyramimonas_parkeae: 6.680455) [&95%={5.025, 8.412}]: 1.087048) [&95%={6.651, 9.296}];
END;
22 changes: 22 additions & 0 deletions man/read.mcmctree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 063a2bc

Please sign in to comment.