Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getAllStateVariablesPaths #526

Merged
merged 3 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export(getAllParametersForSensitivityAnalysisMatching)
export(getAllParametersMatching)
export(getAllQuantitiesMatching)
export(getAllQuantityPathsIn)
export(getAllStateVariablesPaths)
export(getBaseUnit)
export(getContainer)
export(getDimensionForUnit)
Expand Down
8 changes: 4 additions & 4 deletions R/create-population.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
16 changes: 16 additions & 0 deletions R/utilities-simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
21 changes: 21 additions & 0 deletions man/getAllStateVariablesPaths.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/testthat/test-utilities-simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})