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;
}
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();
}
}
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();
}
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);
}
Aggregations