use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class PathwayMapping method createReactionStepsFromTableRow.
private void createReactionStepsFromTableRow(BioModel bioModel, Conversion bioPaxObject, double stoich, String id, String location, ArrayList<ConversionTableRow> conversionTableRows, boolean addSubunits) throws Exception {
// get participants of this reaction from table rows
if (bioModel == null) {
return;
}
for (Process process : BioPAXUtil.getAllProcesses(bioModel.getPathwayModel(), bioPaxObject)) {
ArrayList<ConversionTableRow> participants = new ArrayList<ConversionTableRow>();
for (ConversionTableRow ctr : conversionTableRows) {
if (ctr.interactionId() == null) {
continue;
}
if (ctr.interactionId().equals(bioPaxObject.getID())) {
participants.add(ctr);
}
}
// create reaction object
String name = getSafetyName(process.getName() + "_" + location);
ReactionStep reactionStep = bioModel.getModel().getReactionStep(name);
if (reactionStep == null) {
// create a new reactionStep object
ReactionStep simpleReactionStep = bioModel.getModel().createSimpleReaction(bioModel.getModel().getStructure(location));
simpleReactionStep.setName(name);
RelationshipObject newRelationship = new RelationshipObject(simpleReactionStep, bioPaxObject);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
createReactionStep(bioModel, process, simpleReactionStep, newRelationship, participants, addSubunits);
addKinetics(simpleReactionStep, process);
} else {
// bioModel.getModel().getReactionStep(safeId).setStructure(bioModel.getModel().getStructure(location));
// add missing parts for the existing reactionStep
RelationshipObject newRelationship = new RelationshipObject(reactionStep, bioPaxObject);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
createReactionStep(bioModel, process, reactionStep, newRelationship, participants, addSubunits);
addKinetics(reactionStep, process);
}
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class PathwayMapping method createReactionStepsFromBioPaxObject.
private void createReactionStepsFromBioPaxObject(BioModel bioModel, Conversion conversion, boolean addSubunits) throws Exception {
if (bioModel == null) {
return;
}
for (Process process : BioPAXUtil.getAllProcesses(bioModel.getPathwayModel(), conversion)) {
String name = process.getName();
if (bioModel.getModel().getReactionStep(name) == null) {
// create a new reactionStep object
ReactionStep simpleReactionStep = bioModel.getModel().createSimpleReaction(bioModel.getModel().getStructures()[0]);
simpleReactionStep.setName(name);
RelationshipObject newRelationship = new RelationshipObject(simpleReactionStep, conversion);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
createReactionStepFromPathway(bioModel, process, simpleReactionStep, newRelationship, addSubunits);
} else {
// add missing parts for the existing reactionStep
RelationshipObject newRelationship = new RelationshipObject(bioModel.getModel().getReactionStep(name), conversion);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
createReactionStepFromPathway(bioModel, process, bioModel.getModel().getReactionStep(name), newRelationship, addSubunits);
}
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class PathwayMapping method createReactionStepsFromTableRow.
private void createReactionStepsFromTableRow(BioModel bioModel, Conversion conversion, double stoich, String id, String location, boolean addSubunits) throws Exception {
// use user defined id as the name of the reaction name
if (bioModel == null) {
return;
}
Set<Process> processes = BioPAXUtil.getAllProcesses(bioModel.getPathwayModel(), conversion);
for (Process process : processes) {
String name = getSafetyName(process.getName() + "_" + location);
if (bioModel.getModel().getReactionStep(name) == null) {
// create a new reactionStep object
ReactionStep simpleReactionStep = bioModel.getModel().createSimpleReaction(bioModel.getModel().getStructure(location));
simpleReactionStep.setName(name);
RelationshipObject newRelationship = new RelationshipObject(simpleReactionStep, conversion);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
createReactionStepFromPathway(bioModel, process, simpleReactionStep, newRelationship, addSubunits);
} else {
bioModel.getModel().getReactionStep(name).setStructure(bioModel.getModel().getStructure(location));
// add missing parts for the existing reactionStep
RelationshipObject newRelationship = new RelationshipObject(bioModel.getModel().getReactionStep(name), conversion);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
createReactionStepFromPathway(bioModel, process, bioModel.getModel().getReactionStep(name), newRelationship, addSubunits);
}
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class ReactionCartoonTool method mouseClicked.
@Override
public void mouseClicked(MouseEvent event) {
Point screenPoint = new Point(event.getX(), event.getY());
Point worldPoint = screenToWorld(screenPoint);
try {
if (event.getButton() != MouseEvent.BUTTON1) {
return;
}
switch(mode) {
case SELECT:
{
if (event.getClickCount() == 2) {
final Shape selectedShape = getReactionCartoon().getSelectedShape();
if (selectedShape instanceof ReactionContainerShape || selectedShape instanceof SpeciesContextShape || selectedShape instanceof SimpleReactionShape || selectedShape instanceof FluxReactionShape || selectedShape instanceof ReactionRuleDiagramShape || selectedShape instanceof RuleParticipantSignatureDiagramShape) {
editInPlace(selectedShape, worldPoint);
}
if (selectedShape != null) {
menuAction(selectedShape, CartoonToolMiscActions.Properties.MENU_ACTION);
}
}
break;
}
case STEP:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
if (getReactionCartoon().getStructureSuite().areReactionsShownFor(structure)) {
ReactionStep reactionStep = getReactionCartoon().getModel().createSimpleReaction(structure);
positionShapeForObject(structure, reactionStep, worldPoint);
saveDiagram();
}
}
break;
}
case FLUX:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
FluxReaction fluxReaction = getReactionCartoon().getModel().createFluxReaction(membrane);
ReactionStepShape frShape = (ReactionStepShape) getReactionCartoon().getShapeFromModelObject(fluxReaction);
Point parentLocation = frShape.getParent().getSpaceManager().getAbsLoc();
frShape.getSpaceManager().setRelPos(worldPoint.x - parentLocation.x, worldPoint.y - parentLocation.y);
saveDiagram();
// setMode(SELECT_MODE);
} else {
// setMode(SELECT_MODE);
// throw new Exception("fluxes only applicable to membranes");
}
}
break;
}
case SPECIES:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(((ReactionContainerShape) pickedShape).getStructure());
reactionCartoon.clearSelection();
getGraphModel().select(speciesContext);
positionShapeForObject(speciesContext.getStructure(), speciesContext, worldPoint);
// showCreateSpeciesContextDialog(getGraphPane(), getReactionCartoon().getModel(), ((ReactionContainerShape) pickedShape).getStructure(), scShapeLocation);
saveDiagram();
}
}
default:
break;
}
} catch (Exception e) {
System.out.println("CartoonTool.mouseClicked: uncaught exception");
e.printStackTrace(System.out);
Point canvasLoc = getGraphPane().getLocationOnScreen();
canvasLoc.x += screenPoint.x;
canvasLoc.y += screenPoint.y;
DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class ReactionCartoonTool method showDeleteDetails.
private static TableListResult showDeleteDetails(Component requester, DeleteSpeciesInfo deleteSpeciesInfo, ReactionStep[] reactionStepArr, boolean bShowErrorsOnly) {
if (reactionStepArr != null && reactionStepArr.length == 0) {
reactionStepArr = null;
}
String[][] rowData = null;
String[] columnNames = null;
String title = null;
if (reactionStepArr != null) {
Arrays.sort(reactionStepArr, new Comparator<ReactionStep>() {
@Override
public int compare(ReactionStep o1, ReactionStep o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
}
final String OK_TO_DELETE = "ok to delete";
final String ERROR_IF_DELETE = "ERROR if deleted";
ArrayList<String[]> errorRows = new ArrayList<String[]>();
if (deleteSpeciesInfo != null && reactionStepArr != null) {
title = RXSPECIES_DELETE + " Reactions/Species." + (deleteSpeciesInfo.bAnyUnresolvable() ? " User must resolve 'error' Flags to " + RXSPECIES_DELETE + "." : "");
columnNames = new String[] { "Type", "Name", "Flag", "Reference" };
rowData = new String[deleteSpeciesInfo.getRowData().length + reactionStepArr.length][4];
final int STATUS_ROW = 2;
for (int i = 0; i < rowData.length; i++) {
if (i < reactionStepArr.length) {
rowData[i][0] = "Reaction";
rowData[i][1] = reactionStepArr[i].getName();
rowData[i][STATUS_ROW] = OK_TO_DELETE;
rowData[i][3] = "";
} else {
int index = i - reactionStepArr.length;
rowData[i][0] = "Species";
rowData[i][1] = deleteSpeciesInfo.getRowData()[index][0];
rowData[i][STATUS_ROW] = (deleteSpeciesInfo.getRowData()[index][1].equals(RXSPECIES_ERROR) ? ERROR_IF_DELETE : OK_TO_DELETE);
rowData[i][3] = deleteSpeciesInfo.getRowData()[index][2] + " " + deleteSpeciesInfo.getRowData()[index][3];
}
if (rowData[i][STATUS_ROW].equals(ERROR_IF_DELETE)) {
errorRows.add(rowData[i]);
}
}
} else if (deleteSpeciesInfo != null && reactionStepArr == null) {
title = RXSPECIES_DELETE + " Species." + (deleteSpeciesInfo.bAnyUnresolvable() ? " User must resolve 'error' Flags to " + RXSPECIES_DELETE + "." : "");
columnNames = new String[] { "Species", "Flag", "Reference" };
rowData = new String[deleteSpeciesInfo.getRowData().length][3];
final int STATUS_ROW = 1;
for (int i = 0; i < deleteSpeciesInfo.getRowData().length; i++) {
rowData[i][0] = deleteSpeciesInfo.getRowData()[i][0];
rowData[i][STATUS_ROW] = (deleteSpeciesInfo.getRowData()[i][1].equals(RXSPECIES_ERROR) ? ERROR_IF_DELETE : OK_TO_DELETE);
rowData[i][2] = deleteSpeciesInfo.getRowData()[i][2] + " " + deleteSpeciesInfo.getRowData()[i][3];
if (rowData[i][STATUS_ROW].equals(ERROR_IF_DELETE)) {
errorRows.add(rowData[i]);
}
}
} else if (deleteSpeciesInfo == null && reactionStepArr != null) {
title = RXSPECIES_DELETE + " Reactions.";
columnNames = new String[] { "Reactions" };
rowData = new String[reactionStepArr.length][1];
for (int i = 0; i < reactionStepArr.length; i++) {
rowData[i][0] = reactionStepArr[i].getName();
}
} else {
throw new IllegalArgumentException("Unknown parameter combo 'showDeleteDetails'.");
}
if (bShowErrorsOnly && errorRows.size() > 0) {
rowData = errorRows.toArray(new String[0][]);
}
TableListResult tableListResult = DialogUtils.showComponentOptionsTableList(requester, title, columnNames, rowData, null, null, new String[] { RXSPECIES_BACK }, RXSPECIES_BACK, null);
return tableListResult;
}
Aggregations