diff --git a/NAMESPACE b/NAMESPACE index 0cb4e1200..6e97296b3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -55,6 +55,7 @@ export(getAllParametersForSensitivityAnalysisMatching) export(getAllParametersMatching) export(getAllQuantitiesMatching) export(getAllQuantityPathsIn) +export(getAllStateVariablesPaths) export(getBaseUnit) export(getContainer) export(getDimensionForUnit) diff --git a/R/create-population.R b/R/create-population.R index c8c7517e3..7092979f9 100644 --- a/R/create-population.R +++ b/R/create-population.R @@ -19,16 +19,16 @@ createPopulation <- function(populationCharacteristics) { # NOTE THIS IS A WORKAROUND UNTIL THE CODE IN PKSIM IS UPDATED if (populationCharacteristics$species == Species$Human) { - # create an individual with similar properties Species and population. WEIGHT AND AGE DO NOT MATTER as long as we can create an invidiual - individualCharacteristics <- ospsuite::createIndividualCharacteristics( + # create an individual with similar properties Species and population. WEIGHT AND AGE DO NOT MATTER as long as we can create an invdiviual + individualCharacteristics <- createIndividualCharacteristics( species = populationCharacteristics$species, population = populationCharacteristics$population, age = 30 ) } else { - # create an individual with similar properties Species and population. WEIGHT AND AGE DO NOT MATTER as long as we can create an invidiual - individualCharacteristics <- ospsuite::createIndividualCharacteristics( + # create an individual with similar properties Species and population. WEIGHT AND AGE DO NOT MATTER as long as we can create an indiviual + individualCharacteristics <- createIndividualCharacteristics( species = populationCharacteristics$species, population = populationCharacteristics$population, ) diff --git a/R/utilities-simulation.R b/R/utilities-simulation.R index ca9f10679..2628d4b38 100644 --- a/R/utilities-simulation.R +++ b/R/utilities-simulation.R @@ -425,6 +425,22 @@ getAllParametersForSensitivityAnalysisMatching <- function(paths, simulation) { ) } +#' Get the paths of all state variable quantities of the simulation +#' +#' @param simulation \code{Simulation} object +#' @details List of paths of all molecules in all compartments and all parameters that are +#' state variables. +#' +#' @return A list of paths +#' @export +getAllStateVariablesPaths <- function(simulation) { + validateIsOfType(simulation, type = Simulation) + allMoleculesPaths <- getAllMoleculePathsIn(container = simulation) + allStateVariableParamsPaths <- getAllEntityPathsIn(container = simulation, entityType = Parameter, method = "AllStateVariableParameterPathsIn") + allQantitiesPaths <- append(allMoleculesPaths, allStateVariableParamsPaths) + return(allQantitiesPaths) +} + #' Export simulation PKMLs for given `individualIds`. Each pkml file will contain the orginial simulation updated with parameters of the corresponding individual. #' #' @param population A population object typically loaded with `loadPopulation` diff --git a/man/getAllStateVariablesPaths.Rd b/man/getAllStateVariablesPaths.Rd new file mode 100644 index 000000000..d679cc9b6 --- /dev/null +++ b/man/getAllStateVariablesPaths.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utilities-simulation.R +\name{getAllStateVariablesPaths} +\alias{getAllStateVariablesPaths} +\title{Get the paths of all state variable quantities of the simulation} +\usage{ +getAllStateVariablesPaths(simulation) +} +\arguments{ +\item{simulation}{\code{Simulation} object} +} +\value{ +A list of paths +} +\description{ +Get the paths of all state variable quantities of the simulation +} +\details{ +List of paths of all molecules in all compartments and all parameters that are +state variables. +} diff --git a/tests/testthat/test-utilities-simulation.R b/tests/testthat/test-utilities-simulation.R index 82f7d2188..85d47fb4b 100644 --- a/tests/testthat/test-utilities-simulation.R +++ b/tests/testthat/test-utilities-simulation.R @@ -340,3 +340,10 @@ test_that("It can run multiple simulation batches with multiple parameters and m expect_equal(names(res[[2]])[[2]], ids[[4]]) }) +context("getAllStateVariablesPaths") + +test_that("It returns the correct paths of the state variables", { + sim <- loadTestSimulation(simulationName = "simple", loadFromCache = FALSE) + stateVariablePaths <- getAllStateVariablesPaths(simulation = sim) + expect_equal(length(stateVariablePaths), 5) +})