Skip to content

Commit

Permalink
- issue 3265: if we discover an invalid reaction, flag it as error n…
Browse files Browse the repository at this point in the history
…ot exception
  • Loading branch information
fbergmann committed Oct 29, 2024
1 parent 5fb9184 commit f03d54c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions copasi/sbml/SBMLImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ void ensureAllArgsAreBeingUsedInFunctionDefinition(const FunctionDefinition* sbm
for (unsigned int i = 0; i < sbmlFunction->getNumArguments(); ++i)
str << sbmlFunction->getArgument(i)->getName() << ", ";

char* formula = SBML_formulaToString(sbmlFunction->getBody());
char* formula = SBML_formulaToL3String(sbmlFunction->getBody());
str << formula;

std::vector<std::string>::iterator it;
Expand All @@ -1282,7 +1282,7 @@ void ensureAllArgsAreBeingUsedInFunctionDefinition(const FunctionDefinition* sbm
str << ")";

// update the function definition
const_cast<FunctionDefinition*>(sbmlFunction)->setMath(SBML_parseFormula(str.str().c_str()));
const_cast<FunctionDefinition*>(sbmlFunction)->setMath(SBML_parseL3Formula(str.str().c_str()));

// free the formula
free(formula);
Expand Down Expand Up @@ -2322,7 +2322,7 @@ SBMLImporter::createCReactionFromReaction(Reaction* sbmlReaction, Model* pSBMLMo
/* Create a new user defined CKinFunction */
if (!sbmlId2CopasiCN(node, copasi2sbmlmap, copasiReaction->getParameters(), sbmlReaction))
{
CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 27, copasiReaction->getObjectName().c_str());
CCopasiMessage(CCopasiMessage::ERROR, MCSBML + 27, copasiReaction->getObjectName().c_str());
}

CEvaluationNode* pExpressionTreeRoot = CEvaluationTree::fromAST(node, false);
Expand Down Expand Up @@ -2565,6 +2565,13 @@ SBMLImporter::createCReactionFromReaction(Reaction* sbmlReaction, Model* pSBMLMo
copasiReaction->isReversible() ? TriTrue : TriFalse))
{
pNonconstFun->setReversible(TriUnspecified);

if (pNonconstFun->getInfix() == "@")
{
// set infix to something more usable which even though
// invalid, may help others to fix this
pNonconstFun->setInfix(SBML_formulaToL3String(kLawMath));
}
}

if (CRootContainer::getFunctionList()->loadedFunctions().size() > ExistingFunctions)
Expand Down Expand Up @@ -7577,7 +7584,7 @@ void SBMLImporter::replaceDelayAndRateOfInReaction(ConverterASTNode * pASTNode,

void SBMLImporter::replaceUnsupportedNodeInKinetic(CNodeIterator< ConverterASTNode >& itNode, std::map< std::string, std::string > & map, std::string prefix, Model * pModel, std::map< const CDataObject *, SBase * > & copasi2sbmlmap, Reaction * pSBMLReaction, std::map< std::string, std::string > & localReplacementMap)
{
std::string formula = SBML_formulaToString(*itNode);
std::string formula = SBML_formulaToL3String(*itNode);
std::map< std::string, std::string >::const_iterator pos = map.find(formula);
std::string replacementId;

Expand Down

0 comments on commit f03d54c

Please sign in to comment.