Search in sources :

Example 31 with LocalParameter

use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.

the class BioModelParametersTableModel method bioModelChange.

@Override
protected void bioModelChange(PropertyChangeEvent evt) {
    super.bioModelChange(evt);
    BioModel oldValue = (BioModel) evt.getOldValue();
    if (oldValue != null) {
        for (EditableSymbolTableEntry parameter : oldValue.getModel().getModelParameters()) {
            parameter.removePropertyChangeListener(this);
        }
        for (SpeciesContext sc : oldValue.getModel().getSpeciesContexts()) {
            sc.removePropertyChangeListener(this);
        }
        for (ReactionStep reactionStep : oldValue.getModel().getReactionSteps()) {
            reactionStep.removePropertyChangeListener(this);
            Kinetics kinetics = reactionStep.getKinetics();
            kinetics.removePropertyChangeListener(this);
            for (KineticsParameter kineticsEditableSymbolTableEntry : kinetics.getKineticsParameters()) {
                kineticsEditableSymbolTableEntry.removePropertyChangeListener(this);
            }
            for (ProxyParameter proxyEditableSymbolTableEntry : kinetics.getProxyParameters()) {
                proxyEditableSymbolTableEntry.removePropertyChangeListener(this);
            }
            for (UnresolvedParameter unresolvedEditableSymbolTableEntry : kinetics.getUnresolvedParameters()) {
                unresolvedEditableSymbolTableEntry.removePropertyChangeListener(this);
            }
        }
        for (SimulationContext simulationContext : oldValue.getSimulationContexts()) {
            simulationContext.removePropertyChangeListener(this);
            simulationContext.getGeometryContext().removePropertyChangeListener(this);
            for (StructureMapping mapping : simulationContext.getGeometryContext().getStructureMappings()) {
                mapping.removePropertyChangeListener(this);
                for (EditableSymbolTableEntry parameter : mapping.getParameters()) {
                    parameter.removePropertyChangeListener(this);
                }
            }
            simulationContext.getReactionContext().removePropertyChangeListener(this);
            for (SpeciesContextSpec spec : simulationContext.getReactionContext().getSpeciesContextSpecs()) {
                spec.removePropertyChangeListener(this);
                for (EditableSymbolTableEntry parameter : spec.getParameters()) {
                    parameter.removePropertyChangeListener(this);
                }
            }
            for (ElectricalStimulus elect : simulationContext.getElectricalStimuli()) {
                elect.removePropertyChangeListener(this);
                for (EditableSymbolTableEntry parameter : elect.getParameters()) {
                    parameter.removePropertyChangeListener(this);
                }
            }
            for (SpatialObject spatialObject : simulationContext.getSpatialObjects()) {
                spatialObject.removePropertyChangeListener(this);
            }
            for (SpatialProcess spatialProcess : simulationContext.getSpatialProcesses()) {
                spatialProcess.removePropertyChangeListener(this);
                for (LocalParameter p : spatialProcess.getParameters()) {
                    p.removePropertyChangeListener(this);
                }
            }
            for (SimulationContextParameter p : simulationContext.getSimulationContextParameters()) {
                p.removePropertyChangeListener(this);
            }
        }
    }
    BioModel newValue = (BioModel) evt.getNewValue();
    if (newValue != null) {
        for (ModelParameter modelEditableSymbolTableEntry : newValue.getModel().getModelParameters()) {
            modelEditableSymbolTableEntry.addPropertyChangeListener(this);
        }
        for (SpeciesContext sc : newValue.getModel().getSpeciesContexts()) {
            sc.addPropertyChangeListener(this);
        }
        for (ReactionStep reactionStep : newValue.getModel().getReactionSteps()) {
            reactionStep.addPropertyChangeListener(this);
            Kinetics kinetics = reactionStep.getKinetics();
            kinetics.addPropertyChangeListener(this);
            for (KineticsParameter kineticsEditableSymbolTableEntry : kinetics.getKineticsParameters()) {
                kineticsEditableSymbolTableEntry.addPropertyChangeListener(this);
            }
            for (ProxyParameter proxyEditableSymbolTableEntry : kinetics.getProxyParameters()) {
                proxyEditableSymbolTableEntry.addPropertyChangeListener(this);
            }
            for (UnresolvedParameter unresolvedEditableSymbolTableEntry : kinetics.getUnresolvedParameters()) {
                unresolvedEditableSymbolTableEntry.addPropertyChangeListener(this);
            }
        }
        for (SimulationContext simulationContext : newValue.getSimulationContexts()) {
            simulationContext.addPropertyChangeListener(this);
            simulationContext.getGeometryContext().addPropertyChangeListener(this);
            for (StructureMapping mapping : simulationContext.getGeometryContext().getStructureMappings()) {
                mapping.addPropertyChangeListener(this);
                for (EditableSymbolTableEntry parameter : mapping.getParameters()) {
                    parameter.addPropertyChangeListener(this);
                }
            }
            simulationContext.getReactionContext().addPropertyChangeListener(this);
            for (SpeciesContextSpec spec : simulationContext.getReactionContext().getSpeciesContextSpecs()) {
                spec.addPropertyChangeListener(this);
                for (EditableSymbolTableEntry parameter : spec.getParameters()) {
                    parameter.addPropertyChangeListener(this);
                }
            }
            for (ElectricalStimulus elect : simulationContext.getElectricalStimuli()) {
                elect.addPropertyChangeListener(this);
                for (EditableSymbolTableEntry parameter : elect.getParameters()) {
                    parameter.addPropertyChangeListener(this);
                }
            }
            for (SpatialObject spatialObject : simulationContext.getSpatialObjects()) {
                spatialObject.addPropertyChangeListener(this);
            }
            for (SpatialProcess spatialProcess : simulationContext.getSpatialProcesses()) {
                spatialProcess.addPropertyChangeListener(this);
                for (LocalParameter p : spatialProcess.getParameters()) {
                    p.addPropertyChangeListener(this);
                }
            }
            for (SimulationContextParameter p : simulationContext.getSimulationContextParameters()) {
                p.addPropertyChangeListener(this);
            }
        }
    }
}
Also used : UnresolvedParameter(cbit.vcell.model.Kinetics.UnresolvedParameter) SpeciesContext(cbit.vcell.model.SpeciesContext) SimulationContext(cbit.vcell.mapping.SimulationContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) StructureMapping(cbit.vcell.mapping.StructureMapping) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) ModelParameter(cbit.vcell.model.Model.ModelParameter) ProxyParameter(cbit.vcell.model.ProxyParameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) BioModel(cbit.vcell.biomodel.BioModel) ReactionStep(cbit.vcell.model.ReactionStep) Kinetics(cbit.vcell.model.Kinetics) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry)

Example 32 with LocalParameter

use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.

the class RbmNetworkGenerator method writeBngl_internal.

public static void writeBngl_internal(SimulationContext simulationContext, PrintWriter writer, Map<FakeReactionRuleRateParameter, LocalParameter> kineticsParameterMap, Map<FakeSeedSpeciesInitialConditionsParameter, Pair<SpeciesContext, Expression>> speciesEquivalenceMap, NetworkGenerationRequirements networkGenerationRequirements, CompartmentMode compartmentMode) {
    String callerClassName = new Exception().getStackTrace()[1].getClassName();
    String networkTransformerClassName = NetworkTransformer.class.getName();
    String rulebasedTransformerClassName = RulebasedTransformer.class.getName();
    if (!callerClassName.equals(networkTransformerClassName) && !callerClassName.equals(rulebasedTransformerClassName)) {
        throw new UnsupportedOperationException("This method may only be called from within a " + networkTransformerClassName + " or " + rulebasedTransformerClassName + " instance.");
    }
    Model model = simulationContext.getModel();
    RbmModelContainer rbmModelContainer = model.getRbmModelContainer();
    checkConsistency(model);
    // first we prepare the fake parameters we need to maintain the relationship between the species context and the seed species
    List<FakeSeedSpeciesInitialConditionsParameter> fakeParameterList = new ArrayList<FakeSeedSpeciesInitialConditionsParameter>();
    List<String> seedSpeciesList = new ArrayList<String>();
    SpeciesContext[] speciesContexts = model.getSpeciesContexts();
    for (int i = 0; i < speciesContexts.length; i++) {
        SpeciesContext sc = speciesContexts[i];
        if (!sc.hasSpeciesPattern()) {
            continue;
        }
        SpeciesContextSpec scs = simulationContext.getReactionContext().getSpeciesContextSpec(sc);
        Expression initialConcentration = scs.getParameter(SpeciesContextSpec.ROLE_InitialConcentration).getExpression();
        // fake initial values for the seed species, we need to present them to bngl as parameters
        FakeSeedSpeciesInitialConditionsParameter fakeSeedSpeciesParam = new FakeSeedSpeciesInitialConditionsParameter(sc.getName());
        Pair<SpeciesContext, Expression> p = new Pair<SpeciesContext, Expression>(sc, initialConcentration);
        speciesEquivalenceMap.put(fakeSeedSpeciesParam, p);
        String modified;
        if (compartmentMode == CompartmentMode.show) {
            modified = RbmUtils.toBnglString(sc.getSpeciesPattern(), null, CompartmentMode.hide, 0);
            modified = "@" + sc.getStructure().getName() + ":" + modified;
        } else if (compartmentMode == CompartmentMode.asSite) {
            modified = RbmUtils.toBnglString(sc.getSpeciesPattern(), sc.getStructure(), CompartmentMode.asSite, 0);
        } else {
            // CompartmentMode.hide
            modified = RbmUtils.toBnglString(sc.getSpeciesPattern(), null, CompartmentMode.hide, 0);
        }
        modified += " " + fakeSeedSpeciesParam.fakeParameterName;
        // we label the seed species with the index
        modified = (i + 1) + " " + modified;
        // we build the seed species list now, we write it later (in the BEGIN SPECIES block)
        seedSpeciesList.add(modified);
        fakeParameterList.add(fakeSeedSpeciesParam);
    }
    // second we produce the bngl file
    writer.println(BEGIN_MODEL);
    writer.println();
    for (ReactionRuleSpec rrs : simulationContext.getReactionContext().getReactionRuleSpecs()) {
        if (!rrs.isExcluded()) {
            ReactionRule reactionRule = rrs.getReactionRule();
            RbmKineticLaw kineticLaw = reactionRule.getKineticLaw();
            switch(kineticLaw.getRateLawType()) {
                case MassAction:
                    {
                        FakeReactionRuleRateParameter fakeRateParameterForward = new FakeReactionRuleRateParameter(reactionRule, RbmKineticLawParameterType.MassActionForwardRate);
                        LocalParameter origForwardRateParameter = kineticLaw.getLocalParameter(RbmKineticLawParameterType.MassActionForwardRate);
                        kineticsParameterMap.put(fakeRateParameterForward, origForwardRateParameter);
                        if (reactionRule.isReversible()) {
                            FakeReactionRuleRateParameter fakeRateParameterReverse = new FakeReactionRuleRateParameter(reactionRule, RbmKineticLawParameterType.MassActionReverseRate);
                            LocalParameter origReverseRateParameter = kineticLaw.getLocalParameter(RbmKineticLawParameterType.MassActionReverseRate);
                            kineticsParameterMap.put(fakeRateParameterReverse, origReverseRateParameter);
                        }
                        break;
                    }
                default:
                    {
                        throw new RuntimeException("kinetic law type " + kineticLaw.getRateLawType().name() + " not yet implemented");
                    }
            }
        }
    }
    if (compartmentMode == CompartmentMode.show) {
        RbmNetworkGenerator.writeCompartments(writer, model, simulationContext);
    }
    writer.println(BEGIN_PARAMETERS);
    // the fake parameters used for reaction rule kinetics
    for (FakeReactionRuleRateParameter p : kineticsParameterMap.keySet()) {
        writer.println(p.fakeParameterName + "\t\t1");
    }
    // the fake parameters used at initial values for the seed species
    for (FakeSeedSpeciesInitialConditionsParameter s : fakeParameterList) {
        writer.println(s.fakeParameterName + "\t\t1");
    }
    writer.println(END_PARAMETERS);
    writer.println();
    RbmNetworkGenerator.writeMolecularTypes(writer, model, compartmentMode);
    // write modified version of seed species while maintaining the connection between the species context and the real seed species
    writer.println(BEGIN_SPECIES);
    for (String s : seedSpeciesList) {
        writer.println(s);
    }
    writer.println(END_SPECIES);
    writer.println();
    RbmNetworkGenerator.writeObservables(writer, rbmModelContainer, compartmentMode);
    RbmNetworkGenerator.writeReactions_internal(writer, simulationContext, compartmentMode);
    writer.println(END_MODEL);
    writer.println();
    if (callerClassName.equals(networkTransformerClassName)) {
        RbmNetworkGenerator.writeNetworkConstraints(writer, rbmModelContainer, simulationContext, networkGenerationRequirements);
    } else if (callerClassName.equals(rulebasedTransformerClassName)) {
        writer.println();
        writer.println("writeXML()");
    }
    writer.println();
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) ArrayList(java.util.ArrayList) SpeciesContext(cbit.vcell.model.SpeciesContext) RbmKineticLaw(cbit.vcell.model.RbmKineticLaw) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) Expression(cbit.vcell.parser.Expression) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) Pair(org.vcell.util.Pair)

Example 33 with LocalParameter

use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.

the class Xmlproducer method getXML.

// For events in SimulationContext - XML is very similar to math events
public Element getXML(BioEvent[] bioEvents) throws XmlParseException {
    Element bioEventsElement = new Element(XMLTags.BioEventsTag);
    for (int i = 0; i < bioEvents.length; i++) {
        Element eventElement = new Element(XMLTags.BioEventTag);
        eventElement.setAttribute(XMLTags.NameAttrTag, mangle(bioEvents[i].getName()));
        String triggerType = bioEvents[i].getTriggerType().getXmlName();
        // Add atributes
        eventElement.setAttribute(XMLTags.BioEventTriggerTypeAttrTag, triggerType);
        eventElement.setAttribute(XMLTags.UseValuesFromTriggerTimeAttrTag, Boolean.toString(bioEvents[i].getUseValuesFromTriggerTime()));
        // Add BioEvent Parameters
        LocalParameter[] parameters = bioEvents[i].getEventParameters();
        for (LocalParameter parm : parameters) {
            if (parm.getExpression() != null) {
                Element tempparameter = new Element(XMLTags.ParameterTag);
                // Get parameter attributes
                tempparameter.setAttribute(XMLTags.NameAttrTag, mangle(parm.getName()));
                tempparameter.setAttribute(XMLTags.ParamRoleAttrTag, bioEvents[i].getParameterType(parm).getRoleXmlName());
                VCUnitDefinition unit = parm.getUnitDefinition();
                if (unit != null) {
                    tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
                }
                tempparameter.addContent(mangleExpression(parm.getExpression()));
                // Add the parameter to the general kinetics object
                eventElement.addContent(tempparameter);
            }
        }
        ArrayList<BioEvent.EventAssignment> eventAssignmentsList = bioEvents[i].getEventAssignments();
        if (eventAssignmentsList != null) {
            for (BioEvent.EventAssignment eventAssignment : eventAssignmentsList) {
                Element eventAssignmentElement = new Element(XMLTags.EventAssignmentTag);
                eventAssignmentElement.setAttribute(XMLTags.EventAssignmentVariableAttrTag, eventAssignment.getTarget().getName());
                eventAssignmentElement.addContent(mangleExpression(eventAssignment.getAssignmentExpression()));
                eventElement.addContent(eventAssignmentElement);
            }
        }
        bioEventsElement.addContent(eventElement);
    }
    System.out.println(XmlUtil.xmlToString(bioEventsElement));
    return bioEventsElement;
}
Also used : LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) EventAssignment(cbit.vcell.math.Event.EventAssignment) Element(org.jdom.Element) BioEvent(cbit.vcell.mapping.BioEvent)

Example 34 with LocalParameter

use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.

the class Xmlproducer method getXML.

public Element getXML(SpatialProcess[] spatialProcesses) throws XmlParseException {
    Element spatialProcessesElement = new Element(XMLTags.SpatialProcessesTag);
    for (SpatialProcess spatialProcess : spatialProcesses) {
        Element spatialProcessElement = new Element(XMLTags.SpatialProcessTag);
        spatialProcessElement.setAttribute(XMLTags.NameAttrTag, mangle(spatialProcess.getName()));
        if (spatialProcess instanceof PointKinematics) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_PointKinematics);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessPointObjectAttrTag, ((PointKinematics) spatialProcess).getPointObject().getName());
        } else if (spatialProcess instanceof PointLocation) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_PointLocation);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessPointObjectAttrTag, ((PointLocation) spatialProcess).getPointObject().getName());
        } else if (spatialProcess instanceof SurfaceKinematics) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_SurfaceKinematics);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessSurfaceObjectAttrTag, ((SurfaceKinematics) spatialProcess).getSurfaceRegionObject().getName());
        } else if (spatialProcess instanceof VolumeKinematics) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_VolumeKinematics);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessVolumeObjectAttrTag, ((VolumeKinematics) spatialProcess).getVolumeRegionObject().getName());
        } else {
            throw new RuntimeException("spatialProcess type " + spatialProcess.getClass().getSimpleName() + " not yet supported for persistence.");
        }
        LocalParameter[] parameters = spatialProcess.getParameters();
        for (LocalParameter parm : parameters) {
            if (parm.getExpression() != null) {
                Element tempparameter = new Element(XMLTags.ParameterTag);
                // Get parameter attributes
                tempparameter.setAttribute(XMLTags.NameAttrTag, mangle(parm.getName()));
                tempparameter.setAttribute(XMLTags.ParamRoleAttrTag, spatialProcess.getParameterType(parm).getRoleXmlName());
                VCUnitDefinition unit = parm.getUnitDefinition();
                if (unit != null) {
                    tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
                }
                tempparameter.addContent(mangleExpression(parm.getExpression()));
                spatialProcessElement.addContent(tempparameter);
            }
        }
        spatialProcessesElement.addContent(spatialProcessElement);
    }
    System.out.println(XmlUtil.xmlToString(spatialProcessesElement));
    return spatialProcessesElement;
}
Also used : LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) VolumeKinematics(cbit.vcell.mapping.spatial.processes.VolumeKinematics) Element(org.jdom.Element) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics)

Example 35 with LocalParameter

use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.

the class XmlReader method getSpatialProcesses.

public SpatialProcess[] getSpatialProcesses(SimulationContext simContext, Element spatialProcessesElement) throws XmlParseException {
    Iterator<Element> spatialProcessElementIterator = spatialProcessesElement.getChildren(XMLTags.SpatialProcessTag, vcNamespace).iterator();
    ArrayList<SpatialProcess> spatialProcessList = new ArrayList<SpatialProcess>();
    while (spatialProcessElementIterator.hasNext()) {
        Element spatialProcessElement = (Element) spatialProcessElementIterator.next();
        SpatialProcess spatialProcess = null;
        String name = unMangle(spatialProcessElement.getAttributeValue(XMLTags.NameAttrTag));
        String type = unMangle(spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessTypeAttrTag));
        if (type.equals(XMLTags.SpatialProcessTypeAttrValue_PointKinematics)) {
            PointKinematics pointKinematics = new PointKinematics(name, simContext);
            String pointObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessPointObjectAttrTag);
            PointObject pointObject = (PointObject) simContext.getSpatialObject(pointObjectName);
            pointKinematics.setPointObject(pointObject);
            spatialProcess = pointKinematics;
        } else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_PointLocation)) {
            PointLocation pointLocation = new PointLocation(name, simContext);
            String pointObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessPointObjectAttrTag);
            PointObject pointObject = (PointObject) simContext.getSpatialObject(pointObjectName);
            pointLocation.setPointObject(pointObject);
            spatialProcess = pointLocation;
        } else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_SurfaceKinematics)) {
            SurfaceKinematics surfaceKinematics = new SurfaceKinematics(name, simContext);
            String surfaceRegionObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessSurfaceObjectAttrTag);
            SurfaceRegionObject surfaceRegionObject = (SurfaceRegionObject) simContext.getSpatialObject(surfaceRegionObjectName);
            surfaceKinematics.setSurfaceRegionObject(surfaceRegionObject);
            spatialProcess = surfaceKinematics;
        } else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_VolumeKinematics)) {
            VolumeKinematics volumeKinematics = new VolumeKinematics(name, simContext);
            String volumeRegionObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessVolumeObjectAttrTag);
            VolumeRegionObject volumeRegionObject = (VolumeRegionObject) simContext.getSpatialObject(volumeRegionObjectName);
            volumeKinematics.setVolumeRegionObject(volumeRegionObject);
            spatialProcess = volumeKinematics;
        }
        // set parameters
        Iterator<Element> paramElementIter = spatialProcessElement.getChildren(XMLTags.ParameterTag, vcNamespace).iterator();
        ArrayList<LocalParameter> parameters = new ArrayList<LocalParameter>();
        while (paramElementIter.hasNext()) {
            Element paramElement = paramElementIter.next();
            // Get parameter attributes
            String paramName = paramElement.getAttributeValue(XMLTags.NameAttrTag);
            Expression exp = unMangleExpression(paramElement.getText());
            String roleStr = paramElement.getAttributeValue(XMLTags.ParamRoleAttrTag);
            SpatialProcessParameterType parameterType = SpatialProcessParameterType.fromRoleXmlName(roleStr);
            VCUnitDefinition unit = simContext.getModel().getUnitSystem().getInstance_TBD();
            String unitSymbol = paramElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
            if (unitSymbol != null) {
                unit = simContext.getModel().getUnitSystem().getInstance(unitSymbol);
            }
            parameters.add(spatialProcess.createNewParameter(paramName, parameterType, exp, unit));
        }
        try {
            spatialProcess.setParameters(parameters.toArray(new LocalParameter[0]));
        } catch (PropertyVetoException | ExpressionBindingException e) {
            e.printStackTrace();
            throw new XmlParseException("failed to read parameters in bioEvent " + name + ": " + e.getMessage(), e);
        }
        spatialProcessList.add(spatialProcess);
    }
    return spatialProcessList.toArray(new SpatialProcess[0]);
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) VolumeKinematics(cbit.vcell.mapping.spatial.processes.VolumeKinematics) Element(org.jdom.Element) ArrayList(java.util.ArrayList) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) PropertyVetoException(java.beans.PropertyVetoException) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) PointObject(cbit.vcell.mapping.spatial.PointObject) Expression(cbit.vcell.parser.Expression) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) SpatialProcessParameterType(cbit.vcell.mapping.spatial.processes.SpatialProcess.SpatialProcessParameterType) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Aggregations

LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)45 Expression (cbit.vcell.parser.Expression)31 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)17 PropertyVetoException (java.beans.PropertyVetoException)12 ModelParameter (cbit.vcell.model.Model.ModelParameter)11 SpeciesContext (cbit.vcell.model.SpeciesContext)11 ExpressionException (cbit.vcell.parser.ExpressionException)11 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)9 Parameter (cbit.vcell.model.Parameter)9 ArrayList (java.util.ArrayList)9 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)8 Element (org.jdom.Element)8 ProxyParameter (cbit.vcell.model.ProxyParameter)7 CurrentDensityClampStimulus (cbit.vcell.mapping.CurrentDensityClampStimulus)6 LocalProxyParameter (cbit.vcell.mapping.ParameterContext.LocalProxyParameter)6 TotalCurrentClampStimulus (cbit.vcell.mapping.TotalCurrentClampStimulus)6 Model (cbit.vcell.model.Model)6 ElectricalStimulus (cbit.vcell.mapping.ElectricalStimulus)5 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)5 Domain (cbit.vcell.math.Variable.Domain)5