Search in sources :

Example 81 with Structure

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

the class ReactionCartoonTool method lineAction.

private void lineAction(Structure startStructure, SpeciesContext speciesContextEnd) throws PropertyVetoException, Exception {
    Structure endStructure = speciesContextEnd.getStructure();
    Model model = getModel();
    ReactionStep reaction = null;
    Point startPos = edgeShape.getStart();
    Point endPos = edgeShape.getEnd();
    Structure reactionStructure = null;
    if (startStructure != endStructure) {
        if (startStructure instanceof Feature && endStructure instanceof Feature) {
            // Feature ==> Feature-speciesContext
            Feature startFeature = (Feature) startStructure;
            Feature endFeature = (Feature) endStructure;
            // Feature ==> feature-speciesContext with no membrane between : create a 0th-order simpleReaction in startFeature with GeneralLumpedKinetics
            reactionStructure = startStructure;
            reaction = model.createSimpleReaction(reactionStructure);
            reaction.setKinetics(new GeneralLumpedKinetics(reaction));
        } else if (startStructure instanceof Feature && endStructure instanceof Membrane) {
            // Feature ==> membrane-species : Create volume species ; create membrane reaction ; add volume species as reactant and membrane species(End) as product.
            reactionStructure = endStructure;
            reaction = model.createSimpleReaction(reactionStructure);
            SpeciesContext startingSpeciesContext = model.createSpeciesContext(startStructure);
            reaction.addReactant(startingSpeciesContext, 1);
            positionShapeForObject(startStructure, startingSpeciesContext, startPos);
        } else if (startStructure instanceof Membrane && endStructure instanceof Feature) {
            // Membrane ==> Feature-species : 0th-order reaction in membrane
            reactionStructure = startStructure;
            reaction = model.createSimpleReaction(reactionStructure);
        } else if (startStructure instanceof Membrane && endStructure instanceof Membrane) {
            // Membrane ==> membrane-species : the 2 membranes are different : create a 0th-order lumped simpleReaction in startMembrane
            reactionStructure = startStructure;
            reaction = model.createSimpleReaction(reactionStructure);
            reaction.setKinetics(new GeneralLumpedKinetics(reaction));
        }
    } else {
        // startStructure == endStructure : 0th-order simplereaction in structure
        reactionStructure = startStructure;
        reaction = model.createSimpleReaction(reactionStructure);
    }
    // speciesContextEnd should be added as a product to reaction (if not flux).
    if (!(reaction instanceof FluxReaction)) {
        reaction.addProduct(speciesContextEnd, 1);
    }
    positionShapeForObject(reactionStructure, reaction, new Point((2 * startPos.x + 8 * endPos.x) / 10, (2 * startPos.y + 8 * endPos.y) / 10));
    getReactionCartoon().notifyChangeEvent();
    getGraphModel().clearSelection();
    getGraphModel().select(reaction);
}
Also used : ReactionStep(cbit.vcell.model.ReactionStep) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) GraphModel(cbit.gui.graph.GraphModel) Membrane(cbit.vcell.model.Membrane) FluxReaction(cbit.vcell.model.FluxReaction) Point(java.awt.Point) GeneralLumpedKinetics(cbit.vcell.model.GeneralLumpedKinetics) SpeciesContext(cbit.vcell.model.SpeciesContext) Structure(cbit.vcell.model.Structure) Feature(cbit.vcell.model.Feature)

Example 82 with Structure

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

the class ReactionCartoonTool method mouseReleased.

@Override
public void mouseReleased(MouseEvent event) {
    if (getReactionCartoon() == null) {
        return;
    }
    try {
        if (dragStructTimer != null) {
            dragStructTimer.stop();
        }
        endPointWorld = getReactionCartoon().getResizeManager().unzoom(event.getPoint());
        Shape endShape = getReactionCartoon().pickWorld(endPointWorld);
        if (event.isPopupTrigger() && mode == Mode.SELECT) {
            // win, linux popup
            popupMenu(getReactionCartoon().getSelectedShape(), event.getX(), event.getY());
            return;
        }
        if (mode == Mode.SELECT && bStartRxContainerLabel) {
            resetDropTargets(null, mode == Mode.STRUCTURE);
            if (endShape != null && endShape instanceof ReactionContainerShape) {
                Rectangle labelOutlineRectangle = ((ReactionContainerShape) endShape).getLabelOutline(endShape.getAbsX(), endShape.getAbsY());
                boolean bLabel = labelOutlineRectangle.contains(startPointWorld.x, startPointWorld.y);
                getGraphPane().setCursor((bLabel ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) : Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)));
            }
            bStartRxContainerLabel = false;
            RXContainerDropTargetInfo trueRXContainerDropTargetInfo = getSelectedContainerDropTargetInfo();
            lastRXContainerDropTargetInfoMap = null;
            if (trueRXContainerDropTargetInfo == null) {
                // turn off rxDropTargetRectangles
                getGraphPane().repaint();
                return;
            }
            StructureSuite structureSuite = null;
            structureSuite = getReactionCartoon().getStructureSuite();
            if (structureSuite != null) {
                Structure[] originalOrderedStructArr = structureSuite.getStructures().toArray(new Structure[0]);
                // find where user wants to put the structure
                try {
                    if (trueRXContainerDropTargetInfo != null) {
                        ArrayList<Structure> newStructOrderList = new ArrayList<Structure>(Arrays.asList(originalOrderedStructArr));
                        newStructOrderList.remove(((ReactionContainerShape) startShape).getStructure());
                        int indexEnd = newStructOrderList.indexOf(((ReactionContainerShape) trueRXContainerDropTargetInfo.dropShape).getStructure());
                        int indexClosestNeighbor = (trueRXContainerDropTargetInfo.closestNeighborShape == null ? (trueRXContainerDropTargetInfo.insertFlag == RXContainerDropTargetInfo.INSERT_BEGINNING ? 0 : newStructOrderList.size()) : newStructOrderList.indexOf(((ReactionContainerShape) trueRXContainerDropTargetInfo.closestNeighborShape).getStructure()));
                        if (indexClosestNeighbor < indexEnd) {
                            newStructOrderList.add(indexEnd, ((ReactionContainerShape) startShape).getStructure());
                        } else {
                            newStructOrderList.add(indexClosestNeighbor, ((ReactionContainerShape) startShape).getStructure());
                        }
                        if (structureSuite instanceof AllStructureSuite) {
                            ((AllStructureSuite) structureSuite).setModelStructureOrder(true);
                        }
                        ArrayList<Diagram> newDiagramOrderList = new ArrayList<Diagram>();
                        for (Structure structure : newStructOrderList) {
                            newDiagramOrderList.add(getModel().getDiagram(structure));
                        }
                        getModel().setDiagrams(newDiagramOrderList.toArray(new Diagram[0]));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return;
        }
        // else do select and move
        switch(mode) {
            case SELECT:
                {
                    getGraphPane().setCursor(Cursor.getDefaultCursor());
                    if (bMoving) {
                        getGraphPane().invalidate();
                        ((JViewport) getGraphPane().getParent()).revalidate();
                        getGraphPane().repaint();
                        saveDiagram();
                    } else if (bRectStretch) {
                        Point absLoc = rectShape.getSpaceManager().getRelPos();
                        Dimension size = rectShape.getSpaceManager().getSize();
                        // remove temporary rectangle
                        getReactionCartoon().removeShape(rectShape);
                        rectShape = null;
                        Rectangle rect = new Rectangle(absLoc.x, absLoc.y, size.width, size.height);
                        boolean bShift = (event.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK;
                        boolean bCntrl = (event.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK;
                        selectEventFromWorld(rect, bShift, bCntrl);
                        getGraphPane().repaint();
                    }
                    bMoving = false;
                    movingShape = null;
                    bRectStretch = false;
                    rectShape = null;
                    break;
                }
            case LINEDIRECTED:
                {
                    getGraphPane().setCursor(Cursor.getDefaultCursor());
                    if (bLineStretch && getDragDistanceSquared() >= MIN_DRAG_DISTANCE_TO_CREATE_NEW_ELEMENTS_SQUARED) {
                        bLineStretch = false;
                        // set label and color for line depending on which shape the edge started.
                        // (rather than attachment area on ReactionStepShape)
                        LineType lineType = getLineTypeFromDirection(startShape, endPointWorld);
                        if (endShape instanceof SimpleReactionShape) {
                            SimpleReaction simpleReaction = (SimpleReaction) endShape.getModelObject();
                            Object startShapeObject = null;
                            if (startShape != null) {
                                startShapeObject = startShape.getModelObject();
                            }
                            if (startShapeObject instanceof SpeciesContext) {
                                SpeciesContext speciesContext = (SpeciesContext) startShapeObject;
                                lineAction(speciesContext, simpleReaction);
                            } else if (startShapeObject instanceof Structure) {
                                Structure structure = (Structure) startShapeObject;
                                lineActon(structure, simpleReaction);
                            }
                        } else if (endShape instanceof SpeciesContextShape) {
                            SpeciesContext speciesContextEnd = (SpeciesContext) endShape.getModelObject();
                            Object startShapeObject = null;
                            if (startShape != null) {
                                startShapeObject = startShape.getModelObject();
                            }
                            if (startShapeObject instanceof SimpleReaction) {
                                SimpleReaction simpleReaction = (SimpleReaction) startShapeObject;
                                lineAction(simpleReaction, speciesContextEnd);
                            } else if (startShapeObject instanceof FluxReaction) {
                                FluxReaction fluxReaction = (FluxReaction) startShapeObject;
                                lineAction(fluxReaction, speciesContextEnd);
                            } else if (startShapeObject instanceof SpeciesContext) {
                                SpeciesContext speciesContextStart = (SpeciesContext) startShapeObject;
                                if (!speciesContextStart.equals(speciesContextEnd)) {
                                    lineAction(speciesContextStart, speciesContextEnd);
                                }
                            } else if (startShapeObject instanceof Structure) {
                                Structure startStructure = (Structure) startShapeObject;
                                lineAction(startStructure, speciesContextEnd);
                            }
                        } else if (endShape instanceof FluxReactionShape) {
                            FluxReaction fluxReaction = (FluxReaction) endShape.getModelObject();
                            fluxReaction.setModel(getModel());
                            Object startShapeObject = null;
                            if (startShape != null) {
                                startShapeObject = startShape.getModelObject();
                            }
                            if (startShapeObject instanceof SpeciesContext) {
                                SpeciesContext speciesContext = (SpeciesContext) startShapeObject;
                                lineAction(speciesContext, fluxReaction);
                            } else if (startShapeObject instanceof Structure) {
                                Structure structure = (Structure) startShapeObject;
                                lineActon(structure, fluxReaction);
                            }
                            // remove temporary edge
                            getReactionCartoon().removeShape(edgeShape);
                            edgeShape = null;
                        } else if (endShape instanceof ReactionContainerShape) {
                            Structure endStructure = (Structure) endShape.getModelObject();
                            Object startObject = null;
                            if (startShape != null) {
                                startObject = startShape.getModelObject();
                            }
                            if (startObject instanceof SimpleReaction) {
                                SimpleReaction reaction = (SimpleReaction) startObject;
                                lineAction(reaction, endStructure);
                            } else if (startObject instanceof FluxReaction) {
                                FluxReaction reaction = (FluxReaction) startObject;
                                lineAction(reaction, endStructure);
                            } else if (startObject instanceof SpeciesContext) {
                                SpeciesContext speciesContextStart = (SpeciesContext) startObject;
                                lineAction(speciesContextStart, endStructure);
                            } else if (startObject instanceof Structure) {
                                Structure startStructure = (Structure) startObject;
                                lineAction(startStructure, endStructure, endShape);
                            }
                        }
                    }
                    saveDiagram();
                    break;
                }
            case LINECATALYST:
                {
                    getGraphPane().setCursor(Cursor.getDefaultCursor());
                    if (bLineStretch && getDragDistanceSquared() >= MIN_DRAG_DISTANCE_TO_CREATE_NEW_ELEMENTS_SQUARED) {
                        bLineStretch = false;
                        // set label and color for line depending on which shape the edge started.
                        // (rather than attachment area on ReactionStepShape)
                        Object startObject = startShape.getModelObject();
                        Object endObject = endShape.getModelObject();
                        ReactionStep reactionStep = null;
                        SpeciesContext speciesContext = null;
                        if (startObject instanceof ReactionStep) {
                            reactionStep = (ReactionStep) startObject;
                            if (endObject instanceof SpeciesContext) {
                                if (StructureUtil.reactionHereCanHaveParticipantThere(reactionStep.getStructure(), ((SpeciesContext) endObject).getStructure())) {
                                    speciesContext = (SpeciesContext) endObject;
                                }
                            } else if (endObject instanceof Structure) {
                                Structure endStructure = (Structure) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(reactionStep.getStructure(), endStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(endStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, speciesContext, endPos);
                                }
                            }
                        } else if (startObject instanceof SpeciesContext) {
                            speciesContext = (SpeciesContext) startObject;
                            if (endObject instanceof ReactionStep) {
                                if (StructureUtil.reactionHereCanHaveParticipantThere(((ReactionStep) endObject).getStructure(), speciesContext.getStructure())) {
                                    reactionStep = (ReactionStep) endObject;
                                }
                            } else if (endObject instanceof Structure) {
                                Structure endStructure = (Structure) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(endStructure, speciesContext.getStructure())) {
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(endStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, reactionStep, endPos);
                                }
                            }
                        } else if (startObject instanceof Structure) {
                            Structure startStructure = (Structure) startObject;
                            if (endObject instanceof ReactionStep) {
                                reactionStep = (ReactionStep) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(reactionStep.getStructure(), startStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(startStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    positionShapeForObject(startStructure, speciesContext, startPointWorld);
                                }
                            } else if (endObject instanceof SpeciesContext) {
                                speciesContext = (SpeciesContext) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(startStructure, speciesContext.getStructure())) {
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(startStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    positionShapeForObject(startStructure, reactionStep, startPointWorld);
                                }
                            } else if (endObject instanceof Structure) {
                                Structure endStructure = (Structure) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(startStructure, endStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(endStructure);
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(startStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, speciesContext, endPos);
                                    positionShapeForObject(startStructure, reactionStep, startPointWorld);
                                } else if (StructureUtil.reactionHereCanHaveParticipantThere(endStructure, startStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(startStructure);
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(endStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    positionShapeForObject(startStructure, speciesContext, startPointWorld);
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, reactionStep, endPos);
                                }
                            }
                        }
                        if (reactionStep != null && speciesContext != null) {
                            Catalyst catalyst = null;
                            for (ReactionParticipant participant : reactionStep.getReactionParticipants()) {
                                if (participant instanceof Catalyst && participant.getSpeciesContext().equals(speciesContext)) {
                                    catalyst = (Catalyst) participant;
                                }
                            }
                            if (catalyst == null) {
                                reactionStep.addCatalyst(speciesContext);
                                getReactionCartoon().notifyChangeEvent();
                            }
                        // add reactionParticipant to model
                        } else {
                            getGraphPane().repaint();
                        }
                    }
                    saveDiagram();
                    break;
                }
            default:
                {
                    break;
                }
        }
    } catch (Exception e) {
        System.out.println("CartoonTool.mouseReleased: uncaught exception");
        e.printStackTrace(System.out);
    }
    resetMouseActionHistory();
    getGraphPane().repaint();
}
Also used : SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RubberBandRectShape(cbit.gui.graph.RubberBandRectShape) ProductShape(cbit.vcell.graph.ProductShape) ContainerShape(cbit.gui.graph.ContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactantShape(cbit.vcell.graph.ReactantShape) ElipseShape(cbit.gui.graph.ElipseShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) StructureSuite(cbit.vcell.graph.structures.StructureSuite) Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) FluxReaction(cbit.vcell.model.FluxReaction) SpeciesContext(cbit.vcell.model.SpeciesContext) Structure(cbit.vcell.model.Structure) SimpleReaction(cbit.vcell.model.SimpleReaction) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) Diagram(cbit.vcell.model.Diagram) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ReactionStep(cbit.vcell.model.ReactionStep) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Example 83 with Structure

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

the class ModelDbDriver method getSpeciesContext.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.model.SpeciesContext
 * @param rset java.sql.ResultSet
 */
private SpeciesContext getSpeciesContext(QueryHashtable dbc, Connection con, ResultSet rset) throws SQLException, DataAccessException {
    // 
    // if in object cache, no need to create it
    // 
    KeyValue scKey = new KeyValue(rset.getBigDecimal(SpeciesContextModelTable.table.id.toString()));
    SpeciesContext speciesContext = (SpeciesContext) dbc.get(scKey);
    if (speciesContext != null) {
        return speciesContext;
    }
    // 
    // get foreign keys
    // 
    KeyValue structKey = new KeyValue(rset.getBigDecimal(SpeciesContextModelTable.table.structRef.toString()));
    KeyValue speciesKey = new KeyValue(rset.getBigDecimal(SpeciesContextModelTable.table.speciesRef.toString()));
    // 
    // get object (ignoring foreign keys)
    // 
    speciesContext = speciesContextModelTable.getSpeciesContext(rset, scKey);
    String speciesPatternString = speciesContext.getSpeciesPatternString();
    // 
    // add objects corresponding to foreign keys
    // 
    Structure structure = reactStepDB.getStructure(dbc, con, structKey);
    Species species = reactStepDB.getSpecies(dbc, con, speciesKey);
    speciesContext = new SpeciesContext(scKey, speciesContext.getName(), species, structure);
    speciesContext.setSpeciesPatternString(speciesPatternString);
    // 
    // put SpeciesContext into object cache
    // 
    dbc.put(scKey, speciesContext);
    return speciesContext;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SpeciesContext(cbit.vcell.model.SpeciesContext) Structure(cbit.vcell.model.Structure) Species(cbit.vcell.model.Species)

Example 84 with Structure

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

the class ModelDbDriver method getModel.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.model.Model
 * @param rset java.sql.ResultSet
 */
private Model getModel(QueryHashtable dbc, ResultSet rset, Connection con, User user) throws SQLException, DataAccessException {
    // User owner = new User(ownerName, ownerRef);
    try {
        Model model = modelTable.getModel(rset, con);
        // model.setOwner(owner);
        KeyValue modelKey = model.getVersion().getVersionKey();
        // 
        // set structures for this model
        // 
        StructureTopology structureTopology = model.getStructureTopology();
        Structure[] structures = reactStepDB.getStructuresFromModel(dbc, con, modelKey);
        if (structures != null && structures.length > 0) {
            model.setStructures(structures);
        }
        HashMap<KeyValue, StructureKeys> structureKeysMap = reactStepDB.getStructureParentMapByModel(dbc, con, modelKey);
        ReactStepDbDriver.populateStructureAndElectricalTopology(model, structureKeysMap);
        // 
        // set species for this model
        // 
        SpeciesContext[] speciesContexts = getSpeciesContextFromModel(dbc, con, user, modelKey, structureTopology);
        if (speciesContexts != null) {
            Vector<Species> speciesList = new Vector<Species>();
            for (int i = 0; i < speciesContexts.length; i++) {
                if (!speciesList.contains(speciesContexts[i].getSpecies())) {
                    speciesList.addElement(speciesContexts[i].getSpecies());
                }
            }
            Species[] speciesArray = new Species[speciesList.size()];
            speciesList.copyInto(speciesArray);
            model.setSpecies(speciesArray);
        }
        // 
        if (speciesContexts != null) {
            model.setSpeciesContexts(speciesContexts);
        }
        // 
        // Add global parameters to the model
        // 
        GlobalModelParameterTable.table.setModelParameters(con, model);
        // 
        // add reactionSteps for this model
        // 
        ReactionStep[] reactSteps = reactStepDB.getReactionStepsFromModel(dbc, con, model, modelKey);
        if (reactSteps != null) {
            model.setReactionSteps(reactSteps);
            for (int i = 0; i < reactSteps.length; i++) {
                try {
                    // 
                    // fix any improperly defined reactionSteps (which have parameters that should be catalysts)
                    // name space of kinetic parameters should be unique with respect to SpeciesContexts (so if they overlap, should be a catalyst).
                    // 
                    Kinetics.KineticsParameter[] params = reactSteps[i].getKinetics().getKineticsParameters();
                    for (int j = 0; j < params.length; j++) {
                        SpeciesContext speciesContext = model.getSpeciesContext(params[j].getName());
                        if (speciesContext != null) {
                            reactSteps[i].addCatalyst(speciesContext);
                            if (lg.isWarnEnabled())
                                lg.warn("ModelDbDriver.getModel(), Parameter '" + params[j].getName() + "' in Reaction " + reactSteps[i].getName() + " in Model(" + model.getKey() + ") conflicts with SpeciesContext, added as a catalyst");
                        }
                    }
                } catch (Throwable e) {
                    lg.error(e.getMessage(), e);
                }
                try {
                    reactSteps[i].rebindAllToModel(model);
                } catch (cbit.vcell.parser.ExpressionBindingException e) {
                    throw new DataAccessException("bindingException: " + e.getMessage());
                } catch (cbit.vcell.parser.ExpressionException e) {
                    throw new DataAccessException(e.getMessage());
                } catch (PropertyVetoException e) {
                    throw new DataAccessException("PropertyVetoException: " + e.getMessage());
                } catch (cbit.vcell.model.ModelException e) {
                    throw new DataAccessException(e.getMessage());
                }
            }
        }
        // 
        // add diagrams for this model
        // 
        Diagram[] diagrams = getDiagramsFromModel(dbc, con, modelKey, structureTopology, dbSyntax);
        model.setDiagrams(diagrams);
        // 
        // add rbm
        // 
        ModelTable.readRbmElement(con, model, dbSyntax);
        if (!model.getRbmModelContainer().isEmpty()) {
            for (SpeciesContext sc : model.getSpeciesContexts()) {
                sc.parseSpeciesPatternString(model);
            }
        }
        return model;
    } catch (PropertyVetoException e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SpeciesContext(cbit.vcell.model.SpeciesContext) Structure(cbit.vcell.model.Structure) Species(cbit.vcell.model.Species) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException) StructureTopology(cbit.vcell.model.Model.StructureTopology) Diagram(cbit.vcell.model.Diagram) PropertyVetoException(java.beans.PropertyVetoException) StructureKeys(cbit.vcell.modeldb.ReactStepDbDriver.StructureKeys) ReactionStep(cbit.vcell.model.ReactionStep) Model(cbit.vcell.model.Model)

Example 85 with Structure

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

the class ReactStepDbDriver method getStructure.

/**
 * Selects all structures that are topologically neighboring (according to the parentRef field)
 */
public Structure getStructure(QueryHashtable dbc, Connection con, KeyValue structureKey) throws SQLException, DataAccessException, ObjectNotFoundException {
    Object obj = dbc.get(structureKey);
    if (obj instanceof Structure) {
        return (Structure) obj;
    }
    String sql;
    // 
    if (dbc.get(structureKey) != null) {
        return (Structure) dbc.get(structureKey);
    }
    // log.print("ReactStepDbDriver.getStructureHeirarchy(structKey=" + structKey + ")");
    // 
    // get all structures belonging to the same model and store in temporary hashMap
    // reconcile all references between Structures
    // put final objects into global cache
    // 
    sql = " SELECT " + structTable.getTableName() + ".* " + " FROM " + structTable.getTableName() + " WHERE " + structTable.id.getQualifiedColName() + " = " + structureKey;
    // System.out.println(sql);
    Statement stmt = con.createStatement();
    Structure struct = null;
    try {
        ResultSet rset = stmt.executeQuery(sql);
        while (rset.next()) {
            KeyValue key = new KeyValue(rset.getBigDecimal(structTable.id.toString()));
            struct = structTable.getStructure(rset, key);
            dbc.put(key, struct);
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    return struct;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Structure(cbit.vcell.model.Structure)

Aggregations

Structure (cbit.vcell.model.Structure)159 SpeciesContext (cbit.vcell.model.SpeciesContext)57 Membrane (cbit.vcell.model.Membrane)47 PropertyVetoException (java.beans.PropertyVetoException)42 Feature (cbit.vcell.model.Feature)36 Model (cbit.vcell.model.Model)35 ArrayList (java.util.ArrayList)35 ReactionStep (cbit.vcell.model.ReactionStep)33 Expression (cbit.vcell.parser.Expression)33 ReactionRule (cbit.vcell.model.ReactionRule)27 ExpressionException (cbit.vcell.parser.ExpressionException)27 BioModel (cbit.vcell.biomodel.BioModel)23 StructureMapping (cbit.vcell.mapping.StructureMapping)22 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)22 Species (cbit.vcell.model.Species)21 MolecularType (org.vcell.model.rbm.MolecularType)20 ReactionParticipant (cbit.vcell.model.ReactionParticipant)19 SimpleReaction (cbit.vcell.model.SimpleReaction)19 SimulationContext (cbit.vcell.mapping.SimulationContext)18 ModelException (cbit.vcell.model.ModelException)18