use of cbit.vcell.dictionary.FormalEnzyme in project vcell by virtualcell.
the class DictionaryDBTopLevel method getEnzymeFromECNumber.
/**
* 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.
*/
FormalEnzyme getEnzymeFromECNumber(String dbID, boolean bEnableRetry) throws java.sql.SQLException {
Object lock = new Object();
Connection con = conFactory.getConnection(lock);
try {
FormalEnzyme result = dictionaryDB.getEnzymeFromECNumber(con, dbID);
return result;
} catch (Throwable e) {
lg.error(e.getMessage(), e);
if (bEnableRetry && isBadConnection(con)) {
conFactory.failed(con, lock);
return getEnzymeFromECNumber(dbID, false);
} else {
handle_SQLException(e);
// never gets here;
return null;
}
} finally {
conFactory.release(con, lock);
}
}
use of cbit.vcell.dictionary.FormalEnzyme in project vcell by virtualcell.
the class XmlReader method getDBFormalSpecies.
/**
* This method returns a DBFormalSpecies from a XML representation.
* Creation date: (6/3/2003 8:46:44 PM)
* @return cbit.vcell.dictionary.DBFormalSpecies
* @param formalSpeciesElement org.jdom.Element
*/
private DBFormalSpecies getDBFormalSpecies(Element formalSpeciesElement) throws XmlParseException {
// read key
String keystring = formalSpeciesElement.getAttributeValue(XMLTags.KeyValueAttrTag);
KeyValue key = new KeyValue(keystring);
// read type
String typestring = formalSpeciesElement.getAttributeValue(XMLTags.TypeAttrTag);
// read the FormalSpeciesInfo
Element speciesInfoElement = formalSpeciesElement.getChild(XMLTags.FormalSpeciesInfoTag, vcNamespace);
// create the DBFormalSpecies upon the type
DBFormalSpecies formalSpecies = null;
if (typestring.equalsIgnoreCase(XMLTags.CompoundTypeTag)) {
formalSpecies = new FormalCompound(key, (CompoundInfo) getFormalSpeciesInfo(speciesInfoElement));
} else if (typestring.equalsIgnoreCase(XMLTags.EnzymeTypeTag)) {
formalSpecies = new FormalEnzyme(key, (EnzymeInfo) getFormalSpeciesInfo(speciesInfoElement));
} else if (typestring.equalsIgnoreCase(XMLTags.ProteinTypeTag)) {
formalSpecies = new FormalProtein(key, (ProteinInfo) getFormalSpeciesInfo(speciesInfoElement));
} else {
throw new XmlParseException("DBFormalSpecies type:" + typestring + ", not supported yet!");
}
return formalSpecies;
}
use of cbit.vcell.dictionary.FormalEnzyme 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;
}
use of cbit.vcell.dictionary.FormalEnzyme in project vcell by virtualcell.
the class EnzymeTable method getEnzymes.
/**
* returns a enzyme object from the ResultSet
* @return cbit.vcell.dictionary.enzyme
* @param rset java.sql.ResultSet
*/
public DBFormalSpecies[] getEnzymes(java.sql.ResultSet rset, boolean createBound) throws java.sql.SQLException {
Vector enzymes = new Vector();
Vector aliasNames = new Vector();
String currentAliasName = null;
String currentECNumber = null;
String currentSysname = null;
String currentReaction = null;
String currentPreferred = null;
String currentCasID = null;
org.vcell.util.document.KeyValue currentEnzymeID = null;
org.vcell.util.document.KeyValue currentDBSpeciesID = null;
while (rset.next() || rset.isAfterLast()) {
KeyValue enzymeID = null;
if (!rset.isAfterLast()) {
enzymeID = new KeyValue(rset.getBigDecimal(EnzymeTable.table.id.toString()));
}
if (!rset.isFirst() && (!currentEnzymeID.equals(enzymeID))) {
if (currentEnzymeID != null) {
if (aliasNames.size() > 0) {
String[] aliasNamesArr = new String[aliasNames.size()];
aliasNames.copyInto(aliasNamesArr);
EnzymeInfo enzymeInfo = new EnzymeInfo(currentECNumber, aliasNamesArr, currentReaction, currentSysname, currentCasID);
FormalEnzyme formalEnzyme = new FormalEnzyme(currentEnzymeID, enzymeInfo);
Object enzyme = formalEnzyme;
if (createBound) {
BoundEnzyme boundEnzyme = new BoundEnzyme(currentDBSpeciesID, formalEnzyme);
enzyme = boundEnzyme;
}
enzymes.add(enzyme);
}
}
aliasNames.clear();
if (rset.isAfterLast()) {
break;
}
}
if (aliasNames.size() == 0) {
currentEnzymeID = enzymeID;
currentECNumber = rset.getString(EnzymeTable.table.ecNumber.toString());
currentSysname = rset.getString(EnzymeTable.table.sysname.toString());
currentSysname = (currentSysname != null ? org.vcell.util.TokenMangler.getSQLRestoredString(currentSysname) : null);
currentReaction = rset.getString(EnzymeTable.table.reaction.toString());
currentReaction = (currentReaction != null ? org.vcell.util.TokenMangler.getSQLRestoredString(currentReaction) : null);
currentCasID = rset.getString(EnzymeTable.table.casID.toString());
currentCasID = (currentCasID != null ? org.vcell.util.TokenMangler.getSQLRestoredString(currentCasID) : null);
if (createBound) {
currentDBSpeciesID = new KeyValue(rset.getBigDecimal("dbspecies_id"));
}
}
currentPreferred = rset.getString(EnzymeAliasTable.table.preferred.toString());
currentAliasName = org.vcell.util.TokenMangler.getSQLRestoredString(rset.getString(EnzymeAliasTable.table.name.toString()));
if (currentPreferred.compareToIgnoreCase("T") == 0) {
aliasNames.add(0, currentAliasName);
} else {
aliasNames.add(currentAliasName);
}
}
DBFormalSpecies[] enzymesArr = null;
if (enzymes.size() > 0) {
if (createBound) {
BoundEnzyme[] boundEnzymesArr = null;
boundEnzymesArr = new BoundEnzyme[enzymes.size()];
enzymes.copyInto(boundEnzymesArr);
enzymesArr = boundEnzymesArr;
} else {
FormalEnzyme[] formalEnzymesArr = null;
formalEnzymesArr = new FormalEnzyme[enzymes.size()];
enzymes.copyInto(formalEnzymesArr);
enzymesArr = formalEnzymesArr;
}
}
return enzymesArr;
}
use of cbit.vcell.dictionary.FormalEnzyme in project vcell by virtualcell.
the class DictionaryDbDriver method getEnzymeFromECNumber.
/**
* Returns the enzyme referenced by the given ECNumber
* @return Enzyme
* @param con Connection
* @param ecNumber String
*/
public FormalEnzyme getEnzymeFromECNumber(Connection con, String ecNumber) throws SQLException {
FormalEnzyme result = null;
DBFormalSpecies[] dbfsArr = getDatabaseSpecies(con, null, ecNumber, false, FormalSpeciesType.enzyme, FormalSpeciesType.ENZYME_ECNUMBER, -1, false);
if (dbfsArr != null && dbfsArr.length > 0) {
result = (FormalEnzyme) dbfsArr[0];
} else {
throw new RuntimeException("Expecting only 1 result");
}
return result;
}
Aggregations