Search in sources :

Example 96 with ReactionStep

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

the class PathwayMapping method createReactionStepsFromTableRow.

private void createReactionStepsFromTableRow(BioModel bioModel, Conversion bioPaxObject, double stoich, String id, String location, ArrayList<ConversionTableRow> conversionTableRows, boolean addSubunits) throws Exception {
    // get participants of this reaction from table rows
    if (bioModel == null) {
        return;
    }
    for (Process process : BioPAXUtil.getAllProcesses(bioModel.getPathwayModel(), bioPaxObject)) {
        ArrayList<ConversionTableRow> participants = new ArrayList<ConversionTableRow>();
        for (ConversionTableRow ctr : conversionTableRows) {
            if (ctr.interactionId() == null) {
                continue;
            }
            if (ctr.interactionId().equals(bioPaxObject.getID())) {
                participants.add(ctr);
            }
        }
        // create reaction object
        String name = getSafetyName(process.getName() + "_" + location);
        ReactionStep reactionStep = bioModel.getModel().getReactionStep(name);
        if (reactionStep == null) {
            // create a new reactionStep object
            ReactionStep simpleReactionStep = bioModel.getModel().createSimpleReaction(bioModel.getModel().getStructure(location));
            simpleReactionStep.setName(name);
            RelationshipObject newRelationship = new RelationshipObject(simpleReactionStep, bioPaxObject);
            bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            createReactionStep(bioModel, process, simpleReactionStep, newRelationship, participants, addSubunits);
            addKinetics(simpleReactionStep, process);
        } else {
            // bioModel.getModel().getReactionStep(safeId).setStructure(bioModel.getModel().getStructure(location));
            // add missing parts for the existing reactionStep
            RelationshipObject newRelationship = new RelationshipObject(reactionStep, bioPaxObject);
            bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            createReactionStep(bioModel, process, reactionStep, newRelationship, participants, addSubunits);
            addKinetics(reactionStep, process);
        }
    }
}
Also used : ReactionStep(cbit.vcell.model.ReactionStep) ArrayList(java.util.ArrayList) Process(org.vcell.pathway.BioPAXUtil.Process)

Example 97 with ReactionStep

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

the class PathwayMapping method createReactionStepsFromBioPaxObject.

private void createReactionStepsFromBioPaxObject(BioModel bioModel, Conversion conversion, boolean addSubunits) throws Exception {
    if (bioModel == null) {
        return;
    }
    for (Process process : BioPAXUtil.getAllProcesses(bioModel.getPathwayModel(), conversion)) {
        String name = process.getName();
        if (bioModel.getModel().getReactionStep(name) == null) {
            // create a new reactionStep object
            ReactionStep simpleReactionStep = bioModel.getModel().createSimpleReaction(bioModel.getModel().getStructures()[0]);
            simpleReactionStep.setName(name);
            RelationshipObject newRelationship = new RelationshipObject(simpleReactionStep, conversion);
            bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            createReactionStepFromPathway(bioModel, process, simpleReactionStep, newRelationship, addSubunits);
        } else {
            // add missing parts for the existing reactionStep
            RelationshipObject newRelationship = new RelationshipObject(bioModel.getModel().getReactionStep(name), conversion);
            bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            createReactionStepFromPathway(bioModel, process, bioModel.getModel().getReactionStep(name), newRelationship, addSubunits);
        }
    }
}
Also used : ReactionStep(cbit.vcell.model.ReactionStep) Process(org.vcell.pathway.BioPAXUtil.Process)

Example 98 with ReactionStep

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

the class PathwayMapping method createReactionStepsFromTableRow.

private void createReactionStepsFromTableRow(BioModel bioModel, Conversion conversion, double stoich, String id, String location, boolean addSubunits) throws Exception {
    // use user defined id as the name of the reaction name
    if (bioModel == null) {
        return;
    }
    Set<Process> processes = BioPAXUtil.getAllProcesses(bioModel.getPathwayModel(), conversion);
    for (Process process : processes) {
        String name = getSafetyName(process.getName() + "_" + location);
        if (bioModel.getModel().getReactionStep(name) == null) {
            // create a new reactionStep object
            ReactionStep simpleReactionStep = bioModel.getModel().createSimpleReaction(bioModel.getModel().getStructure(location));
            simpleReactionStep.setName(name);
            RelationshipObject newRelationship = new RelationshipObject(simpleReactionStep, conversion);
            bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            createReactionStepFromPathway(bioModel, process, simpleReactionStep, newRelationship, addSubunits);
        } else {
            bioModel.getModel().getReactionStep(name).setStructure(bioModel.getModel().getStructure(location));
            // add missing parts for the existing reactionStep
            RelationshipObject newRelationship = new RelationshipObject(bioModel.getModel().getReactionStep(name), conversion);
            bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            createReactionStepFromPathway(bioModel, process, bioModel.getModel().getReactionStep(name), newRelationship, addSubunits);
        }
    }
}
Also used : ReactionStep(cbit.vcell.model.ReactionStep) Process(org.vcell.pathway.BioPAXUtil.Process)

Example 99 with ReactionStep

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

the class ReactionCartoonTool method mouseClicked.

@Override
public void mouseClicked(MouseEvent event) {
    Point screenPoint = new Point(event.getX(), event.getY());
    Point worldPoint = screenToWorld(screenPoint);
    try {
        if (event.getButton() != MouseEvent.BUTTON1) {
            return;
        }
        switch(mode) {
            case SELECT:
                {
                    if (event.getClickCount() == 2) {
                        final Shape selectedShape = getReactionCartoon().getSelectedShape();
                        if (selectedShape instanceof ReactionContainerShape || selectedShape instanceof SpeciesContextShape || selectedShape instanceof SimpleReactionShape || selectedShape instanceof FluxReactionShape || selectedShape instanceof ReactionRuleDiagramShape || selectedShape instanceof RuleParticipantSignatureDiagramShape) {
                            editInPlace(selectedShape, worldPoint);
                        }
                        if (selectedShape != null) {
                            menuAction(selectedShape, CartoonToolMiscActions.Properties.MENU_ACTION);
                        }
                    }
                    break;
                }
            case STEP:
                {
                    Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
                    if (pickedShape instanceof ReactionContainerShape) {
                        Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
                        if (getReactionCartoon().getStructureSuite().areReactionsShownFor(structure)) {
                            ReactionStep reactionStep = getReactionCartoon().getModel().createSimpleReaction(structure);
                            positionShapeForObject(structure, reactionStep, worldPoint);
                            saveDiagram();
                        }
                    }
                    break;
                }
            case FLUX:
                {
                    Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
                    if (pickedShape instanceof ReactionContainerShape) {
                        Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
                        if (structure instanceof Membrane) {
                            Membrane membrane = (Membrane) structure;
                            FluxReaction fluxReaction = getReactionCartoon().getModel().createFluxReaction(membrane);
                            ReactionStepShape frShape = (ReactionStepShape) getReactionCartoon().getShapeFromModelObject(fluxReaction);
                            Point parentLocation = frShape.getParent().getSpaceManager().getAbsLoc();
                            frShape.getSpaceManager().setRelPos(worldPoint.x - parentLocation.x, worldPoint.y - parentLocation.y);
                            saveDiagram();
                        // setMode(SELECT_MODE);
                        } else {
                        // setMode(SELECT_MODE);
                        // throw new Exception("fluxes only applicable to membranes");
                        }
                    }
                    break;
                }
            case SPECIES:
                {
                    Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
                    if (pickedShape instanceof ReactionContainerShape) {
                        SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(((ReactionContainerShape) pickedShape).getStructure());
                        reactionCartoon.clearSelection();
                        getGraphModel().select(speciesContext);
                        positionShapeForObject(speciesContext.getStructure(), speciesContext, worldPoint);
                        // showCreateSpeciesContextDialog(getGraphPane(), getReactionCartoon().getModel(), ((ReactionContainerShape) pickedShape).getStructure(), scShapeLocation);
                        saveDiagram();
                    }
                }
            default:
                break;
        }
    } catch (Exception e) {
        System.out.println("CartoonTool.mouseClicked: uncaught exception");
        e.printStackTrace(System.out);
        Point canvasLoc = getGraphPane().getLocationOnScreen();
        canvasLoc.x += screenPoint.x;
        canvasLoc.y += screenPoint.y;
        DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
    }
}
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) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) FluxReaction(cbit.vcell.model.FluxReaction) Point(java.awt.Point) SpeciesContext(cbit.vcell.model.SpeciesContext) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ReactionStep(cbit.vcell.model.ReactionStep) Membrane(cbit.vcell.model.Membrane) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) Structure(cbit.vcell.model.Structure)

Example 100 with ReactionStep

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

the class ReactionCartoonTool method showDeleteDetails.

private static TableListResult showDeleteDetails(Component requester, DeleteSpeciesInfo deleteSpeciesInfo, ReactionStep[] reactionStepArr, boolean bShowErrorsOnly) {
    if (reactionStepArr != null && reactionStepArr.length == 0) {
        reactionStepArr = null;
    }
    String[][] rowData = null;
    String[] columnNames = null;
    String title = null;
    if (reactionStepArr != null) {
        Arrays.sort(reactionStepArr, new Comparator<ReactionStep>() {

            @Override
            public int compare(ReactionStep o1, ReactionStep o2) {
                return o1.getName().compareToIgnoreCase(o2.getName());
            }
        });
    }
    final String OK_TO_DELETE = "ok to delete";
    final String ERROR_IF_DELETE = "ERROR if deleted";
    ArrayList<String[]> errorRows = new ArrayList<String[]>();
    if (deleteSpeciesInfo != null && reactionStepArr != null) {
        title = RXSPECIES_DELETE + " Reactions/Species." + (deleteSpeciesInfo.bAnyUnresolvable() ? "  User must resolve 'error' Flags to " + RXSPECIES_DELETE + "." : "");
        columnNames = new String[] { "Type", "Name", "Flag", "Reference" };
        rowData = new String[deleteSpeciesInfo.getRowData().length + reactionStepArr.length][4];
        final int STATUS_ROW = 2;
        for (int i = 0; i < rowData.length; i++) {
            if (i < reactionStepArr.length) {
                rowData[i][0] = "Reaction";
                rowData[i][1] = reactionStepArr[i].getName();
                rowData[i][STATUS_ROW] = OK_TO_DELETE;
                rowData[i][3] = "";
            } else {
                int index = i - reactionStepArr.length;
                rowData[i][0] = "Species";
                rowData[i][1] = deleteSpeciesInfo.getRowData()[index][0];
                rowData[i][STATUS_ROW] = (deleteSpeciesInfo.getRowData()[index][1].equals(RXSPECIES_ERROR) ? ERROR_IF_DELETE : OK_TO_DELETE);
                rowData[i][3] = deleteSpeciesInfo.getRowData()[index][2] + " " + deleteSpeciesInfo.getRowData()[index][3];
            }
            if (rowData[i][STATUS_ROW].equals(ERROR_IF_DELETE)) {
                errorRows.add(rowData[i]);
            }
        }
    } else if (deleteSpeciesInfo != null && reactionStepArr == null) {
        title = RXSPECIES_DELETE + " Species." + (deleteSpeciesInfo.bAnyUnresolvable() ? "  User must resolve 'error' Flags to " + RXSPECIES_DELETE + "." : "");
        columnNames = new String[] { "Species", "Flag", "Reference" };
        rowData = new String[deleteSpeciesInfo.getRowData().length][3];
        final int STATUS_ROW = 1;
        for (int i = 0; i < deleteSpeciesInfo.getRowData().length; i++) {
            rowData[i][0] = deleteSpeciesInfo.getRowData()[i][0];
            rowData[i][STATUS_ROW] = (deleteSpeciesInfo.getRowData()[i][1].equals(RXSPECIES_ERROR) ? ERROR_IF_DELETE : OK_TO_DELETE);
            rowData[i][2] = deleteSpeciesInfo.getRowData()[i][2] + " " + deleteSpeciesInfo.getRowData()[i][3];
            if (rowData[i][STATUS_ROW].equals(ERROR_IF_DELETE)) {
                errorRows.add(rowData[i]);
            }
        }
    } else if (deleteSpeciesInfo == null && reactionStepArr != null) {
        title = RXSPECIES_DELETE + " Reactions.";
        columnNames = new String[] { "Reactions" };
        rowData = new String[reactionStepArr.length][1];
        for (int i = 0; i < reactionStepArr.length; i++) {
            rowData[i][0] = reactionStepArr[i].getName();
        }
    } else {
        throw new IllegalArgumentException("Unknown parameter combo 'showDeleteDetails'.");
    }
    if (bShowErrorsOnly && errorRows.size() > 0) {
        rowData = errorRows.toArray(new String[0][]);
    }
    TableListResult tableListResult = DialogUtils.showComponentOptionsTableList(requester, title, columnNames, rowData, null, null, new String[] { RXSPECIES_BACK }, RXSPECIES_BACK, null);
    return tableListResult;
}
Also used : TableListResult(org.vcell.util.gui.DialogUtils.TableListResult) ReactionStep(cbit.vcell.model.ReactionStep) ArrayList(java.util.ArrayList) Point(java.awt.Point)

Aggregations

ReactionStep (cbit.vcell.model.ReactionStep)111 SpeciesContext (cbit.vcell.model.SpeciesContext)55 Structure (cbit.vcell.model.Structure)37 ReactionParticipant (cbit.vcell.model.ReactionParticipant)33 Expression (cbit.vcell.parser.Expression)33 Model (cbit.vcell.model.Model)32 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)30 ArrayList (java.util.ArrayList)29 ReactionRule (cbit.vcell.model.ReactionRule)26 ModelParameter (cbit.vcell.model.Model.ModelParameter)25 Reactant (cbit.vcell.model.Reactant)25 Kinetics (cbit.vcell.model.Kinetics)24 Product (cbit.vcell.model.Product)23 PropertyVetoException (java.beans.PropertyVetoException)23 SimpleReaction (cbit.vcell.model.SimpleReaction)20 ExpressionException (cbit.vcell.parser.ExpressionException)20 Vector (java.util.Vector)19 SimulationContext (cbit.vcell.mapping.SimulationContext)18 Membrane (cbit.vcell.model.Membrane)18 BioModel (cbit.vcell.biomodel.BioModel)17