Search in sources :

Example 91 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class DataSymbolsTableModel method simulationContextChange.

/**
 * Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
 * @param simulationContext The new value for the property.
 * @see #getSimulationContext
 */
@Override
protected void simulationContextChange(java.beans.PropertyChangeEvent evt) {
    super.simulationContextChange(evt);
    SimulationContext oldValue = (SimulationContext) evt.getOldValue();
    if (oldValue != null) {
        oldValue.getDataContext().removePropertyChangeListener(this);
        for (DataSymbol ds : oldValue.getDataContext().getDataSymbols()) {
            ds.removePropertyChangeListener(this);
        }
    }
    SimulationContext newValue = (SimulationContext) evt.getNewValue();
    if (newValue != null) {
        newValue.getDataContext().addPropertyChangeListener(this);
        for (DataSymbol ds : newValue.getDataContext().getDataSymbols()) {
            ds.addPropertyChangeListener(this);
        }
    }
}
Also used : DataSymbol(cbit.vcell.data.DataSymbol) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 92 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class ElectricalMembraneMappingPanel method setsimulationContext1.

/**
 * Set the simulationContext1 to a new value.
 * @param newValue cbit.vcell.mapping.SimulationContext
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setsimulationContext1(SimulationContext newValue) {
    if (ivjsimulationContext1 != newValue) {
        try {
            SimulationContext oldValue = getsimulationContext1();
            ivjsimulationContext1 = newValue;
            connPtoP2SetSource();
            connEtoM1(ivjsimulationContext1);
            connEtoM6(ivjsimulationContext1);
            firePropertyChange("simulationContext", oldValue, newValue);
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    ;
}
Also used : SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 93 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class ElectricalMembraneMappingPanel method setSimulationContext.

/**
 * Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
 * @param simulationContext The new value for the property.
 * @see #getSimulationContext
 */
public void setSimulationContext(SimulationContext simulationContext) {
    SimulationContext oldValue = fieldSimulationContext;
    fieldSimulationContext = simulationContext;
    firePropertyChange("simulationContext", oldValue, simulationContext);
}
Also used : SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 94 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class ElectricalStimulusPanel method setSimulationContext.

/**
 * Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
 * @param simulationContext The new value for the property.
 * @see #getSimulationContext
 */
public void setSimulationContext(SimulationContext simulationContext) {
    SimulationContext oldValue = fieldSimulationContext;
    fieldSimulationContext = simulationContext;
    firePropertyChange("simulationContext", oldValue, simulationContext);
}
Also used : SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 95 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class GeneratedReactionTableRow method deriveRule.

private void deriveRule(String inputString, Model tempModel) {
    if (owner != null && owner.getSimulationContext() != null) {
        List<MolecularType> mtList = owner.getSimulationContext().getModel().getRbmModelContainer().getMolecularTypeList();
        try {
            tempModel.getRbmModelContainer().setMolecularTypeList(mtList);
        } catch (PropertyVetoException e1) {
            e1.printStackTrace();
            throw new RuntimeException("Unexpected exception setting " + MolecularType.typeName + " list: " + e1.getMessage(), e1);
        }
    } else {
        // This should not be possible
        throw new RuntimeException("Owner or SimulationContext are null.");
    }
    int arrowIndex = inputString.indexOf("<->");
    boolean bReversible = true;
    if (arrowIndex < 0) {
        arrowIndex = inputString.indexOf("->");
        bReversible = false;
    }
    String left = inputString.substring(0, arrowIndex).trim();
    String right = inputString.substring(arrowIndex + (bReversible ? 3 : 2)).trim();
    if (left.length() == 0 && right.length() == 0) {
        return;
    }
    String name = reactionObject.getRuleName();
    if (name.contains(GeneratedReactionTableModel.reverse)) {
        name = name.substring(GeneratedReactionTableModel.reverse.length());
    }
    if (name.endsWith(ReactionRule.DirectHalf)) {
        name = name.substring(0, name.indexOf(ReactionRule.DirectHalf));
    }
    if (name.endsWith(ReactionRule.InverseHalf)) {
        name = name.substring(0, name.indexOf(ReactionRule.InverseHalf));
    }
    // try to get the name of the original structure from the original rule and make here another structure with the same name
    String strStructure = null;
    Structure ruleStructure;
    SimulationContext sc = owner.getSimulationContext();
    ReactionRule rr = sc.getModel().getRbmModelContainer().getReactionRule(name);
    if (rr != null && rr.getStructure() != null) {
        strStructure = rr.getStructure().getName();
    }
    if (strStructure != null) {
        if (tempModel.getStructure(strStructure) == null) {
            try {
                tempModel.addFeature(strStructure);
            } catch (ModelException | PropertyVetoException e) {
                e.printStackTrace();
            }
        }
        ruleStructure = tempModel.getStructure(strStructure);
    } else {
        throw new RuntimeException("Failed to recover a Structure name from the Reaction Rule: " + name);
    }
    // making the fake rules just for display purpose, actually they are the flattened reactions resulted from bngl
    // the name is probably not unique, it's likely that many flattened reactions are derived from the same rule
    reactionRule = tempModel.getRbmModelContainer().createReactionRule(name, ruleStructure, bReversible);
    String regex = "[^!]\\+";
    String[] patterns = left.split(regex);
    for (String spString : patterns) {
        try {
            spString = spString.trim();
            // if compartments are present, we're making some fake compartments in the tempModel just for compartment name display purposes
            SpeciesPattern speciesPattern = (SpeciesPattern) RbmUtils.parseSpeciesPattern(spString, tempModel);
            strStructure = RbmUtils.parseCompartment(spString, tempModel);
            speciesPattern.resolveBonds();
            Structure structure;
            if (strStructure != null) {
                if (tempModel.getStructure(strStructure) == null) {
                    tempModel.addFeature(strStructure);
                }
                structure = tempModel.getStructure(strStructure);
            } else {
                // if nothing explicit for a participant, we use by default the structure of the rule
                structure = ruleStructure;
            }
            reactionRule.addReactant(new ReactantPattern(speciesPattern, structure));
        } catch (Throwable ex) {
            ex.printStackTrace();
            return;
        }
    }
    patterns = right.split(regex);
    for (String spString : patterns) {
        try {
            spString = spString.trim();
            SpeciesPattern speciesPattern = (SpeciesPattern) RbmUtils.parseSpeciesPattern(spString, tempModel);
            strStructure = RbmUtils.parseCompartment(spString, tempModel);
            speciesPattern.resolveBonds();
            Structure structure;
            if (strStructure != null) {
                if (tempModel.getStructure(strStructure) == null) {
                    tempModel.addFeature(strStructure);
                }
                structure = tempModel.getStructure(strStructure);
            } else {
                structure = ruleStructure;
            }
            reactionRule.addProduct(new ProductPattern(speciesPattern, structure));
        } catch (Throwable ex) {
            ex.printStackTrace();
            return;
        }
    }
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) ModelException(cbit.vcell.model.ModelException) ProductPattern(cbit.vcell.model.ProductPattern) SimulationContext(cbit.vcell.mapping.SimulationContext) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) MolecularType(org.vcell.model.rbm.MolecularType) PropertyVetoException(java.beans.PropertyVetoException) Structure(cbit.vcell.model.Structure) ReactantPattern(cbit.vcell.model.ReactantPattern)

Aggregations

SimulationContext (cbit.vcell.mapping.SimulationContext)181 BioModel (cbit.vcell.biomodel.BioModel)73 Simulation (cbit.vcell.solver.Simulation)57 MathDescription (cbit.vcell.math.MathDescription)32 Geometry (cbit.vcell.geometry.Geometry)29 PropertyVetoException (java.beans.PropertyVetoException)28 MathModel (cbit.vcell.mathmodel.MathModel)25 Model (cbit.vcell.model.Model)25 KeyValue (org.vcell.util.document.KeyValue)25 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)23 ArrayList (java.util.ArrayList)23 DataAccessException (org.vcell.util.DataAccessException)23 XMLSource (cbit.vcell.xml.XMLSource)22 XmlParseException (cbit.vcell.xml.XmlParseException)22 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)20 Expression (cbit.vcell.parser.Expression)20 ExpressionException (cbit.vcell.parser.ExpressionException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)17 Structure (cbit.vcell.model.Structure)17 IOException (java.io.IOException)17