use of org.vcell.pathway.Conversion 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);
}
use of org.vcell.pathway.Conversion in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method importIntoModel.
public void importIntoModel() {
if (bioModel == null) {
return;
}
String warningMessage = "";
String warningMessage2 = "";
int warningCount = 0;
int warningCount2 = 0;
String infoMessage = "";
ArrayList<BioPaxObject> importedBPObjects = new ArrayList<BioPaxObject>();
warningMessage = "The following pathway object(s) have been associated with object(s) in the physiology model:\n";
warningMessage2 = "The following transport reaction(s) will NOT be converted to the physiology model:\n";
warningCount = 0;
warningCount2 = 0;
infoMessage = "The following pathway object(s) have been coverted in the physiology model:\n\n";
boolean hasMembrane = false;
if (bioModel.getModel().getMembranes().size() > 0)
hasMembrane = true;
HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
// convert group Object to regular biopaxObjects
for (BioPaxObject bpo : getSelectedBioPaxObjects()) {
if (bpo instanceof GroupObject) {
selected.addAll(((GroupObject) bpo).computeGroupedBioPaxObjects());
} else {
selected.add(bpo);
}
}
for (BioPaxObject bpo : selected) {
if (bpo instanceof Conversion) {
if (bpo instanceof Transport && !hasMembrane) {
warningCount2++;
if (((Conversion) bpo).getName().size() > 0)
warningMessage2 += "\nTransport: \'" + ((Conversion) bpo).getName().get(0) + "\'\n";
else
warningMessage2 += "\nTransport: \'" + ((Conversion) bpo).getIDShort() + "\'\n";
} else if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
importedBPObjects.add(bpo);
} else {
warningCount++;
if (((Conversion) bpo).getName().size() > 0)
warningMessage += "\nReaction: \'" + ((Conversion) bpo).getName().get(0) + "\' =>\n";
else
warningMessage += "\nReaction: \'" + ((Conversion) bpo).getIDShort() + "\' =>\n";
for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
warningMessage += "\t=> \'" + r.getBioModelEntityObject().getName() + "\'\n";
}
}
} else if (bpo instanceof PhysicalEntity) {
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
importedBPObjects.add(bpo);
} else {
warningCount++;
if (((PhysicalEntity) bpo).getName().size() > 0)
warningMessage += "\nSpecies: \'" + ((PhysicalEntity) bpo).getName().get(0) + "\' =>\n";
else
warningMessage += "\nSpecies: \'" + ((PhysicalEntity) bpo).getIDShort() + "\' =>\n";
for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
warningMessage += "\t=> \'" + r.getBioModelEntityObject().getName() + "\'\n";
}
}
}
}
// create import panel
conversionPanel = new ConversionPanel();
conversionPanel.setBioModel(bioModel);
conversionPanel.setSelectionManager(getSelectionManager());
// show warning message
warningMessage2 += "\nNO membrane structures available in the physiology model.\n";
if (warningCount2 > 0) {
DialogUtils.showWarningDialog(conversionPanel, warningMessage2);
}
warningMessage += "\nThey will NOT be converted to the physiology model.\n";
if (warningCount > 0) {
DialogUtils.showWarningDialog(conversionPanel, warningMessage);
}
if (importedBPObjects.size() == 0) {
return;
}
// set the selected objects to be the validly imported biopaxObject set
conversionPanel.setBioPaxObjects(importedBPObjects);
int returnCode = DialogUtils.showComponentOKCancelDialog(this, conversionPanel, "Import into Physiology");
if (returnCode == JOptionPane.OK_OPTION) {
PathwayMapping pathwayMapping = new PathwayMapping();
try {
// function I:
// pass the table rows that contains user edited values to create Vcell object
pathwayMapping.createBioModelEntitiesFromBioPaxObjects(bioModel, conversionPanel.getTableRows(), conversionPanel.isAddSubunits());
for (BioPaxObject bpo : importedBPObjects) {
if (bpo instanceof Conversion) {
infoMessage += "Reaction: \t\'";
for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
infoMessage += r.getBioModelEntityObject().getName() + "\'\n";
}
infoMessage += "\n";
} else if (bpo instanceof PhysicalEntity) {
infoMessage += "Species: \t\'";
for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
infoMessage += r.getBioModelEntityObject().getName() + "\'\n";
}
infoMessage += "\n";
}
}
DialogUtils.showInfoDialog(this, infoMessage);
// jump the view to reaction diagram panel
if (selectionManager != null) {
selectionManager.setActiveView(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram));
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(this, "Errors occur when converting pathway objects to VCell bioModel objects.\n" + e.getMessage());
}
}
}
use of org.vcell.pathway.Conversion in project vcell by virtualcell.
the class BioPaxRelationshipTableModel method refreshData.
private void refreshData() {
ArrayList<BioPaxRelationshipTableRow> entityRows = new ArrayList<BioPaxRelationshipTableRow>();
if (bioModel != null) {
HashSet<RelationshipObject> relationshipObjects = null;
if (bioPaxObject != null) {
relationshipObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioPaxObject);
}
List<BioPaxRelationshipTableRow> allEntityRows = new ArrayList<BioPaxRelationshipTableRow>();
if (bioPaxObject instanceof Conversion) {
for (ReactionStep rs : bioModel.getModel().getReactionSteps()) {
BioPaxRelationshipTableRow entityRow = new BioPaxRelationshipTableRow(rs);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioModelEntityObject() == rs) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allEntityRows.add(entityRow);
}
}
for (ReactionRule rr : bioModel.getModel().getRbmModelContainer().getReactionRuleList()) {
BioPaxRelationshipTableRow entityRow = new BioPaxRelationshipTableRow(rr);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioModelEntityObject() == rr) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allEntityRows.add(entityRow);
}
}
} else if (bioPaxObject instanceof PhysicalEntity) {
for (SpeciesContext rs : bioModel.getModel().getSpeciesContexts()) {
BioPaxRelationshipTableRow entityRow = new BioPaxRelationshipTableRow(rs);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioModelEntityObject() == rs) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allEntityRows.add(entityRow);
}
}
}
if (searchText == null || searchText.length() == 0) {
entityRows.addAll(allEntityRows);
} else {
for (BioPaxRelationshipTableRow rs : allEntityRows) {
BioModelEntityObject object = rs.getBioModelEntityObject();
String lowerCaseSearchText = searchText.toLowerCase();
if (object.getName().toLowerCase().contains(lowerCaseSearchText) || object.getTypeLabel().toLowerCase().contains(lowerCaseSearchText)) {
entityRows.add(rs);
}
}
}
}
setData(entityRows);
GuiUtils.flexResizeTableColumns(ownerTable);
}
use of org.vcell.pathway.Conversion in project vcell by virtualcell.
the class PathwayGraphModel method refreshControl.
private void refreshControl(Control control) {
Interaction controlledInteraction = control.getControlledInteraction();
if (controlledInteraction instanceof Conversion) {
List<InteractionParticipant> physicalControllers = control.getParticipants();
if (physicalControllers != null) {
Conversion conversion = (Conversion) controlledInteraction;
BioPaxObject ancestorObject = pathwayModel.findTopLevelGroupAncestor(conversion);
if (ancestorObject == conversion) {
// conversion was not grouped
BioPaxConversionShape conversionShape = (BioPaxConversionShape) getShapeFromModelObject(conversion);
if (conversionShape != null) {
for (InteractionParticipant participant : physicalControllers) {
refreshParticipant(conversionShape, participant);
}
}
} else {
if (ancestorObject instanceof GroupObject) {
// conversion has been grouped
GroupObject groupObject = (GroupObject) ancestorObject;
for (InteractionParticipant participant : physicalControllers) {
refreshGroupInteraction(groupObject, participant);
}
}
}
}
}
}
use of org.vcell.pathway.Conversion 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();
}
Aggregations