
Update model ID (run number) in the control stream
Source:R/copy-model-helpers.R
update_model_id.RdHelper to update the model ID (aka the "run number" if models are named
numerically) in the new control stream of a model created with
copy_model_from(). See Details section.
Usage
update_model_id(
.mod,
.suffixes = c(".msf", ".ext", ".tab", ".chn", "par.tab"),
.additional_suffixes = NULL
)Arguments
- .mod
The
bbi_nonmem_modelobject associated with the control stream that will be modified.- .suffixes
Character vector of suffixes to be matched for replacement. Matching is case insensitive (see Details). Note that if passed suffixes are file extensions, you must include the leading period (e.g. pass
".tab"instead of"tab"). This is to enable passing things like"par.tab"which should (and will) match{parent_mod}par.tabbut not{parent_mod}.par.tab.- .additional_suffixes
Character vector of suffices to match in addition to those passed in
.suffixes.NULLby default. This is useful if you want to use the defaults for.suffixes, but also add new ones, as opposed to replacing the defaults. Also, see note in.suffixesabout file extensions.
Value
Invisibly returns .mod, to enable piping (i.e. from
copy_model_from())
Details
This function updates all occurrences of the model ID from
the parent model and replaces them with model ID from the
new model. Importantly, it relies on the assumption that .mod will have the parent model ID as
the first entry in .mod$based_on. This will be true if .mod was created by
copy_model_from().
It will look for that parent model ID before all strings
passed to .suffixes or .additional_suffixes (e.g. {parent_mod}.MSF, etc.)
replace it with get_model_id(.mod) wherever found.
.suffixes defaults to the following:
.msf.ext.chn.tabpar.tab
All matches are not case sensitive but replacements are. For example, if
.msf is passed as a suffix, {parent_mod}.MSF and {parent_mod}.msf would
both be replaced, but the case of the suffix in the control stream will be
maintained as is.