Search in sources :

Example 6 with EventAssignment

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);
    }
}
Also used : ReservedVariable(cbit.vcell.math.ReservedVariable) Variable(cbit.vcell.math.Variable) EventAssignment(cbit.vcell.math.Event.EventAssignment) Delay(org.sbml.jsbml.Delay) Trigger(org.sbml.jsbml.Trigger) Expression(cbit.vcell.parser.Expression) ASTNode(org.sbml.jsbml.ASTNode) Event(cbit.vcell.math.Event)

Aggregations

EventAssignment (cbit.vcell.math.Event.EventAssignment)6 Expression (cbit.vcell.parser.Expression)4 Element (org.jdom.Element)4 BioEvent (cbit.vcell.mapping.BioEvent)3 Event (cbit.vcell.math.Event)3 Delay (cbit.vcell.math.Event.Delay)3 Variable (cbit.vcell.math.Variable)3 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)2 ReservedVariable (cbit.vcell.math.ReservedVariable)2 VolVariable (cbit.vcell.math.VolVariable)2 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)2 ArrayList (java.util.ArrayList)2 BioEventParameterType (cbit.vcell.mapping.BioEvent.BioEventParameterType)1 TriggerType (cbit.vcell.mapping.BioEvent.TriggerType)1 FilamentRegionVariable (cbit.vcell.math.FilamentRegionVariable)1 FilamentVariable (cbit.vcell.math.FilamentVariable)1 InsideVariable (cbit.vcell.math.InsideVariable)1 MathDescription (cbit.vcell.math.MathDescription)1 MemVariable (cbit.vcell.math.MemVariable)1 MembraneParticleVariable (cbit.vcell.math.MembraneParticleVariable)1