ropensci / beautier

R package to generate the same BEAST2 XML parameter files as generated by BEAUti 2
https://docs.ropensci.org/beautier
GNU General Public License v3.0
13 stars 2 forks source link

Add `rate_scaler_factor` to have `scaleFactor` in XML #139

Closed richelbilderbeek closed 1 year ago

richelbilderbeek commented 1 year ago

Allow this to work:

  expect_true(
    is_strict_clock_model(
      create_strict_clock_model(
        rate_scaler_factor = 0.75
      )
    )
  )

with

create_strict_clock_rate_scaler_operator_xml <- function(inference_model) { # nolint indeed a long function name
  beautier::check_inference_model(inference_model)
  clock_model <- inference_model$clock_model
  testthat::expect_true(beautier::is_strict_clock_model(clock_model))
  id <- clock_model$id
  testthat::expect_true(beautier::is_id(id))
  xml <- paste0(
    "<operator id=\"StrictClockRateScaler.c:", id, "\" ",
    "spec=\"ScaleOperator\" parameter=\"@clockRate.c:", id, "\" "
  )
  if (inference_model$beauti_options$beast2_version != "2.6") {
    xml <- paste0(xml, "scaleFactor=\"0.75\" ")
  }
  xml <- paste0(xml, "weight=\"3.0\"/>")
  xml
}
richelbilderbeek commented 1 year ago

Done!