Search in sources :

Example 6 with FormalCompound

use of cbit.vcell.dictionary.FormalCompound 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 7 with FormalCompound

use of cbit.vcell.dictionary.FormalCompound in project vcell by virtualcell.

the class DictionaryDBTopLevel method getCompoundFromKeggID.

/**
 * gets a Species from the DB based on the dbID given as a parameter
 * @return Species
 * @param dbID String
 * @param bVersion boolean
 * @exception java.sql.SQLException The exception description.
 */
FormalCompound getCompoundFromKeggID(String dbID, boolean bEnableRetry) throws java.sql.SQLException {
    Object lock = new Object();
    Connection con = conFactory.getConnection(lock);
    try {
        FormalCompound result = dictionaryDB.getCompoundFromKeggID(con, dbID);
        return result;
    } catch (Throwable e) {
        lg.error(e.getMessage(), e);
        if (bEnableRetry && isBadConnection(con)) {
            conFactory.failed(con, lock);
            return getCompoundFromKeggID(dbID, false);
        } else {
            handle_SQLException(e);
            // never gets here;
            return null;
        }
    } finally {
        conFactory.release(con, lock);
    }
}
Also used : Connection(java.sql.Connection) FormalCompound(cbit.vcell.dictionary.FormalCompound)

Example 8 with FormalCompound

use of cbit.vcell.dictionary.FormalCompound in project vcell by virtualcell.

the class DictionaryDbDriver method getCompoundFromCasID.

/**
 * Returns the compound referenced by the casID
 * @return Compound
 * @param con Connection
 * @param casID String
 */
public FormalCompound getCompoundFromCasID(Connection con, String casID) throws SQLException {
    FormalCompound result = null;
    DBFormalSpecies[] dbfsArr = getDatabaseSpecies(con, null, casID, false, FormalSpeciesType.compound, FormalSpeciesType.COMPOUND_CASID, -1, false);
    if (dbfsArr != null && dbfsArr.length == 1) {
        result = (FormalCompound) dbfsArr[0];
    } else {
        throw new RuntimeException("Expecting only 1 result");
    }
    return result;
}
Also used : DBFormalSpecies(cbit.vcell.model.DBFormalSpecies) FormalCompound(cbit.vcell.dictionary.FormalCompound)

Aggregations

FormalCompound (cbit.vcell.dictionary.FormalCompound)8 CompoundInfo (cbit.vcell.dictionary.CompoundInfo)4 DBFormalSpecies (cbit.vcell.model.DBFormalSpecies)4 KeyValue (org.vcell.util.document.KeyValue)4 BoundCompound (cbit.vcell.dictionary.BoundCompound)3 FormalProtein (cbit.vcell.dictionary.FormalProtein)3 BoundProtein (cbit.vcell.dictionary.BoundProtein)2 FormalEnzyme (cbit.vcell.dictionary.FormalEnzyme)2 ProteinInfo (cbit.vcell.dictionary.ProteinInfo)2 Vector (java.util.Vector)2 Element (org.jdom.Element)2 BoundEnzyme (cbit.vcell.dictionary.BoundEnzyme)1 DBNonFormalUnboundSpecies (cbit.vcell.dictionary.DBNonFormalUnboundSpecies)1 EnzymeInfo (cbit.vcell.dictionary.EnzymeInfo)1 DBSpecies (cbit.vcell.model.DBSpecies)1 ReactionDescription (cbit.vcell.model.ReactionDescription)1 Expression (cbit.vcell.parser.Expression)1 Connection (java.sql.Connection)1