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