Search in sources :

Example 11 with ReactionDescription

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

the class EnzymeReactionTable method getReactions.

/**
 * returns a Compound object from the ResultSet
 * @return cbit.vcell.dictionary.Compound
 * @param rset java.sql.ResultSet
 */
public ReactionDescription[] getReactions(java.sql.ResultSet rset) throws java.sql.SQLException {
    Vector reactions = new Vector();
    String currentReactionID = null;
    String currentEnzymeFID = null;
    ReactionDescription current_dbfr = null;
    while (rset.next()) {
        String reactionID = null;
        String enzymeFID = null;
        if (!rset.isAfterLast()) {
            reactionID = rset.getString(EnzymeReactionTable.table.reactionId.toString());
            enzymeFID = rset.getString(RXQ_ENZYMEFID_ALIAS);
        }
        if (!reactionID.equals(currentReactionID) || !org.vcell.util.Compare.isEqualOrNull(enzymeFID, currentEnzymeFID)) {
            java.math.BigDecimal enzymeID = rset.getBigDecimal(RXQ_ENZYMEID_ALIAS);
            if (enzymeID != null) {
                String enzymeName = rset.getString(RXQ_ENZYMENAME_ALIAS);
                current_dbfr = new ReactionDescription(reactionID);
                current_dbfr.addReactionElement(new FormalEnzyme(new KeyValue(enzymeID), new EnzymeInfo(enzymeFID, new String[] { enzymeName }, null, null, null)), 0, ReactionDescription.RX_ELEMENT_CATALYST);
            } else if (enzymeFID != null) {
                current_dbfr = new ReactionDescription(reactionID);
                current_dbfr.addReactionElement(new DBNonFormalUnboundSpecies(enzymeFID), /*FormalUnknown(enzymeFID,null)*/
                0, ReactionDescription.RX_ELEMENT_CATALYST);
            } else {
                current_dbfr = new ReactionDescription(reactionID);
            }
            reactions.add(current_dbfr);
        }
        currentReactionID = reactionID;
        currentEnzymeFID = enzymeFID;
        // 
        FormalCompound formalCompound = new FormalCompound(new KeyValue(rset.getBigDecimal(RXQ_CMPNDID_ALIAS)), new CompoundInfo(rset.getString(CompoundTable.table.keggID.toString()), new String[] { rset.getString(RXQ_CMPDNDNAME_ALIAS) }, null, null, null));
        current_dbfr.addReactionElement(formalCompound, rset.getInt(EnzymeReactionTable.table.stoich.toString()), rset.getString(EnzymeReactionTable.table.type.toString()).charAt(0));
    }
    ReactionDescription[] reactionsArr = null;
    if (reactions.size() > 0) {
        reactionsArr = new ReactionDescription[reactions.size()];
        reactions.copyInto(reactionsArr);
    }
    return reactionsArr;
}
Also used : FormalEnzyme(cbit.vcell.dictionary.FormalEnzyme) KeyValue(org.vcell.util.document.KeyValue) EnzymeInfo(cbit.vcell.dictionary.EnzymeInfo) CompoundInfo(cbit.vcell.dictionary.CompoundInfo) ReactionDescription(cbit.vcell.model.ReactionDescription) DBNonFormalUnboundSpecies(cbit.vcell.dictionary.DBNonFormalUnboundSpecies) Vector(java.util.Vector) FormalCompound(cbit.vcell.dictionary.FormalCompound)

Example 12 with ReactionDescription

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

the class DictionaryDbDriver method getUserReactionDescriptions.

/**
 * Insert the method's description here.
 * Creation date: (4/18/2003 10:23:37 AM)
 */
public ReactionDescription[] getUserReactionDescriptions(Connection con, User user, ReactionQuerySpec reactionQuerySpec) throws SQLException {
    String sql = ReactStepTable.table.getSQLUserReactionListQuery(reactionQuerySpec, user, dbSyntax);
    ReactionDescription[] rxArr = null;
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        rxArr = ReactStepTable.table.getUserReactionList(rset);
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    // 
    return rxArr;
}
Also used : Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) ReactionDescription(cbit.vcell.model.ReactionDescription)

Example 13 with ReactionDescription

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

the class BiomodelVCMLModelInfoResource method createHtml.

public static StringBuffer createHtml(BioModel bm) {
    final SpeciesContext[] speciesContexts = bm.getModel().getSpeciesContexts();
    final ReactionStep[] reactionSteps = bm.getModel().getReactionSteps();
    // This contains a structure name mapped to Species and ReactionSteps
    TreeMap<String, ArrayList<Object>[]> structName_Species_Reactions_TS = new TreeMap<String, ArrayList<Object>[]>();
    // Store SpeciesContexts belonging to each Structure
    for (int i = 0; i < speciesContexts.length; i++) {
        final String name = speciesContexts[i].getStructure().getName();
        ArrayList<Object>[] items = structName_Species_Reactions_TS.get(name);
        if (items == null) {
            items = new ArrayList[] { new ArrayList<Structure>(), new ArrayList<SpeciesContext>(), new ArrayList<ReactionStep>() };
            items[ITEM_NAMES.structure.ordinal()].add(speciesContexts[i].getStructure());
            structName_Species_Reactions_TS.put(name, items);
        }
        items[ITEM_NAMES.species.ordinal()].add(speciesContexts[i]);
    }
    // Store ReactionStep belonging to each structure
    for (int i = 0; i < reactionSteps.length; i++) {
        final String name = reactionSteps[i].getStructure().getName();
        ArrayList<Object>[] items = structName_Species_Reactions_TS.get(name);
        if (items == null) {
            items = new ArrayList[] { new ArrayList<Structure>(), new ArrayList<SpeciesContext>(), new ArrayList<ReactionStep>() };
            items[ITEM_NAMES.structure.ordinal()].add(reactionSteps[i].getStructure());
            structName_Species_Reactions_TS.put(name, items);
        }
        items[ITEM_NAMES.reactions.ordinal()].add(reactionSteps[i]);
    }
    // Create html
    StringBuffer sb = new StringBuffer();
    sb.append("<strong>Compartments, Species, Reactions</strong><br/>");
    // iterate through all the structures and get the stored SpeciesContexts and ReactionSteps
    final Iterator<String> iterator = structName_Species_Reactions_TS.keySet().iterator();
    while (iterator.hasNext()) {
        // Get the structure name
        final String structName = iterator.next();
        // Get the stored items for the structure
        final ArrayList<Object>[] items = structName_Species_Reactions_TS.get(structName);
        sb.append("<ul><li> Compartment <strong>\"" + structName + "\"</strong>.  &nbsp; (type: " + ((Structure) items[ITEM_NAMES.structure.ordinal()].get(0)).getTypeName() + ")<ul>");
        // Add html for SpeciesContexts
        for (int i = 0; i < items[ITEM_NAMES.species.ordinal()].size(); i++) {
            sb.append("<li>Species <strong>\"" + StringEscapeUtils.escapeHtml(((SpeciesContext) items[ITEM_NAMES.species.ordinal()].get(i)).getName()) + "\"</strong></li>");
        }
        // Add html for ReactionSteps
        for (int i = 0; i < items[ITEM_NAMES.reactions.ordinal()].size(); i++) {
            final ReactionStep rxStep = (ReactionStep) items[ITEM_NAMES.reactions.ordinal()].get(i);
            ReactionDescription reactionDescription = createReactionDescription(rxStep, bm.getVersion().getVersionKey(), ((Structure) items[ITEM_NAMES.structure.ordinal()].get(0)).getKey());
            sb.append("<li>Reaction <strong>\"" + rxStep.getName() + "\"</strong> &nbsp; " + rxStep.getClass().getSimpleName() + " &nbsp; (" + StringEscapeUtils.escapeHtml(reactionDescription.toString()) + ")</li>");
        }
        sb.append("</ul></li></ul>");
    }
    return sb;
}
Also used : ArrayList(java.util.ArrayList) SpeciesContext(cbit.vcell.model.SpeciesContext) BigString(org.vcell.util.BigString) TreeMap(java.util.TreeMap) ReactionStep(cbit.vcell.model.ReactionStep) Structure(cbit.vcell.model.Structure) ReactionDescription(cbit.vcell.model.ReactionDescription)

Aggregations

ReactionDescription (cbit.vcell.model.ReactionDescription)13 DBNonFormalUnboundSpecies (cbit.vcell.dictionary.DBNonFormalUnboundSpecies)4 KeyValue (org.vcell.util.document.KeyValue)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 ReactionType (cbit.vcell.model.ReactionDescription.ReactionType)3 Structure (cbit.vcell.model.Structure)3 Hashtable (java.util.Hashtable)3 Vector (java.util.Vector)3 DefaultListModel (javax.swing.DefaultListModel)3 DataAccessException (org.vcell.util.DataAccessException)3 UserCancelException (org.vcell.util.UserCancelException)3 UtilCancelException (org.vcell.util.UtilCancelException)3 Catalyst (cbit.vcell.model.Catalyst)2 FluxReaction (cbit.vcell.model.FluxReaction)2 Product (cbit.vcell.model.Product)2 Reactant (cbit.vcell.model.Reactant)2 ReactionParticipant (cbit.vcell.model.ReactionParticipant)2 ReactionStep (cbit.vcell.model.ReactionStep)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2