Skip to content

Commit

Permalink
properly report different jumpprocesses in math description
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Nov 12, 2024
1 parent d53f86f commit 18b8c24
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public enum Decision {
MathDifferent_EQUATION_REMOVED(false,"MathDifferent:EquationRemoved"),
MathDifferent_UNKNOWN_DIFFERENCE_IN_EQUATION(false,"MathDifferent:UnknownDifferenceInEquation"),
MathDifferent_DIFFERENT_PARTICLE_PROPERTIES(false,"MathDifferent:DifferentParticleProperties"),
MathDifferent_DIFFERENT_NUMBER_OF_JUMP_PROCESS(false,"MathDifferent:DifferentNumJumpProcs"),
MathDifferent_DIFFERENT_JUMP_PROCESS(false,"MathDifferent:DifferentJumpProc"),
MathDifferent_DIFFERENT_NUMBER_OF_PARTICLE_JUMP_PROCESS(false,"MathDifferent:DifferentNumParticleJumpProcs"),
MathDifferent_DIFFERENT_PARTICLE_JUMP_PROCESS(false,"MathDifferent:DifferentParticleJumpProc"),
MathDifferent_LEGACY_RATE_PARTICLE_JUMP_PROCESS(false,"MathDifferent:LegacyRateParticleJumpProc"),
Expand Down
40 changes: 40 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/math/MathDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,46 @@ private MathCompareResults compareEquivalentCanonicalMath(MathDescription newMat
return new MathCompareResults(Decision.MathDifferent_DIFFERENT_PARTICLE_JUMP_PROCESS, msg);
}
}

//
// 1) get list of old and new JumpProcesses
// 2) filter out 'no-op' JPs (e.g. those only with trivial Actions such as open->open)
// 3) add trivial Symmetry factor (1.0) if missing
//
List<JumpProcess> oldJpList = subDomainsOld.get(i).getJumpProcesses();
List<JumpProcess> newJpList = subDomainsNew.get(i).getJumpProcesses();

if(oldJpList.size() != newJpList.size()){
Set<String> oldJpNameSet = oldJpList.stream().map(JumpProcess::getName).collect(Collectors.toSet());
Set<String> newJpNameSet = newJpList.stream().map(JumpProcess::getName).collect(Collectors.toSet());
Set<String> removedJpNames = new LinkedHashSet<>(oldJpNameSet);
removedJpNames.removeAll(newJpNameSet);
Set<String> addedPjpNames = new LinkedHashSet<>(newJpNameSet);
addedPjpNames.removeAll(oldJpNameSet);
String msg = "removed PJPs=" + removedJpNames + ", added PJPs=" + addedPjpNames;
logMathTexts(this, newMathDesc, Decision.MathDifferent_DIFFERENT_NUMBER_OF_JUMP_PROCESS, msg);
return new MathCompareResults(Decision.MathDifferent_DIFFERENT_NUMBER_OF_JUMP_PROCESS, msg);
}
for(JumpProcess oldJp : oldJpList){
boolean bEqual = false;
JumpProcess matchingJp = null;
for(JumpProcess newJp : newJpList){
if(Compare.isEqualOrNull(oldJp.getName(), newJp.getName())){
matchingJp = newJp;
if(oldJp.compareEqual(newJp)){
bEqual = true;
}
break;
}
}
if(!bEqual){
String oldExprList = Arrays.stream(oldJp.getExpressions()).map(Expression::infix).toList().toString();
String newExprList = ((matchingJp == null) ? "null" : Arrays.stream(matchingJp.getExpressions()).map(Expression::infix).toList().toString());
String msg = "JP='" + oldJp.getName() + "', " + "rate: " + "old='" + oldExprList + "', new='" + newExprList + "'";
logMathTexts(this, newMathDesc, Decision.MathDifferent_DIFFERENT_JUMP_PROCESS, msg);
return new MathCompareResults(Decision.MathDifferent_DIFFERENT_JUMP_PROCESS, msg);
}
}
}

//
Expand Down

0 comments on commit 18b8c24

Please sign in to comment.