Search in sources :

Example 26 with BioPaxObject

use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.

the class PathwayGraphModel method refreshRelationshipInfo.

protected void refreshRelationshipInfo(Shape shape) {
    if (shape instanceof BioPaxShape) {
        BioPaxShape bpShape = (BioPaxShape) shape;
        BioPaxObject bpObject = bpShape.getBioPaxObject();
        boolean hasRelationships = false;
        if (bioModel != null) {
            HashSet<RelationshipObject> relationships = bioModel.getRelationshipModel().getRelationshipObjects(bpObject);
            if (relationships.size() > 0) {
                hasRelationships = true;
            }
        }
        bpShape.setHasRelationships(hasRelationships);
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 27 with BioPaxObject

use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.

the class PathwayGraphModel method refreshGroupInteraction.

private void refreshGroupInteraction(GroupObject groupObject, InteractionParticipant participant) {
    BioPaxGroupShape groupShape = (BioPaxGroupShape) getShapeFromModelObject(groupObject);
    PhysicalEntity physicalEntity = participant.getPhysicalEntity();
    GroupNeighbor groupNeighbor = new GroupNeighbor(groupObject, physicalEntity, participant.getType());
    BioPaxGroupNeighborShape edgeShape = (BioPaxGroupNeighborShape) getShapeFromModelObject(groupNeighbor);
    BioPaxObject ancestorObject = pathwayModel.findTopLevelGroupAncestor(physicalEntity);
    if (edgeShape == null) {
        Shape shape = getShapeFromModelObject(physicalEntity);
        if (shape instanceof BioPaxPhysicalEntityShape) {
            BioPaxPhysicalEntityShape physicalEntityShape = (BioPaxPhysicalEntityShape) shape;
            edgeShape = new BioPaxGroupNeighborShape(groupNeighbor, groupShape, physicalEntityShape, this);
            pathwayContainerShape.addChildShape(edgeShape);
            addShape(edgeShape);
        }
    } else {
        // edges without end objects will be removed
        if (ancestorObject != physicalEntity) {
            // for grouped objects
            removeEdgeShape(edgeShape);
        }
    }
    unwantedShapes.remove(refreshGroup(pathwayContainerShape, ancestorObject, groupShape, participant));
    unwantedShapes.remove(edgeShape);
}
Also used : PhysicalEntity(org.vcell.pathway.PhysicalEntity) EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) GroupNeighbor(org.vcell.pathway.GroupNeighbor) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 28 with BioPaxObject

use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method collapseBioPaxObject.

private void collapseBioPaxObject() {
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>(getSelectedBioPaxObjects());
    if (selected.size() == 0)
        return;
    if (bioModel == null || bioModel.getPathwayModel() == null)
        return;
    PathwayGrouping pathwayGrouping = new PathwayGrouping();
    GroupObject groupObject = null;
    HashSet<BioPaxObject> hiddenobjects = new HashSet<BioPaxObject>();
    for (BioPaxObject bpObject : selected) {
        hiddenobjects.clear();
        if (bpObject instanceof Complex || bpObject instanceof Protein || bpObject instanceof SmallMolecule) {
            // collapse complex with physicalEntities
            groupObject = collapse2Complex(bpObject);
        } else if (bpObject instanceof Interaction) {
            for (InteractionParticipant itp : ((Interaction) bpObject).getParticipants()) {
                hiddenobjects.add(itp.getPhysicalEntity());
            }
            hiddenobjects.add(bpObject);
            String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
            groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), ((Entity) bpObject).getName(), id, hiddenobjects, GroupObject.Type.GROUPEDINTERACTION);
        }
    }
    if (groupObject != null) {
        bioModel.getPathwayModel().add(groupObject);
        bioModel.getPathwayModel().refreshGroupMap();
        // set the grouped object to be selected
        graphCartoonTool.getGraphModel().setSelectedObjects(new GroupObject[] { groupObject });
        pathwayGraphModel.refreshAll();
    }
}
Also used : PathwayGrouping(org.vcell.pathway.group.PathwayGrouping) SmallMolecule(org.vcell.pathway.SmallMolecule) BioPaxObject(org.vcell.pathway.BioPaxObject) Interaction(org.vcell.pathway.Interaction) InteractionParticipant(org.vcell.pathway.InteractionParticipant) GroupObject(org.vcell.pathway.GroupObject) Protein(org.vcell.pathway.Protein) HashSet(java.util.HashSet) Complex(org.vcell.pathway.Complex)

Example 29 with BioPaxObject

use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method deleteSelectedBioPaxObjects.

public static void deleteSelectedBioPaxObjects(Component guiRequester, BioModel bioModel, GraphModel graphModel) {
    StringBuilder warning = new StringBuilder("You can NOT delete the following pathway objects:\n\n");
    StringBuilder text = new StringBuilder("You are going to DELETE the following pathway objects:\n\n");
    // all objects required by user
    List<BioPaxObject> selected = getSelectedBioPaxObjects(graphModel);
    // the user required objects that can be deleted
    List<BioPaxObject> selectedBioPaxObjects = new ArrayList<BioPaxObject>();
    // all objects that will be deleted from the pathway model
    List<BioPaxObject> completeSelectedBioPaxObjects = new ArrayList<BioPaxObject>();
    // used for recover group objects
    HashSet<GroupObject> undeletedGroupObjects = new HashSet<GroupObject>();
    // all objects required by user + grouped elements contained in selected group objects
    List<BioPaxObject> allSelectedBioPaxObjects = new ArrayList<BioPaxObject>();
    // build a list of selected objects with selected grouped elements
    for (BioPaxObject bpObject : selected) {
        if (bpObject instanceof GroupObject) {
            // all elements of the groupObject will be deleted
            allSelectedBioPaxObjects.add(bpObject);
            // check all elements
            allSelectedBioPaxObjects.addAll(getAllGroupedObjects((GroupObject) bpObject));
        } else {
            allSelectedBioPaxObjects.add(bpObject);
        }
    }
    // if so, whether participants and catalysts of a selected reaction can be deleted
    for (BioPaxObject bpObject : allSelectedBioPaxObjects) {
        if (canDelete(bioModel, allSelectedBioPaxObjects, bpObject)) {
            selectedBioPaxObjects.add(bpObject);
            text.append("    " + bpObject.getTypeLabel() + ": \'" + PhysiologyRelationshipTableModel.getLabel(bpObject) + "\'\n");
            completeSelectedBioPaxObjects.add(bpObject);
            if (bpObject instanceof Conversion) {
                // check each participant
                for (InteractionParticipant ip : ((Conversion) bpObject).getParticipants()) {
                    if (canDelete(bioModel, allSelectedBioPaxObjects, ip.getPhysicalEntity())) {
                        completeSelectedBioPaxObjects.add(ip.getPhysicalEntity());
                        // the complex of the pysicalEntity will be removed
                        for (Complex complex : getComplex(bioModel, ip.getPhysicalEntity())) {
                            if (canDelete(bioModel, allSelectedBioPaxObjects, complex))
                                completeSelectedBioPaxObjects.add(complex);
                        }
                    }
                }
                // check catalysts
                for (BioPaxObject bp : bioModel.getPathwayModel().getBiopaxObjects()) {
                    if (bp instanceof Control) {
                        Control control = (Control) bp;
                        if (control.getControlledInteraction() == bpObject) {
                            completeSelectedBioPaxObjects.add(bp);
                            for (PhysicalEntity pe : control.getPhysicalControllers()) {
                                if (canDelete(bioModel, allSelectedBioPaxObjects, pe))
                                    completeSelectedBioPaxObjects.add(pe);
                            }
                        }
                    }
                }
            } else if (bpObject instanceof GroupObject) {
                // all elements of the groupObject will be deleted
                completeSelectedBioPaxObjects.add(bpObject);
                // check all elements
                completeSelectedBioPaxObjects.addAll(getAllGroupedObjects((GroupObject) bpObject));
            }
        } else {
            warning.append("    " + bpObject.getTypeLabel() + ": \'" + PhysiologyRelationshipTableModel.getLabel(bpObject) + "\'\n");
            if (bpObject instanceof GroupObject) {
                undeletedGroupObjects.add((GroupObject) bpObject);
            }
        }
    }
    warning.append("\nThey are either required by other reactions or linked with other physiological objects.\n\n");
    // for(GroupObject gObject : undeletedGroupObjects){
    // for (BioPaxObject bpo : gObject.getGroupedObjects()){
    // completeSelectedBioPaxObjects.remove(bpo);
    // }
    // }
    StringBuilder finalWarningMessage = new StringBuilder();
    if (allSelectedBioPaxObjects.size() > selectedBioPaxObjects.size()) {
        finalWarningMessage.append(warning.toString() + "\n\n");
    }
    if (selectedBioPaxObjects.size() > 0) {
        text.append("\nContinue?");
        finalWarningMessage.append(text.toString());
    }
    if (finalWarningMessage.length() == 0) {
        return;
    }
    String confirm = DialogUtils.showOKCancelWarningDialog(guiRequester, "Deleting pathway objects", finalWarningMessage.toString());
    if (confirm.equals(UserMessage.OPTION_CANCEL)) {
        return;
    }
    if (completeSelectedBioPaxObjects.size() > 0) {
        bioModel.getPathwayModel().remove(completeSelectedBioPaxObjects);
        bioModel.getPathwayModel().cleanGroupObjects();
        bioModel.getRelationshipModel().removeRelationshipObjects(completeSelectedBioPaxObjects);
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) Conversion(org.vcell.pathway.Conversion) Complex(org.vcell.pathway.Complex) Control(org.vcell.pathway.Control) PhysicalEntity(org.vcell.pathway.PhysicalEntity) InteractionParticipant(org.vcell.pathway.InteractionParticipant) HashSet(java.util.HashSet)

Example 30 with BioPaxObject

use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method getSelectedBioPaxObject.

private BioPaxObject getSelectedBioPaxObject() {
    ArrayList<Object> selectedObjects = selectionManager.getSelectedObjects(BioPaxObject.class);
    BioPaxObject selectedBioPaxObject = null;
    if (selectedObjects.size() == 1 && selectedObjects.get(0) instanceof BioPaxObject) {
        selectedBioPaxObject = (BioPaxObject) selectedObjects.get(0);
    }
    return selectedBioPaxObject;
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) GroupObject(org.vcell.pathway.GroupObject) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Aggregations

BioPaxObject (org.vcell.pathway.BioPaxObject)53 GroupObject (org.vcell.pathway.GroupObject)21 ArrayList (java.util.ArrayList)15 HashSet (java.util.HashSet)14 PhysicalEntity (org.vcell.pathway.PhysicalEntity)14 RelationshipObject (org.vcell.relationship.RelationshipObject)14 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)9 Conversion (org.vcell.pathway.Conversion)9 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)8 SpeciesContext (cbit.vcell.model.SpeciesContext)7 Entity (org.vcell.pathway.Entity)7 Complex (org.vcell.pathway.Complex)6 Control (org.vcell.pathway.Control)6 InteractionParticipant (org.vcell.pathway.InteractionParticipant)6 Dimension (java.awt.Dimension)5 MouseAdapter (java.awt.event.MouseAdapter)5 MouseEvent (java.awt.event.MouseEvent)5 JLabel (javax.swing.JLabel)5 JPanel (javax.swing.JPanel)5 MolecularType (org.vcell.model.rbm.MolecularType)5