Search in sources :

Example 1 with ReactionType

use of cbit.vcell.model.ReactionDescription.ReactionType 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);
    }
}
Also used : ReactionType(cbit.vcell.model.ReactionDescription.ReactionType) KeyValue(org.vcell.util.document.KeyValue) Product(cbit.vcell.model.Product) FluxReaction(cbit.vcell.model.FluxReaction) DBNonFormalUnboundSpecies(cbit.vcell.dictionary.DBNonFormalUnboundSpecies) Reactant(cbit.vcell.model.Reactant) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) ReactionDescription(cbit.vcell.model.ReactionDescription) Structure(cbit.vcell.model.Structure) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Example 2 with ReactionType

use of cbit.vcell.model.ReactionDescription.ReactionType in project vcell by virtualcell.

the class ReactStepTable method getUserReactionList.

/**
 * Insert the method's description here.
 * Creation date: (7/12/2003 2:59:27 PM)
 * @return java.lang.String
 * @param likeString java.lang.String
 */
public ReactionDescription[] getUserReactionList(java.sql.ResultSet rset) throws java.sql.SQLException {
    java.util.Vector resultV = new java.util.Vector();
    ReactionDescription[] result = null;
    java.util.Vector rxidV = null;
    // 
    java.math.BigDecimal rxid = null;
    ReactionDescription dbfr = null;
    // 
    while (rset.next()) {
        java.math.BigDecimal currRXID = rset.getBigDecimal(ReactStepTable.table.id.toString());
        if (rset.isFirst()) {
            rxid = currRXID;
        }
        if (rxid != null && !rxid.equals(currRXID)) {
            rxid = currRXID;
            dbfr = null;
        }
        // 
        if (dbfr == null) {
            ReactionType rxType = ReactionType.fromDatabaseName(rset.getString(ReactStepTable.table.reactType.toString()));
            String rxName = rset.getString(ReactStepTable.table.name.toString());
            java.math.BigDecimal currBioModelID = rset.getBigDecimal("bmid");
            java.math.BigDecimal currStructID = rset.getBigDecimal(ReactStepTable.table.structRef.toString());
            dbfr = new ReactionDescription(rxName, rxType, new KeyValue(rxid), new KeyValue(currBioModelID), new KeyValue(currStructID));
            resultV.add(dbfr);
        }
        String name = rset.getString(SpeciesTable.table.commonName.toString());
        DBNonFormalUnboundSpecies dbnfu = new DBNonFormalUnboundSpecies(name);
        // 
        String partRole = rset.getString(ReactPartTable.table.role.toString());
        char partRoleType;
        if (partRole.equals("reactant")) {
            partRoleType = ReactionDescription.RX_ELEMENT_REACTANT;
        } else if (partRole.equals("flux")) {
            partRoleType = ReactionDescription.RX_ELEMENT_FLUX;
        } else if (partRole.equals("catalyst")) {
            partRoleType = ReactionDescription.RX_ELEMENT_CATALYST;
        } else if (partRole.equals("product")) {
            partRoleType = ReactionDescription.RX_ELEMENT_PRODUCT;
        } else {
            throw new RuntimeException("Unknown role in UserList Query results");
        }
        // 
        int stoich = rset.getInt(ReactPartTable.table.stoich.toString());
        dbfr.addReactionElement(dbnfu, stoich, partRoleType);
        if (partRole.equals("flux")) {
            dbfr.addReactionElement(new DBNonFormalUnboundSpecies(name), stoich, partRoleType);
        }
    }
    // 
    if (resultV.size() > 0) {
        result = new ReactionDescription[resultV.size()];
        resultV.copyInto(result);
    }
    return result;
}
Also used : ReactionType(cbit.vcell.model.ReactionDescription.ReactionType) KeyValue(org.vcell.util.document.KeyValue) DBNonFormalUnboundSpecies(cbit.vcell.dictionary.DBNonFormalUnboundSpecies) ReactionDescription(cbit.vcell.model.ReactionDescription)

Aggregations

DBNonFormalUnboundSpecies (cbit.vcell.dictionary.DBNonFormalUnboundSpecies)2 ReactionDescription (cbit.vcell.model.ReactionDescription)2 ReactionType (cbit.vcell.model.ReactionDescription.ReactionType)2 KeyValue (org.vcell.util.document.KeyValue)2 Catalyst (cbit.vcell.model.Catalyst)1 FluxReaction (cbit.vcell.model.FluxReaction)1 Product (cbit.vcell.model.Product)1 Reactant (cbit.vcell.model.Reactant)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 Structure (cbit.vcell.model.Structure)1 DataAccessException (org.vcell.util.DataAccessException)1 UserCancelException (org.vcell.util.UserCancelException)1