use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.
the class BioPaxObjectPropertiesPanel method refreshInterface.
protected void refreshInterface() {
if (bioPaxObject == null) {
// sanity check
return;
}
ArrayList<BioPaxObjectProperty> propertyList = new ArrayList<BioPaxObjectProperty>();
if (!(bioPaxObject instanceof SBEntity)) {
tableModel.setData(propertyList);
return;
}
SBEntity sbEntity = (SBEntity) bioPaxObject;
if (!(sbEntity instanceof Entity)) {
tableModel.setData(propertyList);
return;
}
Entity entity = (Entity) sbEntity;
// entity::type
propertyList.add(new BioPaxObjectProperty("Type", bioPaxObject.getTypeLabel()));
if (lookupContains(entity)) {
propertyList.add(new BioPaxObjectProperty("Name", entity.getName().get(0) + " (looking...)"));
} else if (entity.getFormalNames() != null && entity.getFormalNames().size() != 0) {
propertyList.add(new BioPaxObjectProperty("Name", entity.getName().get(0) + " (" + entity.getFormalNames().get(0) + ")"));
} else if (entity.getName() != null && entity.getName().size() > 0) {
String displayName = entity.getName().get(0);
if (entity.getxRef() != null && entity.getxRef().size() > 0) {
displayName = displayName + " (double-click lookup)";
}
// entity::name
propertyList.add(new BioPaxObjectProperty("Name", displayName));
}
// entity::Link
for (RelationshipObject rObject : bioModel.getRelationshipModel().getRelationshipObjects(bioPaxObject)) {
BioModelEntityObject beObject = rObject.getBioModelEntityObject();
String sType = beObject.getDisplayType();
propertyList.add(new BioPaxObjectProperty("Linked physiology object (" + sType + ")", beObject.getName(), beObject));
}
if (entity instanceof PhysicalEntity) {
// ------------------------ PHYSICAL ENTITY -----------------------
PhysicalEntity physicalEntity = (PhysicalEntity) entity;
// physicalEntity::feature (***ignored***)
// physicalEntity::memberPhysicalEntity (***ignored***)
// physicalEntity::notFeature (***ignored***)
// TODO: extract the kinetic law, then the SBEntities, then the measurables, units, aso
boolean isReactionParticipant = BioPAXUtil.isReactionParticipant(physicalEntity, bioModel.getPathwayModel());
String role = "";
if (BioPAXUtil.isController(physicalEntity, bioModel.getPathwayModel())) {
role += "Controller";
if (isReactionParticipant) {
role += ", Participant";
}
} else if (isReactionParticipant) {
role += "Participant";
}
if (!role.isEmpty()) {
propertyList.add(new BioPaxObjectProperty("Role(s)", role));
}
if (!(physicalEntity instanceof SmallMolecule)) {
// physicalEntity::cellular location
CellularLocationVocabulary cellularLocation = physicalEntity.getCellularLocation();
if (cellularLocation != null && cellularLocation.getTerm() != null && cellularLocation.getTerm().size() > 0) {
propertyList.add(new BioPaxObjectProperty("Cellular Location", cellularLocation.getTerm().get(0), cellularLocation));
} else if (entity.getName() != null && entity.getName().size() > 1) {
String location = entity.getName().get(1);
if (location.contains("[") && location.contains("]")) {
location = location.substring(location.indexOf("[") + 1, location.indexOf("]"));
propertyList.add(new BioPaxObjectProperty("Cellular Location", location));
}
}
}
if (physicalEntity instanceof Complex) {
Complex complex = (Complex) physicalEntity;
// complex::components
for (PhysicalEntity pe : complex.getComponents()) {
propertyList.add(new BioPaxObjectProperty("Component", getEntityName(pe), pe));
}
} else if (physicalEntity instanceof Protein) {
// Protein protein = (Protein)entity;
// protein::entity reference (***ignored***)
} else if (physicalEntity instanceof SmallMolecule) {
SmallMolecule sm = (SmallMolecule) physicalEntity;
EntityReference er = sm.getEntityReference();
if (er != null && !er.getName().isEmpty() && er.getName().get(0) != null && !er.getName().get(0).isEmpty()) {
propertyList.add(new BioPaxObjectProperty("Entity Reference", er.getName().get(0)));
ArrayList<Xref> xrefList = er.getxRef();
for (Xref xref : xrefList) {
propertyList.add(new BioPaxObjectProperty(" Xref", xref.getDb() + ":" + xref.getId(), xref));
}
}
} else if (physicalEntity instanceof Dna) {
// dna::entityReference (***ignored***)
} else if (physicalEntity instanceof DnaRegion) {
// dnaRegion::entityReference (***ignored***)
} else if (physicalEntity instanceof Rna) {
// rna::entityReference (***ignored***)
} else if (physicalEntity instanceof RnaRegion) {
// rnaRegion::entityReference (***ignored***)
}
} else if (entity instanceof Interaction) {
// --------------------------- INTERACTION -------------------
Interaction interaction = (Interaction) entity;
// interaction::interactionType
for (InteractionVocabulary interactionVocabulary : interaction.getInteractionTypes()) {
if (interactionVocabulary.getTerm().size() > 0) {
propertyList.add(new BioPaxObjectProperty("Interaction Type", interactionVocabulary.getTerm().get(0), interactionVocabulary));
}
}
// interaction::participants
for (InteractionParticipant interactionParticipant : interaction.getParticipants()) {
PhysicalEntity physicalEntity = interactionParticipant.getPhysicalEntity();
String physicalEntityName = physicalEntity.getName().size() > 0 ? physicalEntity.getName().get(0) : physicalEntity.getIDShort();
String cellularLocation = "";
if (physicalEntity.getCellularLocation() != null) {
cellularLocation = physicalEntity.getCellularLocation().getTerm().size() > 0 ? " [" + physicalEntity.getCellularLocation().getTerm().get(0) + "]" : "";
}
propertyList.add(new BioPaxObjectProperty(interactionParticipant.getLevel3PropertyName(), physicalEntityName + cellularLocation, physicalEntity));
}
// get the controllers for interactions
// we always need this because there's no guarantee we'll have kinetic laws
// for instance pathway commons doesn't have quantitative information
Set<String> controllersNames = getControllersNames(interaction);
if (controllersNames.size() > 0) {
for (String str : controllersNames) {
// String tooltip = "<html>how many of these 12 M <br>average size 1.12345*E12 nm <br>temperature 37 degrees Celsius</html>";
String tooltip = "";
propertyList.add(new BioPaxObjectProperty("Controlled by", str, interaction, tooltip));
}
}
// get the kinetic laws (if any)
Set<Control> controls = BioPAXUtil.getControlsOfInteraction(interaction, bioModel.getPathwayModel());
for (Control control : controls) {
ArrayList<SBEntity> sbEntities = control.getSBSubEntity();
for (SBEntity sbE : sbEntities) {
// the only SBSubEntities allowed in a control are kinetic laws
if (sbE.getID().contains("kineticLaw")) {
String str = new String();
if (control.getPhysicalControllers() != null) {
str += " for Controller(s): ";
for (PhysicalEntity ep : control.getPhysicalControllers()) {
if (ep.getName().size() > 0) {
str += ep.getName().get(0);
} else {
str += ep.getIDShort();
}
str += " ";
}
}
String sDetails = "";
ArrayList<SBVocabulary> sbTerms = sbE.getSBTerm();
for (SBVocabulary sbv : sbTerms) {
// type of kinetic law
String str1 = sbv.getID();
str1 = str1.substring(str1.lastIndexOf('#') + 1);
System.out.println(str1);
SBOTerm sboT = SBOListEx.sboMap.get(str1);
sDetails += "<font color=\"#660000\"><b>" + sboT.getName() + "</b></font>" + " " + "<font color=\"#006600\">" + sboT.getDescription() + "</font>";
sDetails += "<br>";
}
ArrayList<SBEntity> klProperties = sbE.getSBSubEntity();
for (SBEntity klProperty : klProperties) {
if (klProperty instanceof SBMeasurable) {
SBMeasurable m = (SBMeasurable) klProperty;
String str1 = "";
String str2 = "";
String str3 = "";
if (m.hasTerm()) {
str1 += m.extractSBOTermAsString();
}
if (m.hasNumber()) {
str2 += m.getNumber().get(0);
}
if (m.hasUnit()) {
str3 += m.extractSBOUnitAsString();
}
// str1 is an SBO id, for example "SBO:0000064"
SBOTerm sboT = SBOListEx.sboMap.get(str1);
sDetails += sboT.getSymbol() + " (" + sboT.getName() + ")" + "<font color=\"#660000\"><b>" + str2 + str3 + "</b></font>" + " " + "<font color=\"#006600\">" + sboT.getDescription() + "</font>";
} else {
sDetails = klProperty.getIDShort() + " " + klProperty.getTypeLabel();
}
sDetails += "<br>";
}
// String tooltip = "<html>how many of these 12 M <br>average size 1.12345*E12 nm <br>temperature 37 degrees Celsius</html>";
String tooltip = "";
BioPaxObjectProperty bpop = new BioPaxObjectProperty("Kinetic Law" + str, sbE.getID(), sbE, tooltip);
bpop.setDetails(sDetails);
propertyList.add(bpop);
}
}
}
if (interaction instanceof Control) {
// TODO: is this ever being called?
Control c = (Control) interaction;
// catalysis::controlled
Interaction controlledInteraction = c.getControlledInteraction();
if (controlledInteraction != null) {
String controlledName = controlledInteraction.getIDShort();
if (controlledInteraction.getName().size() > 0) {
controlledName = controlledInteraction.getName().get(0);
}
propertyList.add(new BioPaxObjectProperty("Controlled Interaction", controlledName, controlledInteraction));
}
}
} else if (entity instanceof GroupObject) {
// ---------------------- GROUP OBJECT ------------------
GroupObject groupObject = (GroupObject) entity;
for (BioPaxObject bpo : groupObject.getGroupedObjects()) {
propertyList.add(new BioPaxObjectProperty("Element::" + bpo.getTypeLabel(), getEntityName((Entity) bpo), bpo));
}
}
// entity::comments
for (String comment : entity.getComments()) {
propertyList.add(new BioPaxObjectProperty("Comment", comment));
}
// entity::xRef
ArrayList<Xref> xrefList = ((Entity) bioPaxObject).getxRef();
for (Xref xref : xrefList) {
if (xref instanceof UnificationXref) {
propertyList.add(new BioPaxObjectProperty("Xref", xref.getDb() + ":" + xref.getId(), xref));
}
}
for (Xref xref : xrefList) {
if (xref instanceof RelationshipXref) {
propertyList.add(new BioPaxObjectProperty("Xref (related)", xref.getDb() + ":" + xref.getId(), xref));
}
}
for (Xref xref : xrefList) {
if (xref instanceof PublicationXref) {
propertyList.add(new BioPaxObjectProperty("Publication", xref.getDb() + ":" + xref.getId(), xref));
}
}
// for(SBVocabulary sbVocab : sbEntity.getSBTerm()) {
// propertyList.add(new BioPaxObjectProperty("SBO Term", SBPAXLabelUtil.makeLabel(sbVocab)));
// }
// if(sbEntity instanceof Interaction) {
// // TODO: this goes away
// Interaction interaction = (Interaction) sbEntity;
// Set<SBEntity> subEntities = new HashSet<SBEntity>();
// subEntities.add(interaction);
// Set<Control> controls = BioPAXUtil.findAllControls(interaction, bioModel.getPathwayModel());
// subEntities.addAll(controls);
// subEntities = SBPAX3Util.extractAllEntities(subEntities);
// for(SBEntity subEntity : subEntities) {
// if(subEntity instanceof SBMeasurable) {
// propertyList.add(new BioPaxObjectProperty("Measured quantity", SBPAXLabelUtil.makeLabel(subEntity)));
// }
// }
// }
tableModel.setData(propertyList);
}
use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.
the class PathwayGraphModel method removeEdgeShape.
private void removeEdgeShape(EdgeShape shape) {
PhysicalEntity physicalEntity = null;
if (shape instanceof BioPaxInteractionParticipantShape) {
BioPaxInteractionParticipantShape edgeShape = (BioPaxInteractionParticipantShape) shape;
physicalEntity = ((InteractionParticipant) edgeShape.getModelObject()).getPhysicalEntity();
} else if (shape instanceof BioPaxGroupNeighborShape) {
BioPaxGroupNeighborShape edgeShape = (BioPaxGroupNeighborShape) shape;
BioPaxObject bpObject = ((GroupNeighbor) edgeShape.getModelObject()).getNeighbor();
if (bpObject instanceof PhysicalEntity) {
physicalEntity = (PhysicalEntity) bpObject;
}
}
if (physicalEntity == null)
return;
if (!pathwayModel.getDisplayableBioPaxObjectList().contains(physicalEntity)) {
removeShape(shape);
}
}
use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.
the class PathwayReader method addContentConversion.
private boolean addContentConversion(Conversion conversion, Element element, Element childElement) {
if (addContentInteraction(conversion, element, childElement)) {
return true;
}
/**
* String getConversionDirection();
* ArrayList<PhysicalEntity> getLeftSide();
* ArrayList<Stoichiometry> getParticipantStoichiometry();
* ArrayList<PhysicalEntity> getRightSide();
* Boolean getSpontaneous();
*/
if (childElement.getName().equals("LEFT") || childElement.getName().equals("RIGHT")) {
Element physicalEntityParticipantElement = childElement.getChild("physicalEntityParticipant", bp);
if (physicalEntityParticipantElement != null) {
boolean found = false;
PhysicalEntity thePhysicalEntity = null;
Element physicalEntityPropertyElement = physicalEntityParticipantElement.getChild("PHYSICAL-ENTITY", bp);
// always create a proxy, the real PhysicalEntity (if present) is not ready to be inserted as is because it is incomplete
// the reason is that PhysicalEntity object is a "species" in v2 but becomes a "species context" in v3
PhysicalEntityProxy physicalEntityProxy = null;
if (physicalEntityPropertyElement != null) {
found = true;
physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
if (childElement.getName().equals("LEFT")) {
conversion.addLeft(physicalEntityProxy);
} else {
conversion.addRight(physicalEntityProxy);
}
if (physicalEntityPropertyElement.getChildren().size() > 0) {
thePhysicalEntity = addObjectPhysicalEntity(physicalEntityPropertyElement);
}
}
Element cellularLocationElement = physicalEntityParticipantElement.getChild("CELLULAR-LOCATION", bp);
if (cellularLocationElement != null && found == true) {
Element controlledVocabularyElement = cellularLocationElement.getChild("openControlledVocabulary", bp);
if (controlledVocabularyElement != null) {
CellularLocationVocabularyProxy cellularLocationVocabularyProxy = new CellularLocationVocabularyProxy();
addAttributes(cellularLocationVocabularyProxy, controlledVocabularyElement);
pathwayModel.add(cellularLocationVocabularyProxy);
if (controlledVocabularyElement.getChildren().size() == 0) {
physicalEntityProxy.setCellularLocation(cellularLocationVocabularyProxy);
} else {
physicalEntityProxy.setCellularLocation(addObjectCellularLocationVocabulary(controlledVocabularyElement));
}
// System.out.println(" - " + controlledVocabularyElement.getName());
// we'll use the extra info in this proxy during reconciliation phase to reconstruct a complete PhysicalEntity
}
}
Element stoichiometricCoefficientElement = physicalEntityParticipantElement.getChild("STOICHIOMETRIC-COEFFICIENT", bp);
if (stoichiometricCoefficientElement != null && found == true) {
// System.out.println(" - " + stoichiometricCoefficientElement.getTextTrim());
// Create a Stoichiometry object from the stoichiometricCoefficient and from PhysicalEntity object
Stoichiometry stoichiometry = new Stoichiometry();
stoichiometry.setID(generateInstanceID());
stoichiometry.setStoichiometricCoefficient(Double.valueOf(stoichiometricCoefficientElement.getTextTrim()));
if (physicalEntityProxy == null) {
// reuse the proxy if we created one already
physicalEntityProxy = new PhysicalEntityProxy();
String uri = context.unRelativizeURI(physicalEntityPropertyElement, generateResourceID(physicalEntityPropertyElement));
physicalEntityProxy.setID(uri);
pathwayModel.add(physicalEntityProxy);
}
stoichiometry.setPhysicalEntity(physicalEntityProxy);
// Add the Stoichiometry object to the participantStoichiometry property of the conversion
conversion.getParticipantStoichiometry().add(stoichiometry);
// add the Stoichiometry object to the pathway model
pathwayModel.add(stoichiometry);
found = true;
}
return found;
}
Element sequenceParticipantElement = childElement.getChild("sequenceParticipant", bp);
if (sequenceParticipantElement != null) {
boolean found = false;
PhysicalEntity thePhysicalEntity = null;
Element physicalEntityPropertyElement = sequenceParticipantElement.getChild("PHYSICAL-ENTITY", bp);
PhysicalEntityProxy physicalEntityProxy = null;
if (physicalEntityPropertyElement != null) {
found = true;
if (physicalEntityPropertyElement.getChildren().size() == 0) {
physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
if (childElement.getName().equals("LEFT")) {
conversion.addLeft(physicalEntityProxy);
} else {
conversion.addRight(physicalEntityProxy);
}
// return true;
} else {
thePhysicalEntity = addObjectPhysicalEntity(physicalEntityPropertyElement);
}
Element cellularLocationElement = sequenceParticipantElement.getChild("CELLULAR-LOCATION", bp);
if (cellularLocationElement != null && found == true) {
Element controlledVocabularyElement = cellularLocationElement.getChild("openControlledVocabulary", bp);
if (controlledVocabularyElement != null) {
CellularLocationVocabularyProxy cellularLocationVocabularyProxy = new CellularLocationVocabularyProxy();
addAttributes(cellularLocationVocabularyProxy, controlledVocabularyElement);
pathwayModel.add(cellularLocationVocabularyProxy);
if (controlledVocabularyElement.getChildren().size() == 0) {
physicalEntityProxy.setCellularLocation(cellularLocationVocabularyProxy);
} else {
physicalEntityProxy.setCellularLocation(addObjectCellularLocationVocabulary(controlledVocabularyElement));
}
// System.out.println(" - " + controlledVocabularyElement.getName());
// we'll use the extra info in this proxy during reconciliation phase to reconstruct a complete PhysicalEntity
}
}
}
return found;
}
if (childElement.getChildren().size() == 0) {
// PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
// addAttributes(physicalEntityProxy, childElement);
// pathwayModel.add(physicalEntityProxy);
// if (childElement.getName().equals("LEFT")){
// conversion.getLeftSide().add(physicalEntityProxy);
// }else{
// conversion.getRightSide().add(physicalEntityProxy);
// }
showIgnored(childElement, "conversion/LEFT or conversion/RIGHT assuming redundant sequenceParticipant or physicalEntityParticipant", conversion);
return true;
}
return false;
// }else if(childElement.getName().equals("participantStoichiometry")) {
// conversion.getParticipantStoichiometry().add(addObjectStoichiometry(childElement));
// return true;
} else {
return false;
}
}
use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.
the class PathwayProducerBiopax3 method addContentCatalysis.
// cofactor PhysicalEntity multiple
// catalysisDirection String single
private Element addContentCatalysis(BioPaxObject bpObject, Element element) {
element = addContentControl(bpObject, element);
Catalysis ob = (Catalysis) bpObject;
Element tmpElement = null;
if (ob.getCofactors() != null && ob.getCofactors().size() > 0) {
List<PhysicalEntity> list = ob.getCofactors();
for (PhysicalEntity item : list) {
tmpElement = new Element("cofactor", bp);
addIDToProperty(tmpElement, item);
mustPrintObject(item);
element.addContent(tmpElement);
}
}
if (ob.getCatalysisDirection() != null && ob.getCatalysisDirection().length() > 0) {
tmpElement = new Element("catalysisDirection", bp);
tmpElement.setAttribute("datatype", schemaString, rdf);
tmpElement.setText(ob.getCatalysisDirection());
element.addContent(tmpElement);
}
return element;
}
use of org.vcell.pathway.PhysicalEntity in project vcell by virtualcell.
the class PathwayMapping method createReactionStepFromPathway.
/*
* for reaction:
* 1. annotate the selected vcell object using linked pathway conversion
* 2. add non-existing speciesContexts from linked pathway conversion
* 3. add links between relative vcell objects and pathway objects
* Questions:
* - how to deal with the case that the reaction is existing in the model?
* + add it in no matter what?
* (this is the version we have now:
* add the duplicated reactions in without name changing,
* all duplicated reactions share the same participant objects)
* + just modify the existing one?
*/
private void createReactionStepFromPathway(BioModel bioModel, Process process, ReactionStep reactionStep, RelationshipObject relationshipObject, boolean addSubunits) throws Exception {
// annotate the selected vcell object using linked pathway object
// add non-existing speciesContexts from linked pathway conversion
ReactionParticipant[] rpArray = parseReaction(reactionStep, bioModel, relationshipObject);
// create a hashtable for interaction Participants
Hashtable<String, BioPaxObject> participantTable = new Hashtable<String, BioPaxObject>();
for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getLeft()) {
if (((PhysicalEntity) bpObject).getName().size() == 0) {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
} else {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
}
}
for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getRight()) {
if (((PhysicalEntity) bpObject).getName().size() == 0) {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
} else {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
}
}
for (ReactionParticipant rp : rpArray) {
SpeciesContext speciesContext = rp.getSpeciesContext();
if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
// if the speciesContext is not existed, then add it to the bioModel and link it to the corresponding pathway object
if (bioModel.getModel().getSpecies(speciesContext.getName()) == null) {
bioModel.getModel().addSpecies(speciesContext.getSpecies());
}
bioModel.getModel().addSpeciesContext(speciesContext);
RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
} else {
// if it is in the bioModel, then check whether it links to pathway object or not
HashSet<RelationshipObject> linkedReObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModel.getModel().getSpeciesContext(speciesContext.getName()));
if (linkedReObjects != null) {
boolean isLinked = false;
for (RelationshipObject reObject : linkedReObjects) {
if (reObject.getBioPaxObject() == participantTable.get(speciesContext.getName())) {
isLinked = true;
break;
}
}
if (!isLinked) {
RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
}
} else {
RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
}
}
}
(reactionStep).setReactionParticipants(rpArray);
// add Control to the reaction
if (process.getControl() != null) {
for (InteractionParticipant pe : process.getControl().getParticipants()) {
SpeciesContext newSpeciescontext = createSpeciesContextFromBioPaxObject(bioModel, pe.getPhysicalEntity(), addSubunits);
(reactionStep).addReactionParticipant(new Catalyst(null, reactionStep, newSpeciescontext));
}
}
addKinetics(reactionStep, process);
}
Aggregations