R/mrca_prior_to_xml_state.R

Defines functions mrca_prior_to_xml_state

#' Creates the XML of an MRCA prior,
#'   as used in the \code{state} section
#' @inheritParams default_params_doc
#' @return the tree prior as XML text
#' @author Richèl J.C. Bilderbeek
#' @noRd
mrca_prior_to_xml_state <- function(
  mrca_prior,
  has_non_strict_clock_model = FALSE
) {
  testit::assert(is_mrca_prior(mrca_prior)) # nolint beautier function
  if (mrca_prior$is_monophyletic == FALSE &&
      is_one_na(mrca_prior$mrca_distr)) return(NULL) # nolint beautier function
  if (mrca_prior$is_monophyletic == TRUE &&
    is_one_na(mrca_prior$mrca_distr)) return(NULL) # nolint beautier function
  if (!has_non_strict_clock_model) {
    testit::assert(!is_one_na(mrca_prior$alignment_id)) # nolint beautier function
    paste0(
      "<parameter ",
      "id=\"clockRate.c:", mrca_prior$alignment_id, "\" ",
      "name=\"stateNode\">1.0</parameter>"
    )
  }
}
ropensci/beautier documentation built on March 12, 2019, 8:27 p.m.