use of org.vcell.pathway.persistence.BiopaxProxy.PhysicalEntityProxy 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.persistence.BiopaxProxy.PhysicalEntityProxy in project vcell by virtualcell.
the class PathwayReader method addContentInteraction.
private boolean addContentInteraction(Interaction interaction, Element element, Element childElement) {
if (addContentEntity(interaction, element, childElement)) {
return true;
}
if (childElement.getName().equals("PARTICIPANTS")) {
Element physicalEntityParticipantElement = childElement.getChild("physicalEntityParticipant", bp);
if (physicalEntityParticipantElement != null) {
Element physicalEntityPropertyElement = physicalEntityParticipantElement.getChild("PHYSICAL-ENTITY", bp);
if (physicalEntityPropertyElement != null) {
if (physicalEntityPropertyElement.getChildren().size() == 0) {
PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
interaction.addPhysicalEntityAsParticipant(physicalEntityProxy, InteractionParticipant.Type.PARTICIPANT);
return true;
}
}
}
Element sequenceParticipantElement = childElement.getChild("sequenceParticipant", bp);
if (sequenceParticipantElement != null) {
Element physicalEntityPropertyElement = sequenceParticipantElement.getChild("PHYSICAL-ENTITY", bp);
if (physicalEntityPropertyElement != null) {
if (physicalEntityPropertyElement.getChildren().size() == 0) {
PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
interaction.addPhysicalEntityAsParticipant(physicalEntityProxy, InteractionParticipant.Type.PARTICIPANT);
return true;
}
}
}
return false;
} else if (childElement.getName().equals("INTERACTION-TYPE")) {
interaction.getInteractionTypes().add(addObjectInteractionVocabulary(childElement));
return true;
// showIgnored(childElement, "Can't convert openControlledVocabulary (v2) to InteractionVocabulary (v3).", interaction);
// return false;
} else {
return false;
}
}
use of org.vcell.pathway.persistence.BiopaxProxy.PhysicalEntityProxy in project vcell by virtualcell.
the class PathwayReader method addContentComplex.
private boolean addContentComplex(Complex complex, Element element, Element childElement) {
if (addContentPhysicalEntity(complex, element, childElement)) {
return true;
}
/**
* ArrayList<PhysicalEntity> component
* ArrayList<Stoichiometry> componentStoichiometry
*/
if (childElement.getName().equals("COMPONENTS")) {
Element physicalEntityParticipantElement = childElement.getChild("physicalEntityParticipant", bp);
if (physicalEntityParticipantElement != null) {
Element physicalEntityPropertyElement = physicalEntityParticipantElement.getChild("PHYSICAL-ENTITY", bp);
if (physicalEntityPropertyElement != null) {
if (physicalEntityPropertyElement.getChildren().size() == 0) {
PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
complex.getComponents().add(physicalEntityProxy);
return true;
}
}
}
Element sequenceParticipantElement = childElement.getChild("sequenceParticipant", bp);
if (sequenceParticipantElement != null) {
Element physicalEntityPropertyElement = sequenceParticipantElement.getChild("PHYSICAL-ENTITY", bp);
if (physicalEntityPropertyElement != null) {
if (physicalEntityPropertyElement.getChildren().size() == 0) {
PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
complex.getComponents().add(physicalEntityProxy);
return true;
}
}
}
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, "complex/COMPONENTS assuming redundant sequenceParticipant or physicalEntityParticipant", complex);
return true;
}
return false;
} else {
// no match
return false;
}
}
use of org.vcell.pathway.persistence.BiopaxProxy.PhysicalEntityProxy 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.persistence.BiopaxProxy.PhysicalEntityProxy in project vcell by virtualcell.
the class PathwayReaderBiopax3 method addContentControl.
private boolean addContentControl(Control control, Element element, Element childElement) {
if (addContentInteraction(control, element, childElement)) {
return true;
}
/**
* InteractionImpl controlledInteraction
* Pathway controlledPathway
* String controlType
* ArrayList<Pathway> pathwayControllers
* ArrayList<PhysicalEntity> physicalControllers
*/
if (childElement.getName().equals("controller")) {
// if (resourceAttribute != null){
if (childElement.getChildren().size() == 0) {
// if there are no children it must be a resource inside another object
// we don't know yet whether it's Interaction or Pathway, we make a proxy for each
// at the time when we solve the references we'll find out which is fake
PhysicalEntityProxy proxyE = new PhysicalEntityProxy();
addAttributes(proxyE, childElement);
pathwayModel.add(proxyE);
control.addPhysicalController(proxyE);
PathwayProxy proxyP = new PathwayProxy();
addAttributes(proxyP, childElement);
pathwayModel.add(proxyP);
control.getPathwayControllers().add(proxyP);
return true;
} else {
for (Object child : element.getChildren()) {
if (child instanceof Element) {
if (((Element) child).getName().equals("Pathway")) {
Pathway thingie = addObjectPathway((Element) child);
control.getPathwayControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("Complex")) {
Complex thingie = addObjectComplex((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("Dna")) {
Dna thingie = addObjectDna((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("DnaRegion")) {
DnaRegion thingie = addObjectDnaRegion((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("Rna")) {
Rna thingie = addObjectRna((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("RnaRegion")) {
RnaRegion thingie = addObjectRnaRegion((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("Protein")) {
Protein thingie = addObjectProtein((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else if (((Element) child).getName().equals("SmallMolecule")) {
SmallMolecule thingie = addObjectSmallMolecule((Element) child);
control.getPhysicalControllers().add(thingie);
return true;
} else {
return false;
}
}
}
}
return false;
} else if (childElement.getName().equals("controlled")) {
if (childElement.getChildren().size() == 0) {
InteractionProxy proxyI = new InteractionProxy();
addAttributes(proxyI, childElement);
pathwayModel.add(proxyI);
control.setControlledInteraction(proxyI);
PathwayProxy proxyP = new PathwayProxy();
addAttributes(proxyP, childElement);
pathwayModel.add(proxyP);
control.setControlledPathway(proxyP);
return true;
} else {
for (Object child : childElement.getChildren()) {
if (child instanceof Element) {
if (((Element) child).getName().equals("Pathway")) {
Pathway thingie = addObjectPathway((Element) child);
control.setControlledPathway(thingie);
return true;
} else {
Interaction thingie = (Interaction) addObjectBioPaxObjectSubclass((Element) child);
if (thingie == null) {
return false;
} else {
control.setControlledInteraction(thingie);
return true;
}
}
// if(((Element)child).getName().equals("Pathway")) {
// Pathway thingie = addObjectPathway((Element)child);
// control.setControlledPathway(thingie);
// return true;
// } else if(((Element)child).getName().equals("Interaction")) {
// Interaction thingie = addObjectInteraction((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("Control")) {
// Control thingie = addObjectControl((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("Modulation")) {
// Modulation thingie = addObjectModulation((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("Catalysis")) {
// Catalysis thingie = addObjectCatalysis((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("TemplateReactionRegulation")) {
// TemplateReactionRegulation thingie = addObjectTemplateReactionRegulation((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("Conversion")) {
// Conversion thingie = addObjectConversion((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("BiochemicalReaction")) {
// BiochemicalReaction thingie = addObjectBiochemicalReaction((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("TransportWithBiochemicalReaction")) {
// TransportWithBiochemicalReaction thingie = addObjectTransportWithBiochemicalReaction((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("ComplexAssembly")) {
// ComplexAssembly thingie = addObjectComplexAssembly((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("Degradation")) {
// Degradation thingie = addObjectDegradation((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("Transport")) {
// Transport thingie = addObjectTransport((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("GeneticInteraction")) {
// GeneticInteraction thingie = addObjectGeneticInteraction((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("MolecularInteraction")) {
// MolecularInteraction thingie = addObjectMolecularInteraction((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else if(((Element)child).getName().equals("TemplateReaction")) {
// TemplateReaction thingie = addObjectTemplateReaction((Element)child);
// control.setControlledInteraction(thingie);
// return true;
// } else {
// return false;
// }
}
}
}
return false;
} else if (childElement.getName().equals("controlType")) {
control.setControlType(childElement.getTextTrim());
return true;
} else {
return false;
}
}
Aggregations