Skip to content

Commit 5bf43ef

Browse files
authored
Merge pull request #1671 from virtualcell/fix-particle-math-mapping-mafunc-npe
Fix NPE in ParticleMathMapping for non-mass-action kinetics
2 parents f54c924 + 0da8350 commit 5bf43ef

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

vcell-core/src/main/java/cbit/vcell/mapping/ParticleMathMapping.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,11 @@ else if(rp instanceof Product)
729729
{
730730
maFunc = (MassActionStochasticFunction)stochasticFunction;
731731
}
732-
if ((maFunc.forwardRate() == null && maFunc.reverseRate() == null))
732+
// transformToStochastic falls back to GeneralKineticsStochasticFunction
733+
// when the rate law can't be reduced to mass-action form (e.g. Hill /
734+
// Michaelis-Menten kinetics). Particle math mapping requires mass-action
735+
// shape, so report the same error in either case rather than NPE.
736+
if (maFunc == null || (maFunc.forwardRate() == null && maFunc.reverseRate() == null))
733737
{
734738
throw new MappingException("Cannot generate stochastic math mapping for the reaction:" + reactionStep.getName() + "\nLooking for the rate function according to the form of k1*Reactant1^Stoir1*Reactant2^Stoir2...-k2*Product1^Stoip1*Product2^Stoip2.");
735739
}

0 commit comments

Comments
 (0)