use of cbit.vcell.model.FluxReaction in project vcell by virtualcell.
the class ReactionCartoonRule method setPositionsFromReactionCartoon.
public void setPositionsFromReactionCartoon(Diagram diagram) {
List<NodeReference> nodeList = new ArrayList<NodeReference>();
NodeReference.Mode mode = NodeReference.Mode.rule;
for (Shape shape : getShapes()) {
if (shape instanceof FluxReactionShape) {
nodeList.add(new NodeReference(mode, NodeReference.FLUX_REACTION_NODE, ((FluxReaction) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof SimpleReactionShape) {
nodeList.add(new NodeReference(mode, NodeReference.SIMPLE_REACTION_NODE, ((ReactionStep) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
// } else if (shape instanceof ReactionRuleDiagramShape) {
// nodeList.add(new NodeReference(mode,
// NodeReference.REACTION_RULE_NODE,
// ((ReactionRule) shape.getModelObject()).getName(),
// shape.getSpaceManager().getRelPos()));
} else if (shape instanceof ReactionRuleShortDiagramShape) {
// can only be short
ReactionRuleShortSignature signature = (ReactionRuleShortSignature) shape.getModelObject();
// the display name is the number of rules in the signature's list of rules
String name = signature.getDisplayName();
NodeReference nr = new NodeReference(mode, NodeReference.REACTION_RULE_NODE, name, shape.getSpaceManager().getRelPos());
nodeList.add(nr);
} else if (shape instanceof SpeciesContextShape) {
nodeList.add(new NodeReference(mode, NodeReference.SPECIES_CONTEXT_NODE, ((SpeciesContext) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof RuleParticipantSignatureFullDiagramShape) {
System.out.println("ReactionCartoonRule, Invalid shape type 'RuleParticipantSignatureFullDiagramShape'");
RuleParticipantSignature ruleParticipantSignature = (RuleParticipantSignature) shape.getModelObject();
if (ruleParticipantSignature.getStructure() == diagram.getStructure()) {
String spAsString = ruleParticipantSignature.getFirstSpeciesPatternAsString();
NodeReference nr = new NodeReference(mode, NodeReference.RULE_PARTICIPANT_SIGNATURE_FULL_NODE, spAsString, shape.getSpaceManager().getRelPos());
nr.speciesPattern = ruleParticipantSignature.getSpeciesPattern();
nodeList.add(nr);
}
} else if (shape instanceof RuleParticipantSignatureShortDiagramShape) {
RuleParticipantSignature ruleParticipantSignature = (RuleParticipantSignature) shape.getModelObject();
if (ruleParticipantSignature.getStructure() == diagram.getStructure()) {
String spAsString = ruleParticipantSignature.getFirstSpeciesPatternAsString();
NodeReference nr = new NodeReference(mode, NodeReference.RULE_PARTICIPANT_SIGNATURE_SHORT_NODE, spAsString, shape.getSpaceManager().getRelPos());
nr.speciesPattern = ruleParticipantSignature.getSpeciesPattern();
nodeList.add(nr);
}
}
}
// add all to nodeRuleList
diagram.setNodeReferences(mode, nodeList);
}
use of cbit.vcell.model.FluxReaction in project vcell by virtualcell.
the class DBReactionWizardPanel method bfnActionPerformed.
/**
* Comment
*/
private void bfnActionPerformed(java.awt.event.ActionEvent actionEvent) {
try {
//
javax.swing.DefaultListModel pndlm = (javax.swing.DefaultListModel) getParameterNamesJList().getModel();
//
if (actionEvent.getSource().equals(getBackJButton())) {
if (getResolverJPanel().isVisible() && pndlm.size() == 0 && getSearchDictionaryJRadioButton().isSelected() == false) {
// skip Parameters if there are none
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).previous(getCardLayoutJPanel());
}
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).previous(getCardLayoutJPanel());
} else if (actionEvent.getSource().equals(getNextJButton())) {
if (getSearchCriteriaJPanel().isVisible()) {
if (getSearchDictionaryJRadioButton().isSelected()) {
getParameterJPanel().setVisible(false);
} else {
getParameterJPanel().setVisible(true);
}
if (!lastSearchIsSameAsCurrent()) {
search();
lastReactionSelection = null;
return;
}
} else if (getParameterJPanel().isVisible()) {
if (lastReactStepSelection == null || !lastReactStepSelection.equals(getReactionStep0())) {
lastReactStepSelection = getReactionStep0();
ReactionType rxType = null;
if (getReactionStep0() instanceof FluxReaction) {
if (getReactionStep0().isReversible()) {
rxType = ReactionType.REACTTYPE_FLUX_REVERSIBLE;
} else {
rxType = ReactionType.REACTTYPE_FLUX_IRREVERSIBLE;
}
} else {
if (getReactionStep0().isReversible()) {
rxType = ReactionType.REACTTYPE_SIMPLE_REVERSIBLE;
} else {
rxType = ReactionType.REACTTYPE_SIMPLE_IRREVERSIBLE;
}
}
KeyValue bmid = mapRXIDtoBMIDs.get(lastReactStepSelection.getKey());
KeyValue structRef = mapRXIDtoStructRefIDs.get(lastReactStepSelection.getKey());
ReactionDescription dbfr = new ReactionDescription(getReactionStep0().getName(), rxType, getReactionStep0().getKey(), bmid, structRef);
//
ReactionParticipant[] rpArr = getReactionStep0().getReactionParticipants();
for (int i = 0; i < rpArr.length; i += 1) {
DBNonFormalUnboundSpecies dbnfu = new DBNonFormalUnboundSpecies(rpArr[i].getSpecies().getCommonName());
char role;
if (rpArr[i] instanceof Reactant) {
role = ReactionDescription.RX_ELEMENT_REACTANT;
} else if (rpArr[i] instanceof Product) {
role = ReactionDescription.RX_ELEMENT_PRODUCT;
} else if (rpArr[i] instanceof Catalyst) {
role = ReactionDescription.RX_ELEMENT_CATALYST;
} else {
throw new RuntimeException("Unsupported ReationParticiapnt=" + rpArr[i].getClass().getName());
}
dbfr.addReactionElement(dbnfu, rpArr[i].getSpeciesContext().getName(), rpArr[i].getStoichiometry(), role);
}
if (dbfr.isFluxReaction()) {
// make sure flux is in right direction
Structure outsideStruct = getModel().getStructureTopology().getOutsideFeature((Membrane) getReactionStep0().getStructure());
String defaultOutsideSCName = dbfr.getOrigSpeciesContextName(dbfr.getFluxIndexOutside());
for (int i = 0; i < rpArr.length; i += 1) {
if (rpArr[i].getSpeciesContext().getName().equals(defaultOutsideSCName)) {
if (!rpArr[i].getStructure().equals(outsideStruct)) {
dbfr.swapFluxSCNames();
}
break;
}
}
}
setupRX(dbfr);
}
}
//
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).next(getCardLayoutJPanel());
} else if (actionEvent.getSource().equals(getFinishJButton())) {
applySelectedReactionElements();
}
//
configureBFN();
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "DBReactionWizard failed\n" + e.getMessage(), e);
}
}
use of cbit.vcell.model.FluxReaction in project vcell by virtualcell.
the class ReactionCartoonFull method setPositionsFromReactionCartoon.
public void setPositionsFromReactionCartoon(Diagram diagram) {
List<NodeReference> nodeList = new ArrayList<NodeReference>();
NodeReference.Mode mode = NodeReference.Mode.full;
for (Shape shape : getShapes()) {
if (shape instanceof FluxReactionShape) {
nodeList.add(new NodeReference(mode, NodeReference.FLUX_REACTION_NODE, ((FluxReaction) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof SimpleReactionShape) {
nodeList.add(new NodeReference(mode, NodeReference.SIMPLE_REACTION_NODE, ((ReactionStep) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof ReactionRuleDiagramShape) {
nodeList.add(new NodeReference(mode, NodeReference.REACTION_RULE_NODE, ((ReactionRule) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof SpeciesContextShape) {
nodeList.add(new NodeReference(mode, NodeReference.SPECIES_CONTEXT_NODE, ((SpeciesContext) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof RuleParticipantSignatureFullDiagramShape) {
RuleParticipantSignature ruleParticipantSignature = (RuleParticipantSignature) shape.getModelObject();
if (ruleParticipantSignature.getStructure() == diagram.getStructure()) {
String spAsString = ruleParticipantSignature.getFirstSpeciesPatternAsString();
NodeReference nr = new NodeReference(mode, NodeReference.RULE_PARTICIPANT_SIGNATURE_FULL_NODE, spAsString, shape.getSpaceManager().getRelPos());
nr.speciesPattern = ruleParticipantSignature.getSpeciesPattern();
nodeList.add(nr);
}
} else if (shape instanceof RuleParticipantSignatureShortDiagramShape) {
System.out.println("ReactionCartoonFull, Invalid shape type 'RuleParticipantSignatureShortDiagramShape'");
RuleParticipantSignature ruleParticipantSignature = (RuleParticipantSignature) shape.getModelObject();
if (ruleParticipantSignature.getStructure() == diagram.getStructure()) {
String spAsString = ruleParticipantSignature.getFirstSpeciesPatternAsString();
NodeReference nr = new NodeReference(mode, NodeReference.RULE_PARTICIPANT_SIGNATURE_SHORT_NODE, spAsString, shape.getSpaceManager().getRelPos());
nr.speciesPattern = ruleParticipantSignature.getSpeciesPattern();
nodeList.add(nr);
}
}
}
diagram.setNodeReferences(mode, nodeList);
}
use of cbit.vcell.model.FluxReaction in project vcell by virtualcell.
the class ReactionCartoonFull method applyDefaults.
public void applyDefaults(Diagram diagram) {
List<NodeReference> nodeList = diagram.getNodeFullList();
List<NodeReference> orphansList = new ArrayList<NodeReference>();
for (int i = 0; i < nodeList.size(); i++) {
NodeReference node = nodeList.get(i);
Object obj = null;
Structure struct = diagram.getStructure();
boolean found = false;
switch(node.nodeType) {
case NodeReference.SIMPLE_REACTION_NODE:
obj = getModel().getReactionStep(node.name);
if (!(obj instanceof SimpleReaction)) {
System.out.println("ReactionCartoon.applyDefaults(), diagram reaction " + node.name + " type mismatch in model, using location anyway");
}
break;
case NodeReference.FLUX_REACTION_NODE:
obj = getModel().getReactionStep(node.name);
if (!(obj instanceof FluxReaction)) {
System.out.println("ReactionCartoon.applyDefaults(), diagram flux " + node.name + " type mismatch in model, using location anyway");
}
break;
case NodeReference.SPECIES_CONTEXT_NODE:
obj = getModel().getSpeciesContext(node.name);
break;
case NodeReference.REACTION_RULE_NODE:
obj = getModel().getRbmModelContainer().getReactionRule(node.name);
break;
case // obj is a RuleParticipantSignature
NodeReference.RULE_PARTICIPANT_SIGNATURE_FULL_NODE:
for (RuleParticipantSignature signature : ruleParticipantSignatures) {
if (signature instanceof RuleParticipantLongSignature && signature.getStructure() == struct && signature.compareByCriteria(node.getName(), GroupingCriteria.full)) {
obj = signature;
found = true;
break;
}
}
if (!found) {
orphansList.add(node);
}
break;
case NodeReference.RULE_PARTICIPANT_SIGNATURE_SHORT_NODE:
System.out.println("ReactionCartoonFull, RULE_PARTICIPANT_SIGNATURE_SHORT_NODE detected");
for (RuleParticipantSignature signature : ruleParticipantSignatures) {
if (signature instanceof RuleParticipantShortSignature && signature.getStructure() == struct && signature.compareByCriteria(node.getName(), GroupingCriteria.full)) {
obj = signature;
found = true;
break;
}
}
if (!found) {
orphansList.add(node);
}
break;
}
// -- switch
Shape shape = getShapeFromModelObject(obj);
if (shape != null) {
Point relPosOld = shape.getRelPos();
Point relPosNew = node.location;
// In old models, the same node can appear in multiple diagrams.
// Now, we have only one diagram, so if a node has multiple positions,
// some would overwrite others.
// This attempts to prevent overwriting a position with a worse one.
// if(relPosOld.x + relPosOld.y < relPosNew.x + relPosNew.y) {
shape.setRelPos(relPosNew);
// }
}
}
if (!orphansList.isEmpty()) {
diagram.removeNodeReferences(NodeReference.Mode.full, orphansList);
}
}
use of cbit.vcell.model.FluxReaction in project vcell by virtualcell.
the class ReactionCartoonMolecule method setPositionsFromReactionCartoon.
public void setPositionsFromReactionCartoon(Diagram diagram) {
List<NodeReference> nodeList = new ArrayList<NodeReference>();
NodeReference.Mode mode = NodeReference.Mode.molecule;
for (Shape shape : getShapes()) {
if (shape instanceof FluxReactionShape) {
nodeList.add(new NodeReference(mode, NodeReference.FLUX_REACTION_NODE, ((FluxReaction) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof SimpleReactionShape) {
nodeList.add(new NodeReference(mode, NodeReference.SIMPLE_REACTION_NODE, ((ReactionStep) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof ReactionRuleDiagramShape) {
nodeList.add(new NodeReference(mode, NodeReference.REACTION_RULE_NODE, ((ReactionRule) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof SpeciesContextShape) {
nodeList.add(new NodeReference(mode, NodeReference.SPECIES_CONTEXT_NODE, ((SpeciesContext) shape.getModelObject()).getName(), shape.getSpaceManager().getRelPos()));
} else if (shape instanceof RuleParticipantSignatureFullDiagramShape) {
System.out.println("ReactionCartoonMolecule, Invalid shape type 'RuleParticipantSignatureFullDiagramShape'");
RuleParticipantSignature ruleParticipantSignature = (RuleParticipantSignature) shape.getModelObject();
if (ruleParticipantSignature.getStructure() == diagram.getStructure()) {
String spAsString = ruleParticipantSignature.getFirstSpeciesPatternAsString();
NodeReference nr = new NodeReference(mode, NodeReference.RULE_PARTICIPANT_SIGNATURE_FULL_NODE, spAsString, shape.getSpaceManager().getRelPos());
nr.speciesPattern = ruleParticipantSignature.getSpeciesPattern();
nodeList.add(nr);
}
} else if (shape instanceof RuleParticipantSignatureShortDiagramShape) {
RuleParticipantSignature ruleParticipantSignature = (RuleParticipantSignature) shape.getModelObject();
if (ruleParticipantSignature.getStructure() == diagram.getStructure()) {
String spAsString = ruleParticipantSignature.getFirstSpeciesPatternAsString();
NodeReference nr = new NodeReference(mode, NodeReference.RULE_PARTICIPANT_SIGNATURE_SHORT_NODE, spAsString, shape.getSpaceManager().getRelPos());
nr.speciesPattern = ruleParticipantSignature.getSpeciesPattern();
nodeList.add(nr);
}
}
}
diagram.setNodeReferences(mode, nodeList);
}
Aggregations