Skip to content

Commit

Permalink
Merge branch 'master' into Container-deploy-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeByDrescher committed Nov 15, 2024
2 parents a6380cf + 09470a2 commit 796e148
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) {
}
}

/**
* Sets the geometry property (cbit.vcell.geometry.Geometry) value.
* @param geometry The new value for the property.
* @see #getGeometry
*/
public void setReactionRule(ReactionRule newValue) {
ReactionRule oldValue = reactionRule;
reactionRule = newValue;
Expand Down
140 changes: 73 additions & 67 deletions vcell-core/src/main/java/cbit/vcell/mapping/NetworkTransformer.java

Large diffs are not rendered by default.

43 changes: 35 additions & 8 deletions vcell-core/src/main/java/cbit/vcell/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,10 @@ public ReactionRule createReactionRule(String label, Structure structure, boolea
return new ReactionRule(Model.this, label, structure, bReversible);
}

public final void setObservableList(List<RbmObservable> newValue) throws PropertyVetoException{
public final void setObservableList(List<RbmObservable> newValue) throws PropertyVetoException {
setObservableList(newValue, PropertyNotificationMode.Loud);
}
public final void setObservableList(List<RbmObservable> newValue, PropertyNotificationMode mode) throws PropertyVetoException{
List<RbmObservable> oldValue = observableList;
fireVetoableChange(RbmModelContainer.PROPERTY_NAME_OBSERVABLE_LIST, oldValue, newValue);
if(oldValue != null){
Expand All @@ -1590,7 +1593,9 @@ public final void setObservableList(List<RbmObservable> newValue) throws Propert
mt.setModel(Model.this);
}
}
firePropertyChange(RbmModelContainer.PROPERTY_NAME_OBSERVABLE_LIST, oldValue, newValue);
if(mode == PropertyNotificationMode.Loud) {
firePropertyChange(RbmModelContainer.PROPERTY_NAME_OBSERVABLE_LIST, oldValue, newValue);
}
}

public List<MolecularType> getMolecularTypeList(){
Expand All @@ -1610,8 +1615,14 @@ public Parameter addFunction(String name, Expression expression, VCUnitDefinitio
return Model.this.addModelParameter(new ModelParameter(name, expression, ROLE_UserDefined, unitDefinition));
}

public Parameter addParameter(String name, Expression expression, VCUnitDefinition unitDefinition, PropertyNotificationMode mode) throws ModelException, PropertyVetoException {
ModelParameter mp = new ModelParameter(name, expression, ROLE_UserDefined, unitDefinition);
return Model.this.addModelParameter(mp, mode);

}
public Parameter addParameter(String name, Expression expression, VCUnitDefinition unitDefinition) throws ModelException, PropertyVetoException{
return Model.this.addModelParameter(new ModelParameter(name, expression, ROLE_UserDefined, unitDefinition));
Parameter ret = addParameter(name, expression, unitDefinition, PropertyNotificationMode.Loud);
return ret;
}

public RbmObservable getObservable(String obName){
Expand Down Expand Up @@ -1639,12 +1650,16 @@ public Parameter getParameter(String obName){
}

public boolean removeObservable(RbmObservable observable) throws PropertyVetoException{
boolean ret = removeObservable(observable, PropertyNotificationMode.Loud);
return ret;
}
public boolean removeObservable(RbmObservable observable, PropertyNotificationMode mode) throws PropertyVetoException{
if(!observableList.contains(observable)){
return false;
}
ArrayList<RbmObservable> newValue = new ArrayList<RbmObservable>(observableList);
newValue.remove(observable);
setObservableList(newValue);
setObservableList(newValue, mode);
return true;
}

Expand Down Expand Up @@ -1957,6 +1972,11 @@ public void adjustRulesPatterns(MolecularType mt, MolecularComponent mc){
}
}

public enum PropertyNotificationMode {
Silent,
Loud
}

public Model(Version argVersion){
this(argVersion, ModelUnitSystem.createDefaultVCModelUnitSystem());
}
Expand Down Expand Up @@ -2052,11 +2072,14 @@ private ReservedSymbol[] createReservedSymbols(){
// ModelParameter modelParameter = new ModelParameter(name, expr, role, units);
// return modelParameter;
//}

public ModelParameter addModelParameter(Model.ModelParameter modelParameter) throws PropertyVetoException{
ModelParameter ret = addModelParameter(modelParameter, PropertyNotificationMode.Loud);
return ret;
}
public ModelParameter addModelParameter(Model.ModelParameter modelParameter, PropertyNotificationMode mode) throws PropertyVetoException{
// if (!contains(modelParameter)){
Model.ModelParameter[] newModelParameters = ArrayUtils.addElement(fieldModelParameters, modelParameter);
setModelParameters(newModelParameters);
setModelParameters(newModelParameters, mode);
// }
return modelParameter;
}
Expand Down Expand Up @@ -3721,12 +3744,16 @@ public void setDiagrams(int index, Diagram diagrams){
;
}


public void setModelParameters(ModelParameter[] modelParameters) throws java.beans.PropertyVetoException{
setModelParameters(modelParameters, PropertyNotificationMode.Loud);
}
public void setModelParameters(ModelParameter[] modelParameters, PropertyNotificationMode mode) throws java.beans.PropertyVetoException{
ModelParameter[] oldValue = fieldModelParameters;
fireVetoableChange(Model.PROPERTY_NAME_MODEL_PARAMETERS, oldValue, modelParameters);
fieldModelParameters = modelParameters;
firePropertyChange(Model.PROPERTY_NAME_MODEL_PARAMETERS, oldValue, modelParameters);
if(mode == PropertyNotificationMode.Loud) {
firePropertyChange(Model.PROPERTY_NAME_MODEL_PARAMETERS, oldValue, modelParameters);
}

//System.out.print("vcModel model parameters [");
//for (ModelParameter p : oldValue){
Expand Down
25 changes: 21 additions & 4 deletions vcell-core/src/main/java/org/vcell/sbml/vcell/SBMLImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2975,18 +2975,35 @@ private static void addOutputFunctions(org.sbml.jsbml.Model sbmlModel, BioModel
private static void applySavedExpressions(org.sbml.jsbml.Model sbmlModel, SBMLSymbolMapping sbmlSymbolMapping, VCLogger vcLogger) throws Exception{
for(SBase sbmlValueTargetSbase : sbmlSymbolMapping.getSbmlValueTargets()){
Double sbmlValue = sbmlSymbolMapping.getSbmlValue(sbmlValueTargetSbase);
if(sbmlValue != null && !sbmlValue.isInfinite() && !sbmlValue.isNaN()){
final Expression sbmlValueExp;
if (sbmlValue != null) {
if (sbmlValue.isInfinite() && sbmlValue > 0) {
sbmlValueExp = new Expression(Double.MAX_VALUE);
logger.debug("setting infinite value for SBML id " + sbmlValueTargetSbase.getId() + " to " + Double.MAX_VALUE);
} else if (sbmlValue.isInfinite() && sbmlValue < 0){
sbmlValueExp = new Expression(-Double.MAX_VALUE);
logger.debug("setting infinite value for SBML id " + sbmlValueTargetSbase.getId() + " to " + -Double.MAX_VALUE);
} else if (sbmlValue.isNaN()){
sbmlValueExp = new Expression("0/0");
logger.debug("setting NaN value for SBML id " + sbmlValueTargetSbase.getId() + " to 0/0");
} else {
sbmlValueExp = new Expression(sbmlValue);
}
} else {
sbmlValueExp = null;
}
if(sbmlValueExp != null){
EditableSymbolTableEntry targetSte = sbmlSymbolMapping.getInitialSte(sbmlValueTargetSbase);
try {
if(targetSte != null){
if(targetSte.isExpressionEditable()){
targetSte.setExpression(new Expression(sbmlValue));
targetSte.setExpression(sbmlValueExp);
}
} else {
targetSte = sbmlSymbolMapping.getRuntimeSte(sbmlValueTargetSbase);
if(targetSte != null){
if(targetSte.isExpressionEditable()){
targetSte.setExpression(new Expression(sbmlValue));
targetSte.setExpression(sbmlValueExp);
}
} else {
logger.error("couldn't find vcell object mapped to sbml object: " + sbmlValueTargetSbase);
Expand All @@ -2998,7 +3015,7 @@ private static void applySavedExpressions(org.sbml.jsbml.Model sbmlModel, SBMLSy
vcLogger.sendMessage(VCLogger.Priority.HighPriority, VCLogger.ErrorType.OverallWarning, msg);
}
} else {
String msg = "missing or unexpected value attribute '" + sbmlValue + "' for SBML object id " + sbmlValueTargetSbase.getId();
String msg = "missing value attribute for SBML object id " + sbmlValueTargetSbase.getId();
logger.error(msg);
vcLogger.sendMessage(VCLogger.Priority.HighPriority, VCLogger.ErrorType.OverallWarning, msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static Map<Integer, SBMLTestSuiteTest.FAULT> knownFaults() {
faults.put(627, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_123' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that y
faults.put(628, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_8' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that you
faults.put(632, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'k4b' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that you have pro
faults.put(696, SBMLTestSuiteTest.FAULT.MATHML_PARSING); // cause: Error adding Lambda function UnsupportedConstruct: error parsing expression ' <math><notanumber/></math>': node type 'notanumber' not supported yet
faults.put(696, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_16' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that yo
faults.put(705, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_21' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that yo
faults.put(706, SBMLTestSuiteTest.FAULT.UNCATEGORIZED); // cause: found more than one SBase match for sid=v, matched [org.vcell.sbml.vcell.SBMLSymbolMapping$SBaseWrapper@67cc48df, org.vcell.sbml.vcell.SBMLSymbolMapping$SBaseWrapper@483ac21f]
faults.put(710, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_0_0' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that y
Expand All @@ -179,7 +179,6 @@ public static Map<Integer, SBMLTestSuiteTest.FAULT> knownFaults() {
faults.put(872, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'beta' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that you have pr
faults.put(908, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_2' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that you
faults.put(925, SBMLTestSuiteTest.FAULT.UNCATEGORIZED); // cause: OverallWarning: missing or unexpected value attribute '-Infinity' for SBML object id log_time
faults.put(952, SBMLTestSuiteTest.FAULT.MATHML_PARSING); // cause: Error adding Lambda function UnsupportedConstruct: error parsing expression ' <math><notanumber/></math>': node type 'notanumber' not supported yet
faults.put(956, SBMLTestSuiteTest.FAULT.MATHML_PARSING); // cause: Error adding Lambda function UnsupportedConstruct: error parsing expression ' <math><notanumber/></math>': node type 'notanumber' not supported yet
faults.put(961, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'rateOf_re15' to model: 're15' is either not found in your model or is not allowed to be used in the current context. Check that you have provided t
faults.put(969, SBMLTestSuiteTest.FAULT.EXPRESSION_BINDING_EXCEPTION); // cause: Error binding global parameter 'Metabolite_11' to model: 'UNRESOLVED.initConc' is either not found in your model or is not allowed to be used in the current context. Check that yo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ public static Collection<Integer> testCases() {
faults.put(943, FAULT.DELAY);
faults.put(945, FAULT.STRUCTURE_SIZE_IN_ASSIGNMENT_RULE);
faults.put(947, FAULT.STRUCTURE_SIZE_IN_ASSIGNMENT_RULE);
faults.put(950, FAULT.VALUE_NAN_INF_OR_MISSING);
faults.put(951, FAULT.VALUE_NAN_INF_OR_MISSING);
faults.put(957, FAULT.XOR_MISSING);
faults.put(958, FAULT.XOR_MISSING);
faults.put(959, FAULT.INCONSISTENT_UNIT_SYSTEM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,19 @@ private SimpleNode getRootNode(Element nodeMathML, String timeSymbol) throws Exp
} else {
throw new ExpressionException("csymbol node type "+nodeMathML.getAttributeValue(MathMLTags.DEFINITIONURL)+" not supported yet");
}
} else{
} else if (nodeMathML.getName().equals(MathMLTags.NOT_A_NUMBER)){
ASTFloatNode zeroNode = new ASTFloatNode(0.0);
ASTFloatNode zeroNode2 = new ASTFloatNode(0.0);
ASTInvertTermNode invNode = new ASTInvertTermNode();
invNode.jjtAddChild(zeroNode2);
ASTMultNode multNode = new ASTMultNode();
multNode.jjtAddChild(zeroNode);
multNode.jjtAddChild(invNode);
return multNode;
} else if (nodeMathML.getName().equals(MathMLTags.INFINITY)) {
ASTFloatNode infNode = new ASTFloatNode(Double.MAX_VALUE);
return infNode;
}else{
throw new ExpressionException("node type '"+nodeMathML.getName()+"' not supported yet");
}
}
Expand Down
20 changes: 20 additions & 0 deletions vcell-math/src/test/java/cbit/vcell/parser/MathMLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ public void testMathMLParsing_XOR() throws IOException, ExpressionException {
assertTrue(equiv, msg);
}

@Test
public void testNaN_MathmlParsing() throws ExpressionException {
String nanMathML = "<notanumber/>";
Expression exp = new ExpressionMathMLParser(null).fromMathML(nanMathML, "t");
Expression expectedExp = new Expression("0/0");
boolean equiv = ExpressionUtils.functionallyEquivalent(exp, expectedExp, true);
String msg = "not equivalent: origExp='"+exp.infix()+"', expMathML='"+expectedExp.infix()+"'";
assertTrue(equiv, msg);
}

@Test
public void testInfinity_MathmlParsing() throws ExpressionException {
String nanMathML = "<infinity/>";
Expression exp = new ExpressionMathMLParser(null).fromMathML(nanMathML, "t");
Expression expectedExp = new Expression(Double.MAX_VALUE);
boolean equiv = ExpressionUtils.functionallyEquivalent(exp, expectedExp, true);
String msg = "not equivalent: origExp='"+exp.infix()+"', expMathML='"+expectedExp.infix()+"'";
assertTrue(equiv, msg);
}


@ParameterizedTest
@MethodSource("testCases")
Expand Down

0 comments on commit 796e148

Please sign in to comment.