Search in sources :

Example 1 with PathwayGrouping

use of org.vcell.pathway.group.PathwayGrouping 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 2 with PathwayGrouping

use of org.vcell.pathway.group.PathwayGrouping 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 3 with PathwayGrouping

use of org.vcell.pathway.group.PathwayGrouping in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method groupBioPaxObjects.

private void groupBioPaxObjects() {
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
    selected.addAll(getSelectedBioPaxObjects());
    if (selected.size() == 0)
        return;
    if (bioModel == null || bioModel.getPathwayModel() == null)
        return;
    PathwayGrouping pathwayGrouping = new PathwayGrouping();
    ArrayList<String> names = new ArrayList<String>();
    String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
    String newName = null;
    try {
        newName = DialogUtils.showInputDialog0(this, "Name of the GroupObject", id);
    } catch (UtilCancelException ex) {
    // user canceled; it's ok
    }
    if (newName != null) {
        if (newName.length() == 0) {
            PopupGenerator.showErrorDialog(this, "The Name of the GroupObject should be provided.");
        } else {
            names.add(newName);
            GroupObject groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), names, id, selected, GroupObject.Type.GROUPEDBIOPAXOBJECTS);
            if (groupObject == null) {
                // error message
                DialogUtils.showErrorDialog(this, "The set of selected objects is a subset of one group object in the model. They will not be grouped together again.");
            } else {
                bioModel.getPathwayModel().add(groupObject);
                bioModel.getPathwayModel().refreshGroupMap();
                // set the grouped object to be selected
                graphCartoonTool.getGraphModel().setSelectedObjects(new GroupObject[] { groupObject });
            }
        }
    }
    pathwayGraphModel.refreshAll();
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) PathwayGrouping(org.vcell.pathway.group.PathwayGrouping) BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) HashSet(java.util.HashSet)

Example 4 with PathwayGrouping

use of org.vcell.pathway.group.PathwayGrouping in project vcell by virtualcell.

the class PathwayModel method findTopLevelGroupAncestor.

public BioPaxObject findTopLevelGroupAncestor(BioPaxObject bpObject) {
    Map<BioPaxObject, BioPaxObject> groupMap = getGroupMap();
    PathwayGrouping pathwayGrouping = new PathwayGrouping();
    return pathwayGrouping.findGroupAncestor(groupMap, bpObject);
}
Also used : PathwayGrouping(org.vcell.pathway.group.PathwayGrouping)

Aggregations

PathwayGrouping (org.vcell.pathway.group.PathwayGrouping)4 HashSet (java.util.HashSet)3 BioPaxObject (org.vcell.pathway.BioPaxObject)3 GroupObject (org.vcell.pathway.GroupObject)3 ArrayList (java.util.ArrayList)2 Complex (org.vcell.pathway.Complex)2 Protein (org.vcell.pathway.Protein)2 SmallMolecule (org.vcell.pathway.SmallMolecule)2 List (java.util.List)1 Set (java.util.Set)1 Entity (org.vcell.pathway.Entity)1 Interaction (org.vcell.pathway.Interaction)1 InteractionParticipant (org.vcell.pathway.InteractionParticipant)1 PhysicalEntity (org.vcell.pathway.PhysicalEntity)1 UtilCancelException (org.vcell.util.UtilCancelException)1