use of org.vcell.pathway.Complex 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;
}
}
use of org.vcell.pathway.Complex 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.Complex in project vcell by virtualcell.
the class PathwayReader method addObjectComplex.
private Complex addObjectComplex(Element element) {
Complex complex = new Complex();
addAttributes(complex, element);
for (Object child : element.getChildren()) {
if (child instanceof Element) {
Element childElement = (Element) child;
if (!addContentComplex(complex, element, childElement)) {
showUnexpected(childElement, complex);
}
}
}
pathwayModel.add(complex);
return complex;
}
use of org.vcell.pathway.Complex in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method collapse2Complex.
private GroupObject collapse2Complex(BioPaxObject bpObject) {
PathwayGrouping pathwayGrouping = new PathwayGrouping();
GroupObject groupObject = null;
HashSet<BioPaxObject> hiddenobjects = new HashSet<BioPaxObject>();
if (bpObject instanceof Complex) {
// collapse components
Complex complex = (Complex) bpObject;
Set<BioPaxObject> bioPaxObjects = new HashSet<BioPaxObject>(bioModel.getPathwayModel().getBiopaxObjects());
for (PhysicalEntity pe : complex.getComponents()) {
if (bioPaxObjects.contains(pe)) {
hiddenobjects.add(pe);
}
}
if (hiddenobjects.size() > 0) {
hiddenobjects.add(bpObject);
String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), ((Entity) bpObject).getName(), id, hiddenobjects, GroupObject.Type.GROUPEDCOMPLEX);
} else {
// error message
DialogUtils.showErrorDialog(this, "No Collapse action happened because the components of the complex, " + getEntityName(complex) + ", haven't been imported to pathway model.");
}
} else if (bpObject instanceof Protein || bpObject instanceof SmallMolecule) {
Set<BioPaxObject> bioPaxObjects = new HashSet<BioPaxObject>(bioModel.getPathwayModel().getBiopaxObjects());
ArrayList<String> name = new ArrayList<String>();
List<BioPaxObject> parents = bioModel.getPathwayModel().getParents(bpObject);
if (parents.isEmpty()) {
DialogUtils.showErrorDialog(this, "No Collapse action happened because protein, " + getEntityName((Entity) bpObject) + ", doesn't involve in any complexes in the pathway data.");
return null;
}
for (BioPaxObject bpo : bioModel.getPathwayModel().getParents(bpObject)) {
if (bpo instanceof Complex && bioPaxObjects.contains(bpo)) {
hiddenobjects.add(bpo);
name.addAll(((Complex) bpo).getName());
for (PhysicalEntity pe : ((Complex) bpo).getComponents()) {
if (bioPaxObjects.contains(pe)) {
hiddenobjects.add(pe);
}
}
}
}
if (hiddenobjects.size() > 0) {
hiddenobjects.add(bpObject);
String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
if (name.size() == 0) {
name.add(id);
}
groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), name, id, hiddenobjects, GroupObject.Type.GROUPEDCOMPLEX);
} else {
// error message
DialogUtils.showErrorDialog(this, "No Collapse action happened because complexes that relate to protein, " + getEntityName((Entity) bpObject) + ", haven't been imported to pathway model.");
}
}
return groupObject;
}
use of org.vcell.pathway.Complex in project vcell by virtualcell.
the class BioModelEditorPathwayPanel method importPathway.
public void importPathway(boolean addComplexes, boolean addComponents, boolean addInteractions) {
ArrayList<BioPaxObject> selectedBioPaxObjects = new ArrayList<BioPaxObject>();
int[] rows = table.getSelectedRows();
if (rows == null || rows.length == 0) {
return;
}
for (int row : rows) {
BioPaxObject bioPaxObject = tableModel.getValueAt(row);
selectedBioPaxObjects.add(bioPaxObject);
}
PathwaySelectionExpander selectionExpander = new PathwaySelectionExpander();
PathwayModel rawPathwayModel = pathwayData.getPathwayModel();
if (addComplexes) {
selectionExpander.forPhysicalEntitiesAddComplexes(rawPathwayModel, selectedBioPaxObjects);
}
if (addComponents) {
selectionExpander.forComplexesAddComponents(rawPathwayModel, selectedBioPaxObjects);
}
if (addInteractions) {
selectionExpander.forPhysicalEntitiesAddInteractions(rawPathwayModel, selectedBioPaxObjects);
}
selectionExpander.forInteractionsAddControls(rawPathwayModel, selectedBioPaxObjects);
selectionExpander.forInteractionsAddParticipants(rawPathwayModel, selectedBioPaxObjects);
PathwayModel selectedPathwayModel = new PathwayModel();
HashSet<BioPaxObject> objectsToDelete = new HashSet<BioPaxObject>();
for (BioPaxObject candidateObject : selectedBioPaxObjects) {
// is the object in the current pathwayModel already?
BioPaxObject keeperObject = bioModel.getPathwayModel().find(candidateObject);
if (keeperObject == null) {
// not found in the current pathwayModel, add it
selectedPathwayModel.add(candidateObject);
} else {
// make a list with the objects we don't bring in because of duplication
objectsToDelete.add(candidateObject);
}
}
// we replace references to those objects within selectedPathwayModel with the real thing
for (BioPaxObject bpObject : selectedPathwayModel.getBiopaxObjects()) {
if (bpObject == null) {
System.out.println("PathwayModel: null BioPaxObject.");
continue;
}
for (BioPaxObject objectToDelete : objectsToDelete) {
BioPaxObject keeperObject = bioModel.getPathwayModel().find(objectToDelete);
// for now we only implemented this for InteractionParticipant entities of Conversions
bpObject.replace(keeperObject);
}
}
// we bring proteins, small molecules, etc that are components of a Complex
ArrayList<PhysicalEntity> addList = new ArrayList<>();
for (BioPaxObject bpo : selectedPathwayModel.getBiopaxObjects()) {
if (bpo instanceof Complex) {
Complex complex = (Complex) bpo;
addComplexComponents(complex, addList, 0);
}
}
for (PhysicalEntity pe : addList) {
if (selectedPathwayModel.find(pe) == null) {
selectedPathwayModel.add(pe);
}
}
bioModel.getPathwayModel().merge(selectedPathwayModel);
// jump the view to pathway diagram panel
if (selectionManager != null) {
selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), selectedPathwayModel.getBiopaxObjects().toArray());
}
}
Aggregations