[Phylobase-commits] r916 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 8 23:11:38 CEST 2014


Author: francois
Date: 2014-04-08 23:11:38 +0200 (Tue, 08 Apr 2014)
New Revision: 916

Added:
   pkg/R/multiphylo4-class.R
Removed:
   pkg/R/class-multiphylo4.R
Log:
renaming class-multiphylo4 to multiphylo4-class, moving setAs code for this class here

Deleted: pkg/R/class-multiphylo4.R
===================================================================
--- pkg/R/class-multiphylo4.R	2014-04-08 21:10:44 UTC (rev 915)
+++ pkg/R/class-multiphylo4.R	2014-04-08 21:11:38 UTC (rev 916)
@@ -1,24 +0,0 @@
-## classes for holding multiple tree objects
-
-##' multiPhylo4 and extended classes
-##' 
-##' Classes for lists of phylogenetic trees.  These classes and methods are
-##' planned for a future version of \code{phylobase}.
-##' 
-##' 
-##' @name multiPhylo-class
-##' @aliases multiPhylo-class multiPhylo4-class multiPhylo4d-class tbind
-##' @docType class
-##' @keywords classes
-##' @export
-setClass("multiPhylo4", representation(phylolist = "list", 
-    tree.names = "character"), prototype = list(phylolist = list(), 
-    tree.names = character(0)))
-
-setClass("multiPhylo4d", representation(tip.data = "data.frame"), 
-    contains = "multiPhylo4")
-
-setMethod("initialize", "multiPhylo4", function(.Object, ...) {
-    stop("multiPhylo and multiphylo4d not yet implemented", 
-         "Try using a list of phylo4(d) objects and lapply().")
-})

Copied: pkg/R/multiphylo4-class.R (from rev 911, pkg/R/class-multiphylo4.R)
===================================================================
--- pkg/R/multiphylo4-class.R	                        (rev 0)
+++ pkg/R/multiphylo4-class.R	2014-04-08 21:11:38 UTC (rev 916)
@@ -0,0 +1,53 @@
+## classes for holding multiple tree objects
+
+##' multiPhylo4 and extended classes
+##' 
+##' Classes for lists of phylogenetic trees.  These classes and methods are
+##' planned for a future version of \code{phylobase}.
+##' 
+##' 
+##' @name multiPhylo-class
+##' @aliases multiPhylo-class multiPhylo4-class multiPhylo4d-class tbind
+##' @docType class
+##' @keywords classes
+##' @export
+setClass("multiPhylo4", representation(phylolist = "list", 
+    tree.names = "character"), prototype = list(phylolist = list(), 
+    tree.names = character(0)))
+
+setClass("multiPhylo4d", representation(tip.data = "data.frame"), 
+    contains = "multiPhylo4")
+
+setMethod("initialize", "multiPhylo4", function(.Object, ...) {
+    message("multiPhylo and multiphylo4d not yet implemented", 
+            "Try using a list of phylo4(d) objects and lapply().")
+})
+
+##' multiPhylo4 and extended classes
+##' 
+##' Classes for lists of phylogenetic trees.  These classes and methods are
+##' planned for a future version of \code{phylobase}.
+##' 
+##' 
+##' @name multiPhylo-class
+##' @aliases multiPhylo-class multiPhylo4-class multiPhylo4d-class tbind
+##' @docType class
+##' @keywords classes
+setAs("multiPhylo", "multiPhylo4", function(from, to) {
+    trNm <- names(from)
+    if(is.null(trNm)) trNm <- character(0)
+    newobj <- new("multiPhylo4", phylolist = lapply(from, function(x)
+                                 as(x, "phylo4")),
+                  tree.names = trNm)
+    newobj
+})
+
+
+setAs("multiPhylo4", "multiPhylo", function(from, to) {
+    y <- lapply(from at phylolist, function(x) as(x, "phylo"))
+    names(y) <- from at tree.names
+    if (hasTipData(from))
+        warning("discarded tip data")
+    class(y) <- "multiPhylo"
+    y
+})



More information about the Phylobase-commits mailing list