Search in sources :

Example 36 with SpeciesContext

use of cbit.vcell.model.SpeciesContext in project vcell by virtualcell.

the class FRAPStudy method createNewRefBioModel.

public static BioModel createNewRefBioModel(FRAPStudy sourceFrapStudy, String baseDiffusionRate, TimeStep tStep, KeyValue simKey, User owner, FieldDataIdentifierSpec psfFDIS, int startingIndexForRecovery) throws Exception {
    if (owner == null) {
        throw new Exception("Owner is not defined");
    }
    ROI cellROI_2D = sourceFrapStudy.getFrapData().getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name());
    Extent extent = sourceFrapStudy.getFrapData().getImageDataset().getExtent();
    TimeBounds timeBounds = FRAPOptData.getEstimatedRefTimeBound(sourceFrapStudy);
    double timeStepVal = FRAPOptData.REFERENCE_DIFF_DELTAT;
    int numX = cellROI_2D.getRoiImages()[0].getNumX();
    int numY = cellROI_2D.getRoiImages()[0].getNumY();
    int numZ = cellROI_2D.getRoiImages().length;
    short[] shortPixels = cellROI_2D.getRoiImages()[0].getPixels();
    byte[] bytePixels = new byte[numX * numY * numZ];
    final byte EXTRACELLULAR_PIXVAL = 0;
    final byte CYTOSOL_PIXVAL = 1;
    for (int i = 0; i < bytePixels.length; i++) {
        if (shortPixels[i] != 0) {
            bytePixels[i] = CYTOSOL_PIXVAL;
        }
    }
    VCImage maskImage;
    try {
        maskImage = new VCImageUncompressed(null, bytePixels, extent, numX, numY, numZ);
    } catch (ImageException e) {
        e.printStackTrace();
        throw new RuntimeException("failed to create mask image for geometry");
    }
    Geometry geometry = new Geometry("geometry", maskImage);
    if (geometry.getGeometrySpec().getNumSubVolumes() != 2) {
        throw new Exception("Cell ROI has no ExtraCellular.");
    }
    int subVolume0PixVal = ((ImageSubVolume) geometry.getGeometrySpec().getSubVolume(0)).getPixelValue();
    geometry.getGeometrySpec().getSubVolume(0).setName((subVolume0PixVal == EXTRACELLULAR_PIXVAL ? EXTRACELLULAR_NAME : CYTOSOL_NAME));
    int subVolume1PixVal = ((ImageSubVolume) geometry.getGeometrySpec().getSubVolume(1)).getPixelValue();
    geometry.getGeometrySpec().getSubVolume(1).setName((subVolume1PixVal == CYTOSOL_PIXVAL ? CYTOSOL_NAME : EXTRACELLULAR_NAME));
    geometry.getGeometrySurfaceDescription().updateAll();
    BioModel bioModel = new BioModel(null);
    bioModel.setName("unnamed");
    Model model = new Model("model");
    bioModel.setModel(model);
    Feature extracellular = model.addFeature(EXTRACELLULAR_NAME);
    Feature cytosol = model.addFeature(CYTOSOL_NAME);
    Membrane plasmaMembrane = model.addMembrane(PLASMAMEMBRANE_NAME);
    String roiDataName = FRAPStudy.ROI_EXTDATA_NAME;
    final int ONE_DIFFUSION_SPECIES_COUNT = 1;
    final int MOBILE_SPECIES_INDEX = 0;
    Expression[] diffusionConstants = new Expression[ONE_DIFFUSION_SPECIES_COUNT];
    Species[] species = new Species[ONE_DIFFUSION_SPECIES_COUNT];
    SpeciesContext[] speciesContexts = new SpeciesContext[ONE_DIFFUSION_SPECIES_COUNT];
    Expression[] initialConditions = new Expression[ONE_DIFFUSION_SPECIES_COUNT];
    // Mobile Species
    diffusionConstants[MOBILE_SPECIES_INDEX] = new Expression(baseDiffusionRate);
    species[MOBILE_SPECIES_INDEX] = new Species(SPECIES_NAME_PREFIX_MOBILE, "Mobile bleachable species");
    speciesContexts[MOBILE_SPECIES_INDEX] = new SpeciesContext(null, species[MOBILE_SPECIES_INDEX].getCommonName(), species[MOBILE_SPECIES_INDEX], cytosol);
    FieldFunctionArguments postBleach_first = new FieldFunctionArguments(roiDataName, "postbleach_first", new Expression(0), VariableType.VOLUME);
    FieldFunctionArguments prebleach_avg = new FieldFunctionArguments(roiDataName, "prebleach_avg", new Expression(0), VariableType.VOLUME);
    Expression expPostBleach_first = new Expression(postBleach_first.infix());
    Expression expPreBleach_avg = new Expression(prebleach_avg.infix());
    initialConditions[MOBILE_SPECIES_INDEX] = Expression.div(expPostBleach_first, expPreBleach_avg);
    SimulationContext simContext = new SimulationContext(bioModel.getModel(), geometry);
    bioModel.addSimulationContext(simContext);
    FeatureMapping cytosolFeatureMapping = (FeatureMapping) simContext.getGeometryContext().getStructureMapping(cytosol);
    FeatureMapping extracellularFeatureMapping = (FeatureMapping) simContext.getGeometryContext().getStructureMapping(extracellular);
    MembraneMapping plasmaMembraneMapping = (MembraneMapping) simContext.getGeometryContext().getStructureMapping(plasmaMembrane);
    SubVolume cytSubVolume = geometry.getGeometrySpec().getSubVolume(CYTOSOL_NAME);
    SubVolume exSubVolume = geometry.getGeometrySpec().getSubVolume(EXTRACELLULAR_NAME);
    SurfaceClass pmSurfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(exSubVolume, cytSubVolume);
    cytosolFeatureMapping.setGeometryClass(cytSubVolume);
    extracellularFeatureMapping.setGeometryClass(exSubVolume);
    plasmaMembraneMapping.setGeometryClass(pmSurfaceClass);
    cytosolFeatureMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
    extracellularFeatureMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
    plasmaMembraneMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
    for (int i = 0; i < initialConditions.length; i++) {
        model.addSpecies(species[i]);
        model.addSpeciesContext(speciesContexts[i]);
    }
    for (int i = 0; i < speciesContexts.length; i++) {
        SpeciesContextSpec scs = simContext.getReactionContext().getSpeciesContextSpec(speciesContexts[i]);
        scs.getInitialConditionParameter().setExpression(initialConditions[i]);
        scs.getDiffusionParameter().setExpression(diffusionConstants[i]);
    }
    MathMapping mathMapping = simContext.createNewMathMapping();
    MathDescription mathDesc = mathMapping.getMathDescription();
    // Add PSF function
    mathDesc.addVariable(new Function(Simulation.PSF_FUNCTION_NAME, new Expression(psfFDIS.getFieldFuncArgs().infix()), null));
    simContext.setMathDescription(mathDesc);
    SimulationVersion simVersion = new SimulationVersion(simKey, "sim1", owner, new GroupAccessNone(), new KeyValue("0"), new BigDecimal(0), new Date(), VersionFlag.Current, "", null);
    Simulation newSimulation = new Simulation(simVersion, simContext.getMathDescription());
    newSimulation.getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
    simContext.addSimulation(newSimulation);
    newSimulation.getSolverTaskDescription().setTimeBounds(timeBounds);
    newSimulation.getSolverTaskDescription().setOutputTimeSpec(new UniformOutputTimeSpec(timeStepVal));
    newSimulation.getMeshSpecification().setSamplingSize(cellROI_2D.getISize());
    newSimulation.getSolverTaskDescription().setTimeStep(new TimeStep(timeStepVal, timeStepVal, timeStepVal));
    return bioModel;
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) ImageException(cbit.image.ImageException) KeyValue(org.vcell.util.document.KeyValue) Extent(org.vcell.util.Extent) SurfaceClass(cbit.vcell.geometry.SurfaceClass) MathDescription(cbit.vcell.math.MathDescription) VCImage(cbit.image.VCImage) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) Feature(cbit.vcell.model.Feature) TimeBounds(cbit.vcell.solver.TimeBounds) Function(cbit.vcell.math.Function) GroupAccessNone(org.vcell.util.document.GroupAccessNone) TimeStep(cbit.vcell.solver.TimeStep) SimulationVersion(org.vcell.util.document.SimulationVersion) FeatureMapping(cbit.vcell.mapping.FeatureMapping) SubVolume(cbit.vcell.geometry.SubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) Membrane(cbit.vcell.model.Membrane) Species(cbit.vcell.model.Species) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) VCImageUncompressed(cbit.image.VCImageUncompressed) SimulationContext(cbit.vcell.mapping.SimulationContext) ROI(cbit.vcell.VirtualMicroscopy.ROI) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) BigDecimal(java.math.BigDecimal) Date(java.util.Date) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) Expression(cbit.vcell.parser.Expression) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) MathMapping(cbit.vcell.mapping.MathMapping)

Example 37 with SpeciesContext

use of cbit.vcell.model.SpeciesContext in project vcell by virtualcell.

the class SpeciesContextShape method paintSelf.

@Override
public void paintSelf(Graphics2D g, int absPosX, int absPosY) {
    boolean isBound = false;
    SpeciesContext sc = (SpeciesContext) getModelObject();
    boolean bHasPCLink = false;
    if (graphModel instanceof ModelCartoon) {
        ModelCartoon mc = (ModelCartoon) graphModel;
        // check if species has Pathway Commons link by querying VCMetadata : if it does, need to change color of speciesContext.
        try {
            MiriamManager miriamManager = mc.getModel().getVcMetaData().getMiriamManager();
            Map<MiriamRefGroup, MIRIAMQualifier> miriamRefGroups = miriamManager.getAllMiriamRefGroups(sc.getSpecies());
            if (miriamRefGroups != null && miriamRefGroups.size() > 0) {
                bHasPCLink = true;
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    }
    if (sc.getSpecies().getDBSpecies() != null || bHasPCLink) {
        isBound = true;
    }
    int shapeHeight = getSpaceManager().getSize().height;
    int shapeWidth = getSpaceManager().getSize().width;
    int offsetX = (shapeWidth - circleDiameter) / 2;
    int offsetY = (shapeHeight - circleDiameter) / 2;
    Graphics2D g2D = g;
    // if (icon == null) {
    icon = new Area();
    icon.add(new Area(new Ellipse2D.Double(offsetX, offsetY, circleDiameter, circleDiameter)));
    // icon.add(new Area(new RoundRectangle2D.Double(offsetX, offsetY,circleDiameter,circleDiameter,circleDiameter/2,circleDiameter/2)));
    // }
    Area movedIcon = icon.createTransformedArea(AffineTransform.getTranslateInstance(absPosX, absPosY));
    if (sc.getSpeciesPattern() == null) {
        defaultBG = java.awt.Color.green;
    } else {
        defaultBG = java.awt.Color.blue;
    }
    if (isCatalyst == true) {
        defaultBG = java.awt.Color.magenta;
    }
    backgroundColor = defaultBG;
    darkerBackground = backgroundColor.darker().darker();
    // g.setColor((!isBound && !isSelected()?darkerBackground:backgroundColor));
    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Color exterior = !isBound && !isSelected() ? darkerBackground : backgroundColor;
    // Color interior = exterior.brighter().brighter();
    Point2D center = new Point2D.Float(absPosX + circleDiameter * 0.5f, absPosY + circleDiameter * 0.5f);
    float radius = circleDiameter * 0.5f;
    Point2D focus = new Point2D.Float(absPosX + circleDiameter * 0.4f, absPosY + circleDiameter * 0.4f);
    float[] dist = { 0.1f, 1.0f };
    Color[] colors = { Color.white, exterior };
    // Color[] colors = {interior, exterior};
    RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
    g2D.setPaint(p);
    g2D.fill(movedIcon);
    g.setColor(forgroundColor);
    g2D.draw(movedIcon);
    // draw label
    if (getLabel() != null && getLabel().length() > 0) {
        if (isSelected()) {
            // clear background and outline to make selected label stand out
            Rectangle outlineRectangle = getLabelOutline(absPosX, absPosY);
            drawRaisedOutline(outlineRectangle.x, outlineRectangle.y, outlineRectangle.width, outlineRectangle.height, g, Color.white, forgroundColor, Color.gray);
        }
        g.setColor(forgroundColor);
        g.drawString((isSelected() || smallLabel == null ? getLabel() : smallLabel), (isSelected() || smallLabel == null ? getLabelPos().x : smallLabelPos.x) + absPosX, getLabelPos().y + absPosY);
    }
    if (linkText != null && linkText != "") {
        ShapePaintUtil.paintLinkMark(g2D, this, Color.BLACK);
    }
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) Color(java.awt.Color) Rectangle(java.awt.Rectangle) SpeciesContext(cbit.vcell.model.SpeciesContext) RadialGradientPaint(java.awt.RadialGradientPaint) Point(java.awt.Point) RadialGradientPaint(java.awt.RadialGradientPaint) Graphics2D(java.awt.Graphics2D) Area(java.awt.geom.Area) Point2D(java.awt.geom.Point2D) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Example 38 with SpeciesContext

use of cbit.vcell.model.SpeciesContext in project vcell by virtualcell.

the class SpeciesPatternRoundShape method paintCompartment.

public void paintCompartment(Graphics g) {
    Color structureColor = Color.black;
    Structure structure = null;
    if (owner instanceof ReactionRule && !speciesShapes.isEmpty()) {
        ReactionRule rr = (ReactionRule) owner;
        ReactantPattern rp = rr.getReactantPattern(sp);
        ProductPattern pp = rr.getProductPattern(sp);
        if (rp != null) {
            structure = rp.getStructure();
        } else if (pp != null) {
            structure = pp.getStructure();
        } else {
            structure = ((ReactionRule) owner).getStructure();
        }
    } else if (owner instanceof SpeciesContext && ((SpeciesContext) owner).hasSpeciesPattern()) {
        structure = ((SpeciesContext) owner).getStructure();
        structureColor = Color.gray;
    } else if (owner instanceof RbmObservable && !speciesShapes.isEmpty()) {
        structure = ((RbmObservable) owner).getStructure();
    } else {
        // other things don't have structure
        return;
    }
    if (structure == null) {
        return;
    }
    // don't have a real structure, so we show them structureless (for now)
    if (structure.getName() == null) {
        return;
    }
    Graphics2D g2 = (Graphics2D) g;
    Color colorOld = g2.getColor();
    Paint paintOld = g2.getPaint();
    Font fontOld = g2.getFont();
    Font font;
    // width of compartment shape, adjusted continuously based on zoom factor
    int w;
    String name = structure.getName();
    int z = shapePanel.getZoomFactor();
    if (z > -3) {
        font = fontOld.deriveFont(Font.BOLD);
        g.setFont(font);
        w = 46 + 3 * z;
        name = buildCompartmentName(g, name, "..", w);
    } else if (z < LargeShapeCanvas.SmallestZoomFactorWithText) {
        font = fontOld.deriveFont(fontOld.getSize2D() * 0.8f);
        g.setFont(font);
        w = 20;
        name = buildCompartmentName(g, name, ".", w);
    } else {
        font = fontOld;
        g.setFont(font);
        w = 44 + 3 * z;
        name = buildCompartmentName(g, name, "..", w);
    }
    // a bit darker for border
    Color darker = Color.gray;
    Rectangle2D border = new Rectangle2D.Double(xPos - 9, yPos - 4, w, 58);
    g2.setColor(darker);
    g2.draw(border);
    Color lighter = new Color(224, 224, 224);
    Rectangle2D filling = new Rectangle2D.Double(xPos - 9, yPos - 3, w, 57);
    g2.setPaint(lighter);
    g2.fill(filling);
    g.setColor(structureColor);
    g2.drawString(name, xPos - 4, yPos + 48);
    g2.setFont(fontOld);
    g2.setPaint(paintOld);
    g2.setColor(colorOld);
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) ProductPattern(cbit.vcell.model.ProductPattern) Color(java.awt.Color) RbmObservable(cbit.vcell.model.RbmObservable) Rectangle2D(java.awt.geom.Rectangle2D) SpeciesContext(cbit.vcell.model.SpeciesContext) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint) Font(java.awt.Font) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint) Graphics2D(java.awt.Graphics2D) Structure(cbit.vcell.model.Structure) ReactantPattern(cbit.vcell.model.ReactantPattern)

Example 39 with SpeciesContext

use of cbit.vcell.model.SpeciesContext in project vcell by virtualcell.

the class AbstractMathMapping method getDefaultGeometryClass.

protected GeometryClass getDefaultGeometryClass(Expression expr) throws ExpressionException, MappingException {
    GeometryClass geometryClass = null;
    if (simContext.getGeometry().getDimension() == 0) {
        return null;
    }
    String[] symbols = expr.getSymbols();
    // if expr has no symbols, model param cannot be localized to a domain (its a const).
    if (symbols == null) {
        return null;
    } else {
        Expression modelParamExpr = substituteGlobalParameters(expr);
        symbols = modelParamExpr.getSymbols();
        for (int k = 0; symbols != null && k < symbols.length; k++) {
            Structure symbolStructure = null;
            SymbolTableEntry ste = modelParamExpr.getSymbolBinding(symbols[k]);
            if (ste instanceof SpeciesContext) {
                symbolStructure = ((SpeciesContext) ste).getStructure();
            } else if (ste instanceof StructureSize) {
                symbolStructure = ((StructureSize) ste).getStructure();
            } else if (ste instanceof MembraneVoltage) {
                symbolStructure = ((MembraneVoltage) ste).getMembrane();
            }
            if (symbolStructure != null) {
                StructureMapping sm = simContext.getGeometryContext().getStructureMapping(symbolStructure);
                GeometryClass symbolGeomClass = sm.getGeometryClass();
                if (geometryClass == null) {
                    geometryClass = symbolGeomClass;
                } else {
                    if (geometryClass != symbolGeomClass) {
                        if (geometryClass instanceof SurfaceClass) {
                            if (symbolGeomClass instanceof SurfaceClass) {
                                throw new MappingException("The expression '" + expr.infix() + "' references variables in surface domain '" + geometryClass.getName() + "' & surface domain '" + symbolGeomClass.getName() + "' that cannot be evaluated.");
                            } else if (symbolGeomClass instanceof SubVolume) {
                                // geomClass : surfaceClass; symbolGeomClass : subVol
                                if (!((SurfaceClass) geometryClass).isAdjacentTo((SubVolume) symbolGeomClass)) {
                                    throw new MappingException("The expression '" + expr.infix() + "' references variables in surface domain '" + geometryClass.getName() + "' & volume domain '" + symbolGeomClass.getName() + "' that cannot be evaluated.");
                                }
                            } else {
                                throw new MappingException("unexpected geometry class : " + symbolGeomClass.getClass());
                            }
                        } else if (geometryClass instanceof SubVolume) {
                            // geometryClass is a SubVolume
                            if (symbolGeomClass instanceof SubVolume) {
                                // check if adjacent; if so, choose separating membrane.
                                SurfaceClass surfaceClass = simContext.getGeometry().getGeometrySurfaceDescription().getSurfaceClass((SubVolume) symbolGeomClass, (SubVolume) geometryClass);
                                if (surfaceClass != null) {
                                    geometryClass = surfaceClass;
                                } else {
                                    throw new MappingException("The expression '" + expr.infix() + "' references variables in volume domain '" + geometryClass.getName() + "' & volume domain '" + symbolGeomClass.getName() + "' that cannot be evaluated.");
                                }
                            } else {
                                // geomClass : subVol; symbolGeomClass = surfaceClass
                                SurfaceClass surfaceSymbolGeomClass = (SurfaceClass) symbolGeomClass;
                                if (!surfaceSymbolGeomClass.isAdjacentTo((SubVolume) geometryClass)) {
                                    throw new MappingException("The expression '" + expr.infix() + "' references variables in surface domain '" + surfaceSymbolGeomClass.getName() + "' & volume domain '" + geometryClass.getName() + "' that cannot be evaluated.");
                                } else {
                                    geometryClass = symbolGeomClass;
                                }
                            }
                        } else {
                            throw new MappingException("unexpected geometry class : " + geometryClass.getClass());
                        }
                    }
                }
            }
        }
    }
    return geometryClass;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) SurfaceClass(cbit.vcell.geometry.SurfaceClass) SpeciesContext(cbit.vcell.model.SpeciesContext) StructureSize(cbit.vcell.model.Structure.StructureSize) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Expression(cbit.vcell.parser.Expression) MembraneVoltage(cbit.vcell.model.Membrane.MembraneVoltage) SubVolume(cbit.vcell.geometry.SubVolume) CompartmentSubVolume(cbit.vcell.geometry.CompartmentSubVolume) Structure(cbit.vcell.model.Structure)

Example 40 with SpeciesContext

use of cbit.vcell.model.SpeciesContext in project vcell by virtualcell.

the class StructureAnalyzer method refreshFastMatrices.

/**
 * This method was created in VisualAge.
 */
private void refreshFastMatrices() throws Exception {
    // System.out.println("StructureAnalyzer.refreshFastMatrices()");
    // 
    // update scheme matrix for fast system
    // 
    fastSchemeMatrix = new RationalNumberMatrix(fastSpeciesContextMappings.length, fastReactionSteps.length);
    for (int i = 0; i < fastSpeciesContextMappings.length; i++) {
        for (int j = 0; j < fastReactionSteps.length; j++) {
            fastSchemeMatrix.set_elem(i, j, fastReactionSteps[j].getStoichiometry(fastSpeciesContextMappings[i].getSpeciesContext()));
        }
    }
    // 
    for (int i = 0; i < fastSpeciesContextMappings.length; i++) {
        SpeciesContextMapping scm = fastSpeciesContextMappings[i];
        SpeciesContext sc = scm.getSpeciesContext();
        // 
        // collect fast rate expression
        // 
        Expression exp = new Expression(0.0);
        for (int j = 0; j < fastReactionSteps.length; j++) {
            int stoichiometry = fastReactionSteps[j].getStoichiometry(sc);
            ReactionSpec reactionSpec = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpec(fastReactionSteps[j]);
            if (stoichiometry != 0) {
                if (!reactionSpec.isFast()) {
                    throw new Exception("expected only fast rates");
                }
                if (reactionSpec.isExcluded()) {
                    throw new Exception("expected only included rates");
                }
                ReactionParticipant[] rps = fastReactionSteps[j].getReactionParticipants();
                ReactionParticipant rp0 = null;
                for (ReactionParticipant rp : rps) {
                    if (rp.getSpeciesContext() == sc) {
                        rp0 = rp;
                        break;
                    }
                }
                // 
                if (rp0 != null) {
                    Structure structure = fastReactionSteps[j].getStructure();
                    Expression fastRateExpression = getReactionRateExpression(fastReactionSteps[j], rp0).renameBoundSymbols(mathMapping_4_8.getNameScope());
                    if ((structure instanceof Membrane) && (rp0.getStructure() != structure)) {
                        Membrane membrane = (Membrane) structure;
                        MembraneMapping membraneMapping = (MembraneMapping) mathMapping_4_8.getSimulationContext().getGeometryContext().getStructureMapping(membrane);
                        Expression fluxCorrection = new Expression(mathMapping_4_8.getFluxCorrectionParameter(membraneMapping, (Feature) rp0.getStructure()), mathMapping_4_8.getNameScope());
                        exp = Expression.add(exp, Expression.mult(fluxCorrection, fastRateExpression));
                    } else {
                        exp = Expression.add(exp, new Expression(fastRateExpression));
                    }
                }
            }
        }
        // exp.bindExpression(mathMapping);
        scm.setFastRate(exp.flatten());
    }
    // System.out.println("StructureAnalyzer.refreshFastMatrices(), scheme matrix:");
    // fastSchemeMatrix.show();
    // 
    // update null space matrix
    // 
    fastNullSpaceMatrix = fastSchemeMatrix.findNullSpace();
// if (fastNullSpaceMatrix==null){
// System.out.println("fast system has full rank");
// }else{
// System.out.println("StructureAnalyzer.refreshFastMatrices(), nullSpace matrix:");
// fastNullSpaceMatrix.show();
// }
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) SpeciesContextMapping(cbit.vcell.mapping.SpeciesContextMapping) ReactionSpec(cbit.vcell.mapping.ReactionSpec) RationalNumberMatrix(cbit.vcell.matrix.RationalNumberMatrix) SpeciesContext(cbit.vcell.model.SpeciesContext) Feature(cbit.vcell.model.Feature) Expression(cbit.vcell.parser.Expression) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Aggregations

SpeciesContext (cbit.vcell.model.SpeciesContext)153 Structure (cbit.vcell.model.Structure)57 Expression (cbit.vcell.parser.Expression)49 ReactionStep (cbit.vcell.model.ReactionStep)48 Model (cbit.vcell.model.Model)44 ArrayList (java.util.ArrayList)37 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)32 ModelParameter (cbit.vcell.model.Model.ModelParameter)32 PropertyVetoException (java.beans.PropertyVetoException)32 ReactionParticipant (cbit.vcell.model.ReactionParticipant)30 BioModel (cbit.vcell.biomodel.BioModel)28 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)28 Species (cbit.vcell.model.Species)28 ReactionRule (cbit.vcell.model.ReactionRule)27 Feature (cbit.vcell.model.Feature)25 Membrane (cbit.vcell.model.Membrane)25 ExpressionException (cbit.vcell.parser.ExpressionException)25 SimpleReaction (cbit.vcell.model.SimpleReaction)22 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)22 Reactant (cbit.vcell.model.Reactant)20