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;
}
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;
}
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>. (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> " + rxStep.getClass().getSimpleName() + " (" + StringEscapeUtils.escapeHtml(reactionDescription.toString()) + ")</li>");
}
sb.append("</ul></li></ul>");
}
return sb;
}
Aggregations