Search in sources :

Example 51 with KineticsParameter

use of cbit.vcell.model.Kinetics.KineticsParameter in project vcell by virtualcell.

the class BioModelParametersTableModel method setValueAt.

public void setValueAt(Object value, int row, int col) {
    if (value == null) {
        return;
    }
    try {
        String inputValue = (String) value;
        inputValue = inputValue.trim();
        EditableSymbolTableEntry parameter = getValueAt(row);
        switch(col) {
            case COLUMN_NAME:
                {
                    if (inputValue.length() == 0) {
                        return;
                    }
                    parameter.setName(inputValue);
                    break;
                }
            case COLUMN_EXPRESSION:
                {
                    String newExpressionString = inputValue;
                    if (parameter instanceof SpeciesContextSpec.SpeciesContextSpecParameter) {
                        SpeciesContextSpec.SpeciesContextSpecParameter scsParm = (SpeciesContextSpec.SpeciesContextSpecParameter) parameter;
                        Expression newExp = null;
                        if (newExpressionString == null || newExpressionString.trim().length() == 0) {
                            if (scsParm.getRole() == SpeciesContextSpec.ROLE_InitialConcentration || scsParm.getRole() == SpeciesContextSpec.ROLE_DiffusionRate || scsParm.getRole() == SpeciesContextSpec.ROLE_InitialCount) {
                                newExp = new Expression(0.0);
                            }
                        } else {
                            newExp = new Expression(newExpressionString);
                        }
                        scsParm.setExpression(newExp);
                    } else if (parameter instanceof KineticsParameter) {
                        Expression exp1 = new Expression(inputValue);
                        Kinetics kinetics = ((KineticsParameter) parameter).getKinetics();
                        kinetics.setParameterValue((Kinetics.KineticsParameter) parameter, exp1);
                    } else {
                        Expression exp1 = new Expression(inputValue);
                        exp1.bindExpression(parameter.getNameScope().getScopedSymbolTable());
                        parameter.setExpression(exp1);
                    }
                    break;
                }
            case COLUMN_UNIT:
                {
                    ModelUnitSystem modelUnitSystem = getModel().getUnitSystem();
                    if (inputValue.length() == 0) {
                        parameter.setUnitDefinition(modelUnitSystem.getInstance_TBD());
                    } else {
                        if (!parameter.getUnitDefinition().getSymbol().equals(inputValue)) {
                            parameter.setUnitDefinition(modelUnitSystem.getInstance(inputValue));
                        }
                    }
                    break;
                }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
        DialogUtils.showErrorDialog(ownerTable, e.getMessage());
    }
}
Also used : KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) ScopedExpression(cbit.gui.ScopedExpression) Expression(cbit.vcell.parser.Expression) Kinetics(cbit.vcell.model.Kinetics) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Example 52 with KineticsParameter

use of cbit.vcell.model.Kinetics.KineticsParameter 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 53 with KineticsParameter

use of cbit.vcell.model.Kinetics.KineticsParameter in project vcell by virtualcell.

the class ReactionPropertiesPanel method setReversible.

private void setReversible(boolean bReversible) {
    reactionStep.setReversible(bReversible);
    if (reactionStep.getKinetics() instanceof MassActionKinetics) {
        KineticsParameter kp = reactionStep.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_KReverse);
        kp.setExpression(new Expression(0.0d));
    }
    getParameterTableModel().refreshData();
}
Also used : KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) Expression(cbit.vcell.parser.Expression) MassActionKinetics(cbit.vcell.model.MassActionKinetics)

Example 54 with KineticsParameter

use of cbit.vcell.model.Kinetics.KineticsParameter in project vcell by virtualcell.

the class ParameterPropertiesPanel method changeExpression.

private void changeExpression() {
    try {
        if (parameter == null) {
            return;
        }
        String text = expressionTextField.getText();
        if (text == null || text.trim().length() == 0) {
            Expression exp = parameter.getDefaultExpression();
            if (exp != null) {
                parameter.setExpression(exp);
            }
            return;
        }
        if (expressionMatchesCurrentValue(text)) {
            return;
        }
        if (parameter instanceof SpeciesContextSpec.SpeciesContextSpecParameter) {
            SpeciesContextSpec.SpeciesContextSpecParameter scsParm = (SpeciesContextSpec.SpeciesContextSpecParameter) parameter;
            scsParm.setExpression(new Expression(text));
        } else if (parameter instanceof KineticsParameter) {
            Expression exp1 = new Expression(text);
            Kinetics kinetics = ((KineticsParameter) parameter).getKinetics();
            kinetics.setParameterValue((Kinetics.KineticsParameter) parameter, exp1);
        } else {
            Expression exp1 = new Expression(text);
            exp1.bindExpression(parameter.getNameScope().getScopedSymbolTable());
            parameter.setExpression(exp1);
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
        PopupGenerator.showErrorDialog(this, e.getMessage(), e);
    }
}
Also used : KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) Expression(cbit.vcell.parser.Expression) Kinetics(cbit.vcell.model.Kinetics) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) PropertyVetoException(java.beans.PropertyVetoException) ExpressionException(cbit.vcell.parser.ExpressionException)

Aggregations

KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)54 Expression (cbit.vcell.parser.Expression)38 SpeciesContext (cbit.vcell.model.SpeciesContext)26 ReactionStep (cbit.vcell.model.ReactionStep)24 ModelParameter (cbit.vcell.model.Model.ModelParameter)23 Kinetics (cbit.vcell.model.Kinetics)21 Model (cbit.vcell.model.Model)15 ExpressionException (cbit.vcell.parser.ExpressionException)14 PropertyVetoException (java.beans.PropertyVetoException)14 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)13 LumpedKinetics (cbit.vcell.model.LumpedKinetics)11 Structure (cbit.vcell.model.Structure)11 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)11 MassActionKinetics (cbit.vcell.model.MassActionKinetics)10 ReactionParticipant (cbit.vcell.model.ReactionParticipant)10 SimpleReaction (cbit.vcell.model.SimpleReaction)10 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)9 DistributedKinetics (cbit.vcell.model.DistributedKinetics)9 ReactionRule (cbit.vcell.model.ReactionRule)8 BioModel (cbit.vcell.biomodel.BioModel)7