Search in sources :

Example 21 with ASTNode

use of org.sbml.jsbml.ASTNode 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

ASTNode (org.sbml.jsbml.ASTNode)21 Expression (cbit.vcell.parser.Expression)17 InteriorPoint (org.sbml.jsbml.ext.spatial.InteriorPoint)13 ExpressionException (cbit.vcell.parser.ExpressionException)11 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)8 BioModel (cbit.vcell.biomodel.BioModel)7 Model (cbit.vcell.model.Model)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 AssignmentRule (org.sbml.jsbml.AssignmentRule)7 SBMLException (org.sbml.jsbml.SBMLException)7 ModelParameter (cbit.vcell.model.Model.ModelParameter)6 PropertyVetoException (java.beans.PropertyVetoException)6 StructureMapping (cbit.vcell.mapping.StructureMapping)5 SpeciesContext (cbit.vcell.model.SpeciesContext)5 XmlParseException (cbit.vcell.xml.XmlParseException)5 IOException (java.io.IOException)5 Compartment (org.sbml.jsbml.Compartment)5 Kinetics (cbit.vcell.model.Kinetics)4 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)4 ModelPropertyVetoException (cbit.vcell.model.ModelPropertyVetoException)4