##' @export
ape::read.tree


##' generate random tree
##' @export
##' @rdname rtree
##' @param n number of tips in the tree
##' @param rooted logcial
##' @param tip.label tip label
##' @param br one of the following: (i) an R function used to generate the
##'           branch lengths ('rtree'; use 'NULL' to simulate only a
##'           topology), or the coalescence times ('rcoal'); (ii) a
##'           character to simulate a genuine coalescent tree for 'rcoal'
##'           (the default); or (iii) a numeric vector for the branch
##'           lengths or the coalescence times.
##' @param ... additional parameters to be passed to 'br'
##' @source
##' This is just the imported function
##' from the ape package. The documentation you should
##' read for the rtree function can be found here: \link[ape]{rtree}
##'
##' @seealso
##' \link[ape]{rtree}
rtree <- ape::rtree


##' merge phylo and output of boot.phylo to 'apeBootstrap' object
##'
##' 
##' @title apeBoot
##' @param phylo phylo
##' @param boot bootstrap values
##' @return an instance of 'apeBootstrap'
##' @importFrom ape Nnode
##' @export
##' @author Guangchuang Yu
apeBoot <- function(phylo, boot) {
    ## phylo is a phylo object
    ## boot is output from boot.phylo
    new("apeBootstrap",
        phylo=phylo,
        bootstrap=data.frame(node=(1:Nnode(phylo)) + Ntip(phylo), bootstrap=boot)
        )
}


##' @rdname show-methods
##' @importFrom ape print.phylo
##' @exportMethod show
setMethod("show", signature(object = "apeBootstrap"),
          function(object) {
              cat("'apeBoot' S4 object that stored bootstrap value generated by 'ape::boot.phylo'", ".\n\n")
              cat("...@ tree: ")
              print.phylo(get.tree(object))                  
          })




##' @rdname groupClade-methods
##' @exportMethod groupClade
setMethod("groupClade", signature(object="apeBootstrap"),
          function(object, node, group_name="group") {
              groupClade_(object, node, group_name)
          })

##' @rdname scale_color-methods
##' @exportMethod scale_color
setMethod("scale_color", signature(object="apeBootstrap"),
          function(object, by="bootstrap", ...) {
              scale_color_(object, by, ...)
          })


##' @rdname get.fields-methods
##' @exportMethod get.fields
setMethod("get.fields", signature(object="apeBootstrap"),
          function(object, ...) {
              get.fields.tree(object)
          }
          )