Fix OverdeterminationValidator for L3V2 rateOf csymbol #276
+156
−31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
###Summary
Fixes #138 .
In SBML Level 3 Version 2, rateOf csymbols can target a reaction identifier. The OverdeterminationValidator was not correctly taking these references into account because, in some cases, the ASTNode for the identifier has no variable set, and the identifier was therefore ignored when building the bipartite graph. This could cause overdetermined models involving rateOf(reactionId) to go undetected.
Changes
which resolves an identifier string to the corresponding SBase in the model (Species, Compartment, Parameter, or Reaction).
to:
First use node.getVariable() as before.
If getVariable() returns null (which can happen for identifiers used under a rateOf csymbol in L3V2), fall back to resolveSBaseFromId(node.getName()).
Preserve existing behavior for:
excluding local parameters
special Level 1 parameter insertion ordering
ignoring time and Avogadro symbols.
As a result, algebraic rules whose MathML uses rateOf(reactionId) now correctly link to the corresponding reaction node in the validator’s bipartite graph.
Added core/test/org/sbml/jsbml/validator/OverdeterminationValidatorTest.java.
New test:
testGetVariablesResolvesReactionIdWhenVariableNotSet()Builds a minimal L3V2 model with a single reaction R1.
Creates an ASTNode that refers to "R1" by name, without setting its variable (mimicking the situation for rateOf targets).
Invokes the private getVariables(...) method via reflection.
Asserts that the resulting variable list contains the reaction R1.
Testing
On this branch I ran:
mvn -pl core -am -DskipTests install
mvn -pl core test
Both complete with BUILD SUCCESS. No changes were made to project POMs or external dependencies.