use of cbit.vcell.math.Event.EventAssignment in project vcell by virtualcell.
the class MathModel_SBMLExporter method addSbmlEvent.
protected static void addSbmlEvent(Model sbmlModel, Event vcellMathEvent) {
org.sbml.jsbml.Event sbmlEvent = sbmlModel.createEvent();
sbmlEvent.setId(vcellMathEvent.getName());
// create trigger
Trigger trigger = sbmlEvent.createTrigger();
Expression triggerExpr = vcellMathEvent.getTriggerExpression();
//
// if trigger expression is not already in "boolean" form, then new expression is (exp != 0.0) ...nonzero is true.
//
ASTNode triggerMath = getFormulaFromExpression(triggerExpr, MathType.BOOLEAN);
trigger.setMath(triggerMath);
// create delay
cbit.vcell.math.Event.Delay vcellMathDelay = vcellMathEvent.getDelay();
if (vcellMathDelay != null && vcellMathDelay.getDurationExpression() != null && !vcellMathDelay.getDurationExpression().isZero()) {
Delay delay = sbmlEvent.createDelay();
Expression delayExpr = vcellMathDelay.getDurationExpression();
ASTNode delayMath = getFormulaFromExpression(delayExpr, MathType.REAL);
delay.setMath(delayMath);
sbmlEvent.setUseValuesFromTriggerTime(vcellMathDelay.useValuesFromTriggerTime());
}
// create eventAssignments
Iterator<EventAssignment> vcEventAssignments = vcellMathEvent.getEventAssignments();
while (vcEventAssignments.hasNext()) {
EventAssignment vcEventAssignment = vcEventAssignments.next();
org.sbml.jsbml.EventAssignment sbmlEA = sbmlEvent.createEventAssignment();
Variable target = vcEventAssignment.getVariable();
sbmlEA.setVariable(target.getName());
Expression eventAssgnExpr = new Expression(vcEventAssignment.getAssignmentExpression());
ASTNode eaMath = getFormulaFromExpression(eventAssgnExpr, MathType.REAL);
sbmlEA.setMath(eaMath);
}
}
Aggregations