Search in sources :

Example 1 with GroupObject

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

the class BioModelEditorPathwayDiagramPanel method importIntoModel.

public void importIntoModel() {
    if (bioModel == null) {
        return;
    }
    String warningMessage = "";
    String warningMessage2 = "";
    int warningCount = 0;
    int warningCount2 = 0;
    String infoMessage = "";
    ArrayList<BioPaxObject> importedBPObjects = new ArrayList<BioPaxObject>();
    warningMessage = "The following pathway object(s) have been associated with object(s) in the physiology model:\n";
    warningMessage2 = "The following transport reaction(s) will NOT be converted to the physiology model:\n";
    warningCount = 0;
    warningCount2 = 0;
    infoMessage = "The following pathway object(s) have been coverted in the physiology model:\n\n";
    boolean hasMembrane = false;
    if (bioModel.getModel().getMembranes().size() > 0)
        hasMembrane = true;
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
    // convert group Object to regular biopaxObjects
    for (BioPaxObject bpo : getSelectedBioPaxObjects()) {
        if (bpo instanceof GroupObject) {
            selected.addAll(((GroupObject) bpo).computeGroupedBioPaxObjects());
        } else {
            selected.add(bpo);
        }
    }
    for (BioPaxObject bpo : selected) {
        if (bpo instanceof Conversion) {
            if (bpo instanceof Transport && !hasMembrane) {
                warningCount2++;
                if (((Conversion) bpo).getName().size() > 0)
                    warningMessage2 += "\nTransport: \'" + ((Conversion) bpo).getName().get(0) + "\'\n";
                else
                    warningMessage2 += "\nTransport: \'" + ((Conversion) bpo).getIDShort() + "\'\n";
            } else if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                importedBPObjects.add(bpo);
            } else {
                warningCount++;
                if (((Conversion) bpo).getName().size() > 0)
                    warningMessage += "\nReaction: \'" + ((Conversion) bpo).getName().get(0) + "\' =>\n";
                else
                    warningMessage += "\nReaction: \'" + ((Conversion) bpo).getIDShort() + "\' =>\n";
                for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                    warningMessage += "\t=> \'" + r.getBioModelEntityObject().getName() + "\'\n";
                }
            }
        } else if (bpo instanceof PhysicalEntity) {
            if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                importedBPObjects.add(bpo);
            } else {
                warningCount++;
                if (((PhysicalEntity) bpo).getName().size() > 0)
                    warningMessage += "\nSpecies: \'" + ((PhysicalEntity) bpo).getName().get(0) + "\' =>\n";
                else
                    warningMessage += "\nSpecies: \'" + ((PhysicalEntity) bpo).getIDShort() + "\' =>\n";
                for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                    warningMessage += "\t=> \'" + r.getBioModelEntityObject().getName() + "\'\n";
                }
            }
        }
    }
    // create import panel
    conversionPanel = new ConversionPanel();
    conversionPanel.setBioModel(bioModel);
    conversionPanel.setSelectionManager(getSelectionManager());
    // show warning message
    warningMessage2 += "\nNO membrane structures available in the physiology model.\n";
    if (warningCount2 > 0) {
        DialogUtils.showWarningDialog(conversionPanel, warningMessage2);
    }
    warningMessage += "\nThey will NOT be converted to the physiology model.\n";
    if (warningCount > 0) {
        DialogUtils.showWarningDialog(conversionPanel, warningMessage);
    }
    if (importedBPObjects.size() == 0) {
        return;
    }
    // set the selected objects to be the validly imported biopaxObject set
    conversionPanel.setBioPaxObjects(importedBPObjects);
    int returnCode = DialogUtils.showComponentOKCancelDialog(this, conversionPanel, "Import into Physiology");
    if (returnCode == JOptionPane.OK_OPTION) {
        PathwayMapping pathwayMapping = new PathwayMapping();
        try {
            // function I:
            // pass the table rows that contains user edited values to create Vcell object
            pathwayMapping.createBioModelEntitiesFromBioPaxObjects(bioModel, conversionPanel.getTableRows(), conversionPanel.isAddSubunits());
            for (BioPaxObject bpo : importedBPObjects) {
                if (bpo instanceof Conversion) {
                    infoMessage += "Reaction: \t\'";
                    for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                        infoMessage += r.getBioModelEntityObject().getName() + "\'\n";
                    }
                    infoMessage += "\n";
                } else if (bpo instanceof PhysicalEntity) {
                    infoMessage += "Species: \t\'";
                    for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                        infoMessage += r.getBioModelEntityObject().getName() + "\'\n";
                    }
                    infoMessage += "\n";
                }
            }
            DialogUtils.showInfoDialog(this, infoMessage);
            // jump the view to reaction diagram panel
            if (selectionManager != null) {
                selectionManager.setActiveView(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram));
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
            DialogUtils.showErrorDialog(this, "Errors occur when converting pathway objects to VCell bioModel objects.\n" + e.getMessage());
        }
    }
}
Also used : PathwayMapping(org.vcell.relationship.PathwayMapping) BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) Conversion(org.vcell.pathway.Conversion) RelationshipObject(org.vcell.relationship.RelationshipObject) ZoomRangeException(cbit.gui.graph.GraphResizeManager.ZoomRangeException) UtilCancelException(org.vcell.util.UtilCancelException) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Transport(org.vcell.pathway.Transport) HashSet(java.util.HashSet)

Example 2 with GroupObject

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

the class BioModelEditorPathwayDiagramPanel method ungroupBioPaxObjects.

private void ungroupBioPaxObjects() {
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
    selected.addAll(getSelectedBioPaxObjects());
    if (selected.size() == 0)
        return;
    if (bioModel == null || bioModel.getPathwayModel() == null)
        return;
    for (BioPaxObject bpObject : selected) {
        if (bpObject instanceof GroupObject) {
            // remove the GroupObject from pathway model
            GroupObject group = (GroupObject) bpObject;
            ArrayList<BioPaxObject> groupElements = new ArrayList<BioPaxObject>();
            for (BioPaxObject bpo : group.getGroupedObjects()) {
                groupElements.add(bpo);
            }
            bioModel.getPathwayModel().remove(bpObject);
            // set the group elements to be selected
            graphCartoonTool.getGraphModel().setSelectedObjects(groupElements.toArray());
        }
    }
    pathwayGraphModel.refreshAll();
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) HashSet(java.util.HashSet)

Example 3 with GroupObject

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

the class BioModelEditorPathwayDiagramPanel method collapse2Complex.

private GroupObject collapse2Complex(BioPaxObject bpObject) {
    PathwayGrouping pathwayGrouping = new PathwayGrouping();
    GroupObject groupObject = null;
    HashSet<BioPaxObject> hiddenobjects = new HashSet<BioPaxObject>();
    if (bpObject instanceof Complex) {
        // collapse components
        Complex complex = (Complex) bpObject;
        Set<BioPaxObject> bioPaxObjects = new HashSet<BioPaxObject>(bioModel.getPathwayModel().getBiopaxObjects());
        for (PhysicalEntity pe : complex.getComponents()) {
            if (bioPaxObjects.contains(pe)) {
                hiddenobjects.add(pe);
            }
        }
        if (hiddenobjects.size() > 0) {
            hiddenobjects.add(bpObject);
            String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
            groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), ((Entity) bpObject).getName(), id, hiddenobjects, GroupObject.Type.GROUPEDCOMPLEX);
        } else {
            // error message
            DialogUtils.showErrorDialog(this, "No Collapse action happened because the components of the complex, " + getEntityName(complex) + ", haven't been imported to pathway model.");
        }
    } else if (bpObject instanceof Protein || bpObject instanceof SmallMolecule) {
        Set<BioPaxObject> bioPaxObjects = new HashSet<BioPaxObject>(bioModel.getPathwayModel().getBiopaxObjects());
        ArrayList<String> name = new ArrayList<String>();
        List<BioPaxObject> parents = bioModel.getPathwayModel().getParents(bpObject);
        if (parents.isEmpty()) {
            DialogUtils.showErrorDialog(this, "No Collapse action happened because protein, " + getEntityName((Entity) bpObject) + ", doesn't involve in any complexes in the pathway data.");
            return null;
        }
        for (BioPaxObject bpo : bioModel.getPathwayModel().getParents(bpObject)) {
            if (bpo instanceof Complex && bioPaxObjects.contains(bpo)) {
                hiddenobjects.add(bpo);
                name.addAll(((Complex) bpo).getName());
                for (PhysicalEntity pe : ((Complex) bpo).getComponents()) {
                    if (bioPaxObjects.contains(pe)) {
                        hiddenobjects.add(pe);
                    }
                }
            }
        }
        if (hiddenobjects.size() > 0) {
            hiddenobjects.add(bpObject);
            String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
            if (name.size() == 0) {
                name.add(id);
            }
            groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), name, id, hiddenobjects, GroupObject.Type.GROUPEDCOMPLEX);
        } else {
            // error message
            DialogUtils.showErrorDialog(this, "No Collapse action happened because complexes that relate to protein, " + getEntityName((Entity) bpObject) + ", haven't been imported to pathway model.");
        }
    }
    return groupObject;
}
Also used : PhysicalEntity(org.vcell.pathway.PhysicalEntity) Entity(org.vcell.pathway.Entity) Set(java.util.Set) HashSet(java.util.HashSet) PathwayGrouping(org.vcell.pathway.group.PathwayGrouping) BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) Protein(org.vcell.pathway.Protein) Complex(org.vcell.pathway.Complex) PhysicalEntity(org.vcell.pathway.PhysicalEntity) SmallMolecule(org.vcell.pathway.SmallMolecule) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 4 with GroupObject

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

the class BioModelEditorPathwayDiagramPanel method refreshButtons.

private void refreshButtons() {
    deleteButton.setEnabled(false);
    physiologyLinkButton.setEnabled(false);
    groupButton.setEnabled(false);
    if (showPhysiologyLinksMenuItem != null) {
        showPhysiologyLinksMenuItem.setEnabled(false);
    }
    if (editPhysiologyLinksMenuItem != null) {
        editPhysiologyLinksMenuItem.setEnabled(false);
    }
    if (importIntoModelMenuItem != null) {
        importIntoModelMenuItem.setEnabled(false);
    }
    if (groupMenuItem != null) {
        groupMenuItem.setEnabled(false);
    }
    if (ungroupMenuItem != null) {
        ungroupMenuItem.setEnabled(false);
    }
    if (expandMenuItem != null) {
        expandMenuItem.setEnabled(false);
    }
    if (collapseMenuItem != null) {
        collapseMenuItem.setEnabled(false);
    }
    if (showPhysiologyLinksMenuItem1 != null) {
        showPhysiologyLinksMenuItem1.setEnabled(false);
    }
    if (editPhysiologyLinksMenuItem1 != null) {
        editPhysiologyLinksMenuItem1.setEnabled(false);
    }
    if (importIntoModelMenuItem1 != null) {
        importIntoModelMenuItem1.setEnabled(false);
    }
    if (groupMenuItem1 != null) {
        groupMenuItem1.setEnabled(false);
    }
    if (ungroupMenuItem1 != null) {
        ungroupMenuItem1.setEnabled(false);
    }
    if (expandMenuItem1 != null) {
        expandMenuItem1.setEnabled(false);
    }
    if (collapseMenuItem1 != null) {
        collapseMenuItem1.setEnabled(false);
    }
    if (deleteMenuItem != null) {
        deleteMenuItem.setEnabled(false);
    }
    if (selectAllMenuItem != null) {
        selectAllMenuItem.setEnabled(false);
    }
    if (selectionManager != null && tabbedPane.getSelectedComponent() != sourceTabPanel) {
        ArrayList<Object> selectedObjects = selectionManager.getSelectedObjects(BioPaxObject.class);
        if (bioModel.getPathwayModel().getBiopaxObjects().size() > 0 && selectAllMenuItem != null) {
            selectAllMenuItem.setEnabled(true);
        }
        if (selectedObjects.size() > 0) {
            deleteButton.setEnabled(true);
            if (deleteMenuItem != null) {
                deleteMenuItem.setEnabled(true);
            }
            physiologyLinkButton.setEnabled(true);
            if (importIntoModelMenuItem != null) {
                importIntoModelMenuItem.setEnabled(true);
            }
            if (importIntoModelMenuItem1 != null) {
                importIntoModelMenuItem1.setEnabled(true);
            }
            if (selectedObjects.size() == 1) {
                if (bioModel.getRelationshipModel().getRelationshipObjects((BioPaxObject) selectedObjects.get(0)).size() > 0) {
                    if (showPhysiologyLinksMenuItem != null) {
                        showPhysiologyLinksMenuItem.setEnabled(true);
                    }
                    if (showPhysiologyLinksMenuItem1 != null) {
                        showPhysiologyLinksMenuItem1.setEnabled(true);
                    }
                }
                if (editPhysiologyLinksMenuItem != null) {
                    editPhysiologyLinksMenuItem.setEnabled(true);
                }
                if (editPhysiologyLinksMenuItem1 != null) {
                    editPhysiologyLinksMenuItem1.setEnabled(true);
                }
                if ((selectedObjects.get(0) instanceof GroupObject)) {
                    GroupObject selectedGroup = (GroupObject) selectedObjects.get(0);
                    if (// (selectedGroup.getType().equals(GroupObject.Type.GROUPEDCOMPLEX)) || // expand function for complex
                    (selectedGroup.getType().equals(GroupObject.Type.GROUPEDINTERACTION))) {
                        groupButton.setEnabled(true);
                        if (expandMenuItem != null) {
                            // expand function only available when one grouped complex or interaction is selected
                            expandMenuItem.setEnabled(true);
                        }
                        if (expandMenuItem1 != null) {
                            // expand function only available when one grouped complex or interaction is selected
                            expandMenuItem1.setEnabled(true);
                        }
                    }
                }
                if (// (selectedObjects.get(0) instanceof Protein) ||  // collapse function for Protein
                (selectedObjects.get(0) instanceof Interaction)) {
                    groupButton.setEnabled(true);
                    if (collapseMenuItem != null) {
                        collapseMenuItem.setEnabled(true);
                    }
                    if (collapseMenuItem1 != null) {
                        collapseMenuItem1.setEnabled(true);
                    }
                }
            }
            if (selectedObjects.size() > 1) {
                // only provide the "group" function when users select more than one object
                groupButton.setEnabled(true);
                if (groupMenuItem != null) {
                    groupMenuItem.setEnabled(true);
                }
                if (groupMenuItem1 != null) {
                    groupMenuItem1.setEnabled(true);
                }
            }
            boolean includingGroup = false;
            for (Object object : selectedObjects) {
                if (object instanceof GroupObject) {
                    includingGroup = true;
                    break;
                }
            }
            if (includingGroup) {
                // only provide the "ungroup" function when selected objects contain at least one GroupObject
                groupButton.setEnabled(true);
                if (ungroupMenuItem != null) {
                    ungroupMenuItem.setEnabled(true);
                }
                if (ungroupMenuItem1 != null) {
                    ungroupMenuItem1.setEnabled(true);
                }
            }
        }
    }
}
Also used : Interaction(org.vcell.pathway.Interaction) GroupObject(org.vcell.pathway.GroupObject) GroupObject(org.vcell.pathway.GroupObject) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 5 with GroupObject

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

the class BioModelEditorPathwayDiagramPanel method collapseComplex.

private void collapseComplex() {
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>(getSelectedBioPaxObjects());
    if (selected.size() != 1)
        return;
    if (bioModel == null || bioModel.getPathwayModel() == null)
        return;
    GroupObject groupObject = null;
    for (BioPaxObject bpObject : selected) {
        groupObject = collapse2Complex(bpObject);
    }
    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 : BioPaxObject(org.vcell.pathway.BioPaxObject) GroupObject(org.vcell.pathway.GroupObject) HashSet(java.util.HashSet)

Aggregations

GroupObject (org.vcell.pathway.GroupObject)20 BioPaxObject (org.vcell.pathway.BioPaxObject)19 HashSet (java.util.HashSet)12 ArrayList (java.util.ArrayList)6 Complex (org.vcell.pathway.Complex)5 Conversion (org.vcell.pathway.Conversion)5 InteractionParticipant (org.vcell.pathway.InteractionParticipant)5 PhysicalEntity (org.vcell.pathway.PhysicalEntity)5 Interaction (org.vcell.pathway.Interaction)4 Protein (org.vcell.pathway.Protein)4 SmallMolecule (org.vcell.pathway.SmallMolecule)4 Control (org.vcell.pathway.Control)3 MolecularInteraction (org.vcell.pathway.MolecularInteraction)3 PathwayGrouping (org.vcell.pathway.group.PathwayGrouping)3 RelationshipObject (org.vcell.relationship.RelationshipObject)3 EdgeShape (cbit.gui.graph.EdgeShape)2 Shape (cbit.gui.graph.Shape)2 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)2 Set (java.util.Set)2 Element (org.jdom.Element)2