Skip to content

Commit

Permalink
Merge pull request #1161 from sys-bio/fix_the_issue_with_calculating_…
Browse files Browse the repository at this point in the history
…steady_state_changes_the_selection_vector_update

Steady state selection vector can now be updated by the user
  • Loading branch information
luciansmith committed Nov 13, 2023
2 parents 4746b7e + 27ad572 commit 5b94b55
Show file tree
Hide file tree
Showing 4 changed files with 430 additions and 5 deletions.
8 changes: 4 additions & 4 deletions source/rrRoadRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ namespace rr {
}

//Create a defualt steady state selectionlist
if (!createDefaultSteadyStateSelectionList()) {
if ((impl->loadOpt.loadFlags & LoadSBMLOptions::NO_DEFAULT_STEADY_STATE_SELECTIONS) == 0 && !createDefaultSteadyStateSelectionList()) {
rrLog(lDebug) << "Failed creating default steady state selectionList.";
result = false;
} else {
Expand Down Expand Up @@ -3276,7 +3276,7 @@ namespace rr {
if (!impl->model) {
throw CoreException(gEmptyModelMessage);
}
if (impl->mSteadyStateSelection.size() == 0) {
if ((impl->loadOpt.loadFlags & LoadSBMLOptions::NO_DEFAULT_STEADY_STATE_SELECTIONS) == 0) {
createDefaultSteadyStateSelectionList();
}

Expand All @@ -3303,7 +3303,7 @@ namespace rr {
if (!impl->model) {
throw CoreException(gEmptyModelMessage);
}
if (impl->mSteadyStateSelection.size() == 0) {
if ((impl->loadOpt.loadFlags & LoadSBMLOptions::NO_DEFAULT_STEADY_STATE_SELECTIONS) == 0) {
createDefaultSteadyStateSelectionList();
}

Expand Down Expand Up @@ -4822,7 +4822,7 @@ namespace rr {
for (int i = 0; i < ss.size(); ++i) {
impl->mSteadyStateSelection.push_back(createSelection(ss[i]));
}
impl->loadOpt.loadFlags = impl->loadOpt.loadFlags | LoadSBMLOptions::NO_DEFAULT_SELECTIONS;
impl->loadOpt.loadFlags = impl->loadOpt.loadFlags | LoadSBMLOptions::NO_DEFAULT_STEADY_STATE_SELECTIONS;
}

void RoadRunner::setSteadyStateSelections(const std::vector<rr::SelectionRecord> &ss) {
Expand Down
7 changes: 6 additions & 1 deletion source/rrRoadRunnerOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ namespace rr
/**
* Do not create a default selection list when the model is loaded.
*/
NO_DEFAULT_SELECTIONS = (0x1 << 0) // => 0x00000001
NO_DEFAULT_SELECTIONS = (0x1 << 0), // => 0x00000001

/**
* Do not create a default steady state selection list when the model is loaded.
*/
NO_DEFAULT_STEADY_STATE_SELECTIONS = (0x1 << 1) // => 0x00000010
};

/**
Expand Down
11 changes: 11 additions & 0 deletions test/cxx_api_tests/SelectionRecordTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,14 @@ TEST_F(SelectionRecordTests, AllIDs) {
}
}
}

TEST_F(SelectionRecordTests, MODIFY_STEADY_STATE_SELECTIONS_LIST) {
RoadRunner rr((rrTestModelsDir_ / "ModelAnalysis" / "long_selection_record.xml").string());
std::string users_favorite_steady_state_selection_record = "x0";
std::vector<std::string> steadyStateSelectionRecordStrings;
steadyStateSelectionRecordStrings.push_back(users_favorite_steady_state_selection_record);
rr.setSteadyStateSelections(steadyStateSelectionRecordStrings);
std::vector<SelectionRecord> steadyStateSelectionRecords = rr.getSteadyStateSelections();
EXPECT_EQ(steadyStateSelectionRecords.size(), 1);
EXPECT_EQ(steadyStateSelectionRecords.front().p1, users_favorite_steady_state_selection_record);
}

0 comments on commit 5b94b55

Please sign in to comment.