Search in sources :

Example 21 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class BioModelParametersTableModel method getApplicationEditableSymbolTableEntryList.

private List<EditableSymbolTableEntry> getApplicationEditableSymbolTableEntryList(SimulationContext simulationContext) {
    ArrayList<EditableSymbolTableEntry> parameterList = new ArrayList<EditableSymbolTableEntry>();
    Map<String, SymbolTableEntry> entryMap = new HashMap<String, SymbolTableEntry>();
    simulationContext.getEntries(entryMap);
    for (SymbolTableEntry ste : entryMap.values()) {
        if (ste instanceof EditableSymbolTableEntry && ste.getNameScope() == simulationContext.getNameScope()) {
            parameterList.add((EditableSymbolTableEntry) ste);
        }
    }
    for (StructureMapping mapping : simulationContext.getGeometryContext().getStructureMappings()) {
        parameterList.addAll(mapping.computeApplicableParameterList());
    }
    for (SpeciesContextSpec spec : simulationContext.getReactionContext().getSpeciesContextSpecs()) {
        parameterList.addAll(spec.computeApplicableParameterList());
    }
    for (ElectricalStimulus elect : simulationContext.getElectricalStimuli()) {
        parameterList.addAll(Arrays.asList(elect.getParameters()));
    }
    for (SpatialProcess sp : simulationContext.getSpatialProcesses()) {
        parameterList.addAll(Arrays.asList(sp.getParameters()));
    }
    return parameterList;
}
Also used : ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry) HashMap(java.util.HashMap) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) ArrayList(java.util.ArrayList) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry)

Example 22 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess 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 23 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess 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 24 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess 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)

Example 25 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class SpatialProcessDisplayPanel method deleteButtonPressed.

@Override
protected void deleteButtonPressed() {
    int[] rows = table.getSelectedRows();
    ArrayList<SpatialProcess> deleteList = new ArrayList<SpatialProcess>();
    for (int r : rows) {
        if (r < tableModel.getRowCount()) {
            SpatialProcess SpatialProcess = tableModel.getValueAt(r);
            if (SpatialProcess != null) {
                deleteList.add(SpatialProcess);
            }
        }
    }
    try {
        for (SpatialProcess SpatialProcess : deleteList) {
            simulationContext.removeSpatialProcess(SpatialProcess);
        }
    } catch (PropertyVetoException ex) {
        ex.printStackTrace();
        DialogUtils.showErrorDialog(this, ex.getMessage());
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) ArrayList(java.util.ArrayList)

Aggregations

SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)28 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)18 SimulationContext (cbit.vcell.mapping.SimulationContext)9 BioEvent (cbit.vcell.mapping.BioEvent)8 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)7 StructureMapping (cbit.vcell.mapping.StructureMapping)7 ReactionStep (cbit.vcell.model.ReactionStep)7 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)6 SimulationContextParameter (cbit.vcell.mapping.SimulationContext.SimulationContextParameter)6 PointObject (cbit.vcell.mapping.spatial.PointObject)6 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)6 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)6 Element (org.jdom.Element)6 PointKinematics (cbit.vcell.mapping.spatial.processes.PointKinematics)5 PointLocation (cbit.vcell.mapping.spatial.processes.PointLocation)5 ReactionRule (cbit.vcell.model.ReactionRule)5 SpeciesContext (cbit.vcell.model.SpeciesContext)5 NetworkConstraints (org.vcell.model.rbm.NetworkConstraints)5 BioModel (cbit.vcell.biomodel.BioModel)4 Geometry (cbit.vcell.geometry.Geometry)4