use of cbit.vcell.model.ReactionDescription in project vcell by virtualcell.
the class ReactionCartoonTool method pasteReactionsAndSpecies.
private void pasteReactionsAndSpecies(Component requester, Structure pasteToStructure) {
final String RXSPECIES_PASTERX = "Reactions";
final String RXSPECIES_SPECIES = "Species";
ReactionSpeciesCopy reactionSpeciesCopy = (ReactionSpeciesCopy) SimpleTransferable.getFromClipboard(VCellTransferable.REACTION_SPECIES_ARRAY_FLAVOR);
if (reactionSpeciesCopy != null) {
// TODO: here we may want to warn the user about compartment number / type / name mismatch
// between the source and the destination
String response = null;
if ((reactionSpeciesCopy.getReactStepArr() != null || reactionSpeciesCopy.getReactionRuleArr() != null) && reactionSpeciesCopy.getSpeciesContextArr() != null) {
String msg = "There are ";
msg += reactionSpeciesCopy.getSpeciesContextArr().length + " Species and ";
int rlen = 0;
if (reactionSpeciesCopy.getReactStepArr() != null)
rlen += reactionSpeciesCopy.getReactStepArr().length;
if (reactionSpeciesCopy.getReactionRuleArr() != null)
rlen += reactionSpeciesCopy.getReactionRuleArr().length;
msg += rlen + " Reactions / Rules on the clipboard, choose which set to paste.";
response = DialogUtils.showWarningDialog(getGraphPane(), "Choose Species or Reactions to paste", msg, new String[] { RXSPECIES_SPECIES, RXSPECIES_PASTERX, RXSPECIES_CANCEL }, RXSPECIES_CANCEL);
if (response == null || response.equals(RXSPECIES_CANCEL)) {
return;
}
}
if (reactionSpeciesCopy.getSpeciesContextArr() != null && (response == null || response.equals(RXSPECIES_SPECIES))) {
IdentityHashMap<Species, Species> speciesHash = new IdentityHashMap<Species, Species>();
Vector<BioModelEntityObject> pastedSpeciesContextV = new Vector<BioModelEntityObject>();
for (int i = 0; i < reactionSpeciesCopy.getSpeciesContextArr().length; i++) {
String rootSC = speciesContextRootFinder(reactionSpeciesCopy.getSpeciesContextArr()[i]);
pastedSpeciesContextV.add(pasteSpecies(getGraphPane(), reactionSpeciesCopy.getSpeciesContextArr()[i].getSpecies(), rootSC, getModel(), pasteToStructure, true, speciesHash, null));
copyRelativePosition(getGraphModel(), reactionSpeciesCopy.getSpeciesContextArr()[i], pastedSpeciesContextV.lastElement());
}
ReactionCartoonTool.selectAndSaveDiagram(ReactionCartoonTool.this, pastedSpeciesContextV);
}
if (reactionSpeciesCopy.getReactStepArr() != null && reactionSpeciesCopy.getReactionRuleArr() == null && (response == null || response.equals(RXSPECIES_PASTERX))) {
BioModel bioModel = null;
try {
bioModel = findBioModel(requester);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
DialogUtils.showErrorDialog(requester, e.getMessage());
return;
}
ReactionDescription reactionDescription = DBReactionWizardPanel.createReactionDescription(reactionSpeciesCopy.getReactStepArr()[0], null, reactionSpeciesCopy.getFromStructure().getKey());
RXParticipantResolverPanel rxParticipantResolverPanel = new RXParticipantResolverPanel();
// rxParticipantResolverPanel.setPasteToModel(getModel());
rxParticipantResolverPanel.setupRX(reactionDescription, getModel(), pasteToStructure);
// JDialog j = new JDialog();
// j.setModal(true);
// j.setAlwaysOnTop(true);
// j.getContentPane().add(rxParticipantResolverPanel);
// j.pack();
// j.setVisible(true);
// int result = DialogUtils.showComponentOKCancelDialog(getGraphPane(), rxParticipantResolverPanel, "Assign Reaction elements");
// if(result != JOptionPane.OK_OPTION) {
// return;
// }
BioCartoonTool.AssignmentHelper assignmentHelper = new BioCartoonTool.AssignmentHelper() {
@Override
public JComboBox[] getStructureAssignmentJCB() {
return rxParticipantResolverPanel.getStructureAssignmentJCB();
}
@Override
public JComboBox[] getSpeciesAssignmentJCB() {
return rxParticipantResolverPanel.getSpeciesAssignmentJCB();
}
@Override
public ArrayList<JTextField> getFinalNames() {
// TODO Auto-generated method stub
return rxParticipantResolverPanel.getFinalNamesJTF();
}
@Override
public Component getParent() {
return getGraphPane();
}
@Override
public Component getAssignmentInterface() {
return rxParticipantResolverPanel;
}
@Override
public void close() {
// Do Nothing
}
};
BioCartoonTool.pasteReactionSteps(requester, ReactionCartoonTool.this, reactionDescription, reactionSpeciesCopy.getReactStepArr()[0].getModel(), reactionSpeciesCopy.getFromStructure(), reactionSpeciesCopy.getReactStepArr()[0], bioModel.getModel(), pasteToStructure, assignmentHelper);
// pasteReactionSteps(getGraphPane(),reactionSpeciesCopy.getReactStepArr(), getModel(),structure,true, null,ReactionCartoonTool.this);
} else if (reactionSpeciesCopy.getReactionRuleArr() != null && (response == null || response.equals(RXSPECIES_PASTERX))) {
pasteReactionsAndRules(getGraphPane(), reactionSpeciesCopy, getModel(), pasteToStructure, ReactionCartoonTool.this);
}
// try {
// for(MolecularType mtOurs : mtNewList) {
// rbmmcOurs.addMolecularType(mtOurs, false);
// }
// } catch (ModelException | PropertyVetoException e) {
// e.printStackTrace();
// }
//
// // ReactionRules
// if(reactionSpeciesCopy.getReactionRuleArr() != null) {
// for(ReactionRule rrTheirs : reactionSpeciesCopy.getReactionRuleArr()) {
//
// }
// }
}
}
use of cbit.vcell.model.ReactionDescription in project vcell by virtualcell.
the class BiomodelVCMLModelInfoResource method createReactionDescription.
// Copied from DBReactionWizrdPanel and altered to display speciescontext names in ReactionStep text representation
public static ReactionDescription createReactionDescription(ReactionStep rxStep, KeyValue bmid, KeyValue structRef) {
ReactionType rxType = null;
if (rxStep instanceof FluxReaction) {
if (rxStep.isReversible()) {
rxType = ReactionType.REACTTYPE_FLUX_REVERSIBLE;
} else {
rxType = ReactionType.REACTTYPE_FLUX_IRREVERSIBLE;
}
} else {
if (rxStep.isReversible()) {
rxType = ReactionType.REACTTYPE_SIMPLE_REVERSIBLE;
} else {
rxType = ReactionType.REACTTYPE_SIMPLE_IRREVERSIBLE;
}
}
ReactionDescription dbfr = new ReactionDescription(rxStep.getName(), rxType, rxStep.getKey(), bmid, structRef);
//
ReactionParticipant[] rpArr = rxStep.getReactionParticipants();
for (int i = 0; i < rpArr.length; i += 1) {
DBNonFormalUnboundSpecies dbnfu = new DBNonFormalUnboundSpecies(rpArr[i].getSpeciesContext().getName());
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].getSpeciesContext().getStructure().getName(), rpArr[i].getStoichiometry(), role);
}
if (dbfr.isFluxReaction()) {
// make sure flux is in right direction
Structure outsideStruct = rxStep.getModel().getStructureTopology().getOutsideFeature((Membrane) rxStep.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;
}
}
}
return dbfr;
}
use of cbit.vcell.model.ReactionDescription in project vcell by virtualcell.
the class DBReactionWizardPanel method searchUserReactions.
/**
* Insert the method's description here.
* Creation date: (7/12/2003 2:45:44 PM)
*/
private void searchUserReactions(final ReactionQuerySpec reactionQuerySpec) {
if (getDocumentManager() != null) {
final DocumentManager docManager = getDocumentManager();
final JList jlist = getReactionsJList();
//
final String RXSTRING_VALUE_KEY = "rxString";
//
AsynchClientTask searchReactions = new AsynchClientTask("searching reactions", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
try {
mapRXStringtoRXIDs.clear();
//
ReactionDescription[] dbrd = docManager.getUserReactionDescriptions(reactionQuerySpec);
//
if (dbrd != null && !(getStructure() instanceof Membrane)) {
Vector<ReactionDescription> noflux = new Vector<ReactionDescription>();
for (int i = 0; i < dbrd.length; i += 1) {
if (!dbrd[i].isFluxReaction()) {
noflux.add(dbrd[i]);
}
}
if (noflux.size() > 0) {
dbrd = new ReactionDescription[noflux.size()];
noflux.copyInto(dbrd);
}
}
//
String[] dbrdS = null;
if (dbrd != null) {
// if(mapRXStringtoRXIDs == null){mapRXStringtoRXIDs = new java.util.Hashtable();}
for (int i = 0; i < dbrd.length; i += 1) {
String rxString = dbrd[i].toString();
if (!mapRXStringtoRXIDs.containsKey(rxString)) {
mapRXStringtoRXIDs.put(rxString, new Vector<String>());
}
mapRXStringtoRXIDs.get(rxString).add(dbrd[i].getVCellRXID().toString());
mapRXIDtoBMIDs.put(dbrd[i].getVCellRXID(), dbrd[i].getVCellBioModelID());
mapRXIDtoStructRefIDs.put(dbrd[i].getVCellRXID(), dbrd[i].getVCellStructRef());
}
dbrdS = mapRXStringtoRXIDs.keySet().toArray(new String[0]);
}
//
if (dbrd != null && dbrd.length > 0) {
hash.put(RXSTRING_VALUE_KEY, dbrdS);
}
} catch (DataAccessException e) {
PopupGenerator.showErrorDialog(DBReactionWizardPanel.this, e.getMessage());
}
}
};
//
AsynchClientTask updateRXList = new AsynchClientTask("updateRXList", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
String[] dbrdS = (String[]) hash.get(RXSTRING_VALUE_KEY);
if (dbrdS != null) {
jlist.setListData(dbrdS);
} else {
jlist.setListData(new String[0]);
}
// afterSearchConfigure();
}
};
//
Hashtable<String, Object> hashTemp = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hashTemp, new AsynchClientTask[] { searchReactions, updateRXList }, false);
}
}
use of cbit.vcell.model.ReactionDescription in project vcell by virtualcell.
the class DBReactionWizardPanel method bfnActionPerformed.
/**
* Invoked when an action occurs.
*/
// public void actionPerformed(java.awt.event.ActionEvent e) {dbfr.get
//
// ReactionDescription resolvedReaction = getResolverJPanel().getREsolvedReaction();
// JComboBox[] speciesAssignmentJCB = getResolverJPanel().getSpeciesAssignmentJCB();
// if(resolvedReaction.isFluxReaction()){
// if(e.getSource() == speciesAssignmentJCB[0]){
// if(speciesAssignmentJCB[1].getSelectedIndex() != speciesAssignmentJCB[0].getSelectedIndex()){
// speciesAssignmentJCB[1].setSelectedIndex(speciesAssignmentJCB[0].getSelectedIndex());
// }
// }else if(e.getSource() == speciesAssignmentJCB[1]){
// if(speciesAssignmentJCB[0].getSelectedIndex() != speciesAssignmentJCB[1].getSelectedIndex()){
// speciesAssignmentJCB[0].setSelectedIndex(speciesAssignmentJCB[1].getSelectedIndex());
// }
// }
// }
// //for(int i=0;i<speciesAssignmentJCB.length;i+= 1){
// //Species species = speciesOrder[speciesAssignmentJCB[i].getSelectedIndex()];
// //Structure structure = null;
// //if(getStructure() instanceof Feature){
// //structure = getStructure();
// //}else if(resolvedReaction.isFluxReaction() && i == 0){
// //structure = ((Membrane)getStructure()).getOutsideFeature();
// //}else if(resolvedReaction.isFluxReaction() && i == 1){
// //structure = ((Membrane)getStructure()).getInsideFeature();
// //}else if(structureAssignmentJCB[i].getSelectedIndex() == 0){
// //structure = getStructure();
// //}else if(structureAssignmentJCB[i].getSelectedIndex() == 1){
// //structure = ((Membrane)getStructure()).getOutsideFeature();
// //}else if(structureAssignmentJCB[i].getSelectedIndex() == 2){
// //structure = ((Membrane)getStructure()).getInsideFeature();
// //}
// //System.out.println(
// //resolvedReaction.getReactionElement(i).getPreferredName()+
// //" assigned to "+(species != null?species.getCommonName():"New Species")+
// //" in structure "+ structure.getName());
// //}
//
// }
// /**
// * Insert the method's description here.
// * Creation date: (8/18/2003 2:38:49 PM)
// */
// private void afterSearchConfigure() {
//
// if(getReactionsJList().getModel().getSize() == 0){
// lastSearchChangeInfo = null;
// PopupGenerator.showInfoDialog(this, "No Reactions found matching search criteria");
// }else{
// lastSearchSaveInfo();
// ((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).next(getCardLayoutJPanel());
// }
// configureBFN();
// }
/**
* Comment
*/
private void bfnActionPerformed(java.awt.event.ActionEvent actionEvent) {
try {
//
DefaultListModel pndlm = (DefaultListModel) getParameterNamesJList().getModel();
//
if (actionEvent.getSource().equals(getBackJButton())) {
if (getRXParticipantResolverPanel().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())) {
// }else
if (getParameterJPanel().isVisible()) {
if (lastReactStepSelection == null || !lastReactStepSelection.equals(getReactionStep0())) {
lastReactStepSelection = getReactionStep0();
KeyValue bmid = mapRXIDtoBMIDs.get(lastReactStepSelection.getKey());
KeyValue structRef = mapRXIDtoStructRefIDs.get(lastReactStepSelection.getKey());
ReactionDescription dbfr = createReactionDescription(getReactionStep0(), bmid, structRef);
getRXParticipantResolverPanel().setupRX(dbfr, getModel(), getStructure());
}
}
//
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).next(getCardLayoutJPanel());
}
// else if(actionEvent.getSource().equals(getFinishJButton())){
// ReactionDescription myResolvedReaction = getRXParticipantResolverPanel().getResolvedReaction();
// Model fromModel = getDocumentManager().getBioModel(myResolvedReaction.getVCellBioModelID()).getModel();
// ReactionStep[] rxArr = fromModel.getReactionSteps();
// ReactionStep fromRXStep = null;
// for (int i = 0; i < rxArr.length; i++) {
// if(rxArr[i].getKey().equals(myResolvedReaction.getVCellRXID())){
// fromRXStep = rxArr[i];
// break;
// }
// }
// BioCartoonTool.AssignmentHelper assignmentHelper = new BioCartoonTool.AssignmentHelper() {
// @Override
// public JComboBox[] getStructureAssignmentJCB() {
// return getRXParticipantResolverPanel().getStructureAssignmentJCB();
// }
// @Override
// public JComboBox[] getSpeciesAssignmentJCB() {
// return getRXParticipantResolverPanel().getSpeciesAssignmentJCB();
// }
// @Override
// public ArrayList<JTextField> getFinalNames() {
// // TODO Auto-generated method stub
// return getRXParticipantResolverPanel().getFinalNamesJTF();
// }
// @Override
// public Component getParent() {
// return DBReactionWizardPanel.this;
// }
// @Override
// public Component getAssignmentInterface() {
// return null;
// }
// @Override
// public boolean shouldCloseParent() {
// return true;
// }
// };
// BioCartoonTool.pasteReactionSteps(DBReactionWizardPanel.this, rxPasteInterface, myResolvedReaction, fromModel,DBReactionWizardPanel.this.getStructure(),fromRXStep,
// DBReactionWizardPanel.this.getModel(), DBReactionWizardPanel.this.getStructure(),assignmentHelper);
// DBReactionWizardPanel.this.getChildWindow().close();
// }
//
configureBFN();
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "DBReactionWizard failed\n" + e.getMessage(), e);
}
}
use of cbit.vcell.model.ReactionDescription in project vcell by virtualcell.
the class DBReactionWizardPanel method setReactionDescription.
/**
* Sets the reactionDescription property (cbit.vcell.dictionary.ReactionDescription) value.
* @param reactionDescription The new value for the property.
* @see #getReactionDescription
*/
private void setReactionDescription(ReactionDescription reactionDescription) {
ReactionDescription oldValue = fieldReactionDescription;
fieldReactionDescription = reactionDescription;
firePropertyChange("reactionDescription", oldValue, reactionDescription);
}
Aggregations