use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.
the class PathwayReaderBiopax3 method addObjectPhysicalEntity.
private PhysicalEntity addObjectPhysicalEntity(Element element) {
if (element.getChildren().size() == 0) {
// we got lucky: no children, it means a reference -> create a proxy
PhysicalEntityProxy proxy = new PhysicalEntityProxy();
addAttributes(proxy, element);
pathwayModel.add(proxy);
return proxy;
}
for (Object child : element.getChildren()) {
if (child instanceof Element) {
Element childElement = (Element) child;
// </bp:component>
if (childElement.getName().equals("Complex")) {
Complex thingie = addObjectComplex(childElement);
pathwayModel.add(thingie);
return thingie;
} else if (childElement.getName().equals("Dna")) {
Dna thingie = addObjectDna(childElement);
pathwayModel.add(thingie);
return thingie;
} else if (childElement.getName().equals("DnaRegion")) {
DnaRegion thingie = addObjectDnaRegion(childElement);
pathwayModel.add(thingie);
return thingie;
} else if (childElement.getName().equals("Rna")) {
Rna thingie = addObjectRna(childElement);
pathwayModel.add(thingie);
return thingie;
} else if (childElement.getName().equals("RnaRegion")) {
RnaRegion thingie = addObjectRnaRegion(childElement);
pathwayModel.add(thingie);
return thingie;
} else if (childElement.getName().equals("Protein")) {
Protein thingie = addObjectProtein(childElement);
pathwayModel.add(thingie);
return thingie;
} else if (childElement.getName().equals("SmallMolecule")) {
SmallMolecule thingie = addObjectSmallMolecule(childElement);
pathwayModel.add(thingie);
return thingie;
}
}
}
PhysicalEntity physicalEntity = new PhysicalEntity();
if (element.getAttributes().size() > 0) {
// real PhysicalEntity, with ID and everything
addAttributes(physicalEntity, element);
}
for (Object child : element.getChildren()) {
if (child instanceof Element) {
Element childElement = (Element) child;
if (!addContentPhysicalEntity(physicalEntity, element, childElement)) {
showUnexpected(childElement);
}
}
}
pathwayModel.add(physicalEntity);
return physicalEntity;
}
use of org.vcell.pathway.PhysicalEntity 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.PhysicalEntity 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.PhysicalEntity 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.PhysicalEntity in project vcell by virtualcell.
the class PhysiologyRelationshipTableModel method refreshData.
private void refreshData() {
ArrayList<PhysiologyRelationshipTableRow> pathwayObjectList = new ArrayList<PhysiologyRelationshipTableRow>();
if (bioModel != null) {
HashSet<RelationshipObject> relationshipObjects = null;
if (bioModelEntityObject != null) {
relationshipObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModelEntityObject);
}
List<PhysiologyRelationshipTableRow> allPathwayObjectList = new ArrayList<PhysiologyRelationshipTableRow>();
for (BioPaxObject bpObject1 : bioModel.getPathwayModel().getBiopaxObjects()) {
if ((bpObject1 instanceof PhysicalEntity && (bioModelEntityObject == null || bioModelEntityObject instanceof SpeciesContext)) || (bpObject1 instanceof Conversion && (bioModelEntityObject == null || bioModelEntityObject instanceof ModelProcess)) || (bpObject1 instanceof PhysicalEntity && (bioModelEntityObject == null || bioModelEntityObject instanceof MolecularType))) {
PhysiologyRelationshipTableRow entityRow = new PhysiologyRelationshipTableRow(bpObject1);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioPaxObject() == entityRow.getBioPaxObject()) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allPathwayObjectList.add(entityRow);
}
}
}
if (searchText == null || searchText.length() == 0) {
pathwayObjectList.addAll(allPathwayObjectList);
} else {
for (PhysiologyRelationshipTableRow rs : allPathwayObjectList) {
BioPaxObject bpObject = rs.getBioPaxObject();
String lowerCaseSearchText = searchText.toLowerCase();
if (getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
pathwayObjectList.add(rs);
}
}
}
}
setData(pathwayObjectList);
GuiUtils.flexResizeTableColumns(ownerTable);
}
Aggregations