use of org.vcell.pathway.Control in project vcell by virtualcell.
the class PathwayGraphModel method refreshAll.
@Override
public void refreshAll() {
if (pathwayModel == null) {
clearAllShapes();
fireGraphChanged();
return;
}
unwantedShapes = new HashSet<Shape>();
unwantedShapes.addAll(getShapes());
pathwayContainerShape = (PathwayContainerShape) getShapeFromModelObject(pathwayModel);
if (pathwayContainerShape == null) {
pathwayContainerShape = new PathwayContainerShape(this, pathwayModel);
pathwayContainerShape.getSpaceManager().setSize(400, 300);
addShape(pathwayContainerShape);
}
unwantedShapes.remove(pathwayContainerShape);
Set<BioPaxObject> bioPaxObjects = new HashSet<BioPaxObject>(pathwayModel.getDisplayableBioPaxObjectList());
for (BioPaxObject bpObject : bioPaxObjects) {
BioPaxShape bpObjectShape = (BioPaxShape) getShapeFromModelObject(bpObject);
if (bpObjectShape == null) {
if (bpObject instanceof Conversion) {
bpObjectShape = new BioPaxConversionShape((Conversion) bpObject, this);
} else if (bpObject instanceof MolecularInteraction) {
bpObjectShape = new BioPaxMolecularInteractionShape((MolecularInteraction) bpObject, this);
} else if (bpObject instanceof Protein) {
bpObjectShape = new BioPaxProteinShape((Protein) bpObject, this);
} else if (bpObject instanceof Complex) {
bpObjectShape = new BioPaxComplexShape((Complex) bpObject, this);
} else if (bpObject instanceof SmallMolecule) {
bpObjectShape = new BioPaxSmallMoleculeShape((SmallMolecule) bpObject, this);
} else if (bpObject instanceof Dna) {
bpObjectShape = new BioPaxDnaShape((Dna) bpObject, this);
} else if (bpObject instanceof Rna) {
bpObjectShape = new BioPaxRnaShape((Rna) bpObject, this);
} else if (bpObject instanceof PhysicalEntity) {
bpObjectShape = new BioPaxPhysicalEntityShape((PhysicalEntity) bpObject, this);
} else if (bpObject instanceof GroupObject) {
bpObjectShape = new BioPaxGroupShape((GroupObject) bpObject, this);
} else {
bpObjectShape = new BioPaxObjectShape(bpObject, this);
}
if (!(bpObject instanceof Control)) {
// the Control objects will not be displayed on the diagram
pathwayContainerShape.addChildShape(bpObjectShape);
addShape(bpObjectShape);
}
Dimension shapeSize = bpObjectShape.getSpaceManager().getSize();
Rectangle boundary = getContainerLayout().getBoundaryForAutomaticLayout(pathwayContainerShape);
int xPos = boundary.x + random.nextInt(boundary.width - shapeSize.width);
int yPos = boundary.y + random.nextInt(boundary.height - shapeSize.height);
bpObjectShape.setAbsPos(xPos, yPos);
}
unwantedShapes.remove(bpObjectShape);
}
for (BioPaxObject bpObject : bioPaxObjects) {
if (bpObject instanceof Conversion) {
refreshInteraction((Conversion) bpObject);
} else if (bpObject instanceof MolecularInteraction) {
refreshInteraction((MolecularInteraction) bpObject);
} else if (bpObject instanceof Control) {
refreshControl((Control) bpObject);
} else if (bpObject instanceof GroupObject) {
refreshGroupObject((GroupObject) bpObject);
}
}
for (Shape unwantedShape : unwantedShapes) {
removeShape(unwantedShape);
}
refreshRelationshipInfo();
fireGraphChanged();
}
use of org.vcell.pathway.Control 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);
}
}
use of org.vcell.pathway.Control in project vcell by virtualcell.
the class BioPaxObjectPropertiesPanel method getControllersNames.
private Set<String> getControllersNames(Interaction interaction) {
Set<String> controllersNames = new HashSet<String>();
if (bioModel == null) {
return controllersNames;
}
Set<Control> controls = BioPAXUtil.getControlsOfInteraction(interaction, bioModel.getPathwayModel());
for (Control control : controls) {
if (control.getPhysicalControllers() != null) {
for (PhysicalEntity ep : control.getPhysicalControllers()) {
String type = control.getControlType();
if (type == null) {
type = "";
} else {
type = " (" + type + ")";
}
if (ep.getName().size() > 0)
controllersNames.add(ep.getName().get(0) + type);
else {
controllersNames.add(ep.getIDShort() + type);
}
}
}
}
return controllersNames;
}
use of org.vcell.pathway.Control in project vcell by virtualcell.
the class BioModelEditorConversionTableModel method refreshData.
private void refreshData() {
if (bioModel == null || bioModel.getPathwayModel() == null || bioPaxObjects == null) {
setData(null);
return;
}
// function I :: get selected objects only
// create ConversionTableRow objects
allPathwayObjectList = new ArrayList<ConversionTableRow>();
convertedBPObjects = new HashSet<BioPaxObject>();
printObjects(bioPaxObjects);
BioModel.printBpModelObjects(bioModel.getPathwayModel().getBiopaxObjects());
// BioModel.printBpRelationshipObjects(bioModel.getRelationshipModel().getBioPaxObjects()); // derived; the bpObjects that are part of a relationship
BioModel.printRelationships(bioModel.getRelationshipModel().getRelationshipObjects());
System.out.println("----------------------------------------------------------------------");
for (BioPaxObject bpo : bioPaxObjects) {
if (bpo instanceof Conversion) {
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
Conversion conversion = (Conversion) bpo;
ArrayList<String> nameList = conversion.getName();
String interactionId = conversion.getID();
String interactionLabel = nameList.isEmpty() ? conversion.getIDShort() : nameList.get(0);
ConversionTableRow newConversionTableRow = createTableRow(conversion, interactionId, interactionLabel, "Conversion", 1.0, null);
allPathwayObjectList.add(newConversionTableRow);
convertedBPObjects.add(bpo);
ArrayList<Stoichiometry> stoichiometryList = conversion.getParticipantStoichiometry();
// stoichiometryMap problem:
// how to deal with the case that the same object occurs on both left and right sides
HashMap<PhysicalEntity, Double> stoichiometryMap = createStoichiometryMap(stoichiometryList);
// reactant
for (BioPaxObject bpObject1 : conversion.getLeft()) {
Double stoich = 1.0;
if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
}
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
} else {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(bpObject1);
}
// product
for (BioPaxObject bpObject1 : conversion.getRight()) {
Double stoich = 1.0;
if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
}
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
} else {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(bpObject1);
}
// control
for (BioPaxObject bpObject : bioModel.getPathwayModel().getBiopaxObjects()) {
if (bpObject instanceof Control) {
Control control = (Control) bpObject;
if (control instanceof Catalysis) {
// catalysis
if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
for (PhysicalEntity pe : ((Catalysis) control).getPhysicalControllers()) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
} else {
// other control types
if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
for (PhysicalEntity pe : control.getPhysicalControllers()) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
}
}
}
}
} else if (bpo instanceof Catalysis) {
for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
if (!convertedBPObjects.contains(pe)) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
// TODO
}
} else if (bpo instanceof Control) {
for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
if (!convertedBPObjects.contains(pe)) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
// TODO
}
}
}
// 2nd pass - entities selected as themselves
for (BioPaxObject bpo : bioPaxObjects) {
if (bpo instanceof PhysicalEntity) {
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
PhysicalEntity physicalEntityObject = (PhysicalEntity) bpo;
// we add standalone selected entities, only if they were not already added as part of any reaction
if (!convertedBPObjects.contains(physicalEntityObject)) {
ConversionTableRow conversionTableRow = createTableRow(physicalEntityObject, "", "", "", 1.0, null);
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(physicalEntityObject);
}
}
}
}
// apply text search function for particular columns
ArrayList<ConversionTableRow> pathwayObjectList = new ArrayList<ConversionTableRow>();
if (searchText == null || searchText.length() == 0) {
pathwayObjectList.addAll(allPathwayObjectList);
} else {
String lowerCaseSearchText = searchText.toLowerCase();
for (ConversionTableRow rs : allPathwayObjectList) {
BioPaxObject bpObject = rs.getBioPaxObject();
if (rs.interactionLabel().toLowerCase().contains(lowerCaseSearchText) || rs.participantType().toLowerCase().contains(lowerCaseSearchText) || getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
pathwayObjectList.add(rs);
}
}
}
setData(pathwayObjectList);
GuiUtils.flexResizeTableColumns(ownerTable);
}
use of org.vcell.pathway.Control in project vcell by virtualcell.
the class PathwayTableModel method refreshData.
private void refreshData() {
if (pathwayModel == null) {
setData(null);
return;
}
List<BioPaxObject> allPathwayObjectList = new ArrayList<BioPaxObject>();
for (BioPaxObject bpObject1 : pathwayModel.getBiopaxObjects()) {
if (bpObject1 instanceof PhysicalEntity || (bpObject1 instanceof Interaction && !(bpObject1 instanceof Control))) {
allPathwayObjectList.add(bpObject1);
}
}
ArrayList<BioPaxObject> pathwayObjectList = new ArrayList<BioPaxObject>();
for (BioPaxObject bpObject : allPathwayObjectList) {
if (searchText == null || searchText.length() == 0 || getLabel(bpObject).toLowerCase().contains(searchText.toLowerCase()) || getType(bpObject).toLowerCase().contains(searchText.toLowerCase())) {
pathwayObjectList.add(bpObject);
bioPaxObjectImportedMap.put(bpObject, bioModel != null && bioModel.getPathwayModel().find(bpObject) != null);
}
}
setData(pathwayObjectList);
}
Aggregations