Search in sources :

Example 6 with InteractionParticipant

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

the class PathwayGraphModel method refreshControl.

private void refreshControl(Control control) {
    Interaction controlledInteraction = control.getControlledInteraction();
    if (controlledInteraction instanceof Conversion) {
        List<InteractionParticipant> physicalControllers = control.getParticipants();
        if (physicalControllers != null) {
            Conversion conversion = (Conversion) controlledInteraction;
            BioPaxObject ancestorObject = pathwayModel.findTopLevelGroupAncestor(conversion);
            if (ancestorObject == conversion) {
                // conversion was not grouped
                BioPaxConversionShape conversionShape = (BioPaxConversionShape) getShapeFromModelObject(conversion);
                if (conversionShape != null) {
                    for (InteractionParticipant participant : physicalControllers) {
                        refreshParticipant(conversionShape, participant);
                    }
                }
            } else {
                if (ancestorObject instanceof GroupObject) {
                    // conversion has been grouped
                    GroupObject groupObject = (GroupObject) ancestorObject;
                    for (InteractionParticipant participant : physicalControllers) {
                        refreshGroupInteraction(groupObject, participant);
                    }
                }
            }
        }
    }
}
Also used : Interaction(org.vcell.pathway.Interaction) MolecularInteraction(org.vcell.pathway.MolecularInteraction) BioPaxObject(org.vcell.pathway.BioPaxObject) InteractionParticipant(org.vcell.pathway.InteractionParticipant) GroupObject(org.vcell.pathway.GroupObject) Conversion(org.vcell.pathway.Conversion)

Example 7 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant 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 8 with InteractionParticipant

use of org.vcell.pathway.InteractionParticipant 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)

Aggregations

InteractionParticipant (org.vcell.pathway.InteractionParticipant)8 BioPaxObject (org.vcell.pathway.BioPaxObject)6 GroupObject (org.vcell.pathway.GroupObject)5 Interaction (org.vcell.pathway.Interaction)5 HashSet (java.util.HashSet)3 Complex (org.vcell.pathway.Complex)3 Conversion (org.vcell.pathway.Conversion)3 PhysicalEntity (org.vcell.pathway.PhysicalEntity)3 ArrayList (java.util.ArrayList)2 Control (org.vcell.pathway.Control)2 InteractionVocabulary (org.vcell.pathway.InteractionVocabulary)2 MolecularInteraction (org.vcell.pathway.MolecularInteraction)2 Protein (org.vcell.pathway.Protein)2 SmallMolecule (org.vcell.pathway.SmallMolecule)2 EdgeShape (cbit.gui.graph.EdgeShape)1 Shape (cbit.gui.graph.Shape)1 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)1 Catalyst (cbit.vcell.model.Catalyst)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1