Skip to content

Commit

Permalink
getting there
Browse files Browse the repository at this point in the history
  • Loading branch information
skeating committed Jan 30, 2025
1 parent c4a131d commit 6d1a2b2
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 77 deletions.
20 changes: 17 additions & 3 deletions src/sbml/conversion/ExpressionAnalyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void ExpressionAnalyser::identifyHiddenSpeciesWithinExpressions()
}
}
}
substituteNodes();
//substituteNodes();
}

void ExpressionAnalyser::substituteParameters(SubstitutionValues_t* exp)
Expand Down Expand Up @@ -691,7 +691,7 @@ void ExpressionAnalyser::orderExpressions()
}

void
ExpressionAnalyser::detectHiddenSpecies()
ExpressionAnalyser::detectHiddenSpecies(bool testing)
{
mExpressions.clear();

Expand All @@ -703,6 +703,10 @@ ExpressionAnalyser::detectHiddenSpecies()
//}
orderExpressions();
identifyHiddenSpeciesWithinExpressions();
if (!testing)
{
substituteNodes();
}
}

/*
Expand Down Expand Up @@ -766,8 +770,9 @@ void ExpressionAnalyser::substituteNodes()
for (unsigned int i = 0; i < mExpressions.size(); i++)
{
SubstitutionValues_t* exp = mExpressions.at(i);
replaceExpressionInNodeWithNode(exp->current, exp->z_expression, getODE(exp->odeIndex)); //getODEFor(exp->current);
replaceExpressionInNodeWithNode(getODE(exp->odeIndex), exp->current, exp->z_expression); //getODEFor(exp->current);
cout << "node: " << SBML_formulaToL3String(getODE(exp->odeIndex)) << endl;
addParametersAndRateRules(exp);
}
}

Expand All @@ -776,6 +781,7 @@ void
ExpressionAnalyser::addParametersAndRateRules(SubstitutionValues_t* exp)
{
if (exp->z_value.empty()) return;
if (mHiddenSpecies == NULL) mHiddenSpecies = new List();
//for (unsigned int i = 0; i < mExpressions.size(); i++)
//{
// SubstitutionValues_t *exp = mExpressions.at(i);
Expand Down Expand Up @@ -947,6 +953,14 @@ ExpressionAnalyser::replaceExpressionWithNewParameter(ASTNode* ode, Substitution
}
}

unsigned int ExpressionAnalyser::getNumHiddenNodes()
{
if (mHiddenNodes == NULL)
return 0;
else
return mHiddenNodes->getSize();
}


/*
* Have we already created a parameter for this expression
Expand Down
6 changes: 4 additions & 2 deletions src/sbml/conversion/ExpressionAnalyser.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,16 @@ class LIBSBML_EXTERN ExpressionAnalyser
*/
unsigned int getNumHiddenSpecies();

unsigned int getNumHiddenNodes();


// need a function to get hidden species by index
// TODO

/**
* Function to work through all the expressions and detect hidden species
*/
void detectHiddenSpecies();
void detectHiddenSpecies(bool testing = false);

/**
* Function to create a blank substitution value
Expand Down Expand Up @@ -407,7 +410,6 @@ class LIBSBML_EXTERN ExpressionAnalyser

void replaceExpressionWithNewParameter(ASTNode* ode, SubstitutionValues_t* exp);


// member variables populated during analysis
pairODEs mODEs;

Expand Down
1 change: 1 addition & 0 deletions src/sbml/conversion/SBMLRateRuleConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ SBMLRateRuleConverter::populateODEinfo()


ea->detectHiddenSpecies();

// add all hidden species to the model
for (unsigned int hs=0; hs < ea->getNumHiddenSpecies(); hs++)
{
Expand Down
Loading

0 comments on commit 6d1a2b2

Please sign in to comment.