use of cbit.vcell.dictionary.BoundEnzyme in project vcell by virtualcell.
the class XmlReader method getDBSpecies.
/**
* This method reads a DBSpecies from a XML representation.
* Creation date: (6/3/2003 8:20:54 PM)
* @return cbit.vcell.dictionary.DBSpecies
* @param dbSpeciesElement org.jdom.Element
*/
private DBSpecies getDBSpecies(Element dbSpeciesElement) throws XmlParseException {
// Read the key
String keystring = dbSpeciesElement.getAttributeValue(XMLTags.KeyValueAttrTag);
KeyValue key = new KeyValue(keystring);
DBSpecies dbSpecies = null;
// read the type
String type = dbSpeciesElement.getAttributeValue(XMLTags.TypeAttrTag);
// Read the DBFormalSpecies
org.jdom.Element formalSpeciesElement = dbSpeciesElement.getChild(XMLTags.DBFormalSpeciesTag, vcNamespace);
if (type.equalsIgnoreCase(XMLTags.CompoundTypeTag)) {
// Create a BoundCompound
dbSpecies = new BoundCompound(key, (FormalCompound) getDBFormalSpecies(formalSpeciesElement));
} else if (type.equalsIgnoreCase(XMLTags.EnzymeTypeTag)) {
// Create a BoundEnzyme
dbSpecies = new BoundEnzyme(key, (FormalEnzyme) getDBFormalSpecies(formalSpeciesElement));
} else if (type.equalsIgnoreCase(XMLTags.ProteinTypeTag)) {
// Create a BoundProtein
dbSpecies = new BoundProtein(key, (FormalProtein) getDBFormalSpecies(formalSpeciesElement));
} else {
throw new XmlParseException("DBSpecies type: " + type + ", not supported yet!");
}
return dbSpecies;
}
use of cbit.vcell.dictionary.BoundEnzyme in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns the XML representation of a DBSpecies.
* Creation date: (6/3/2003 4:36:40 PM)
* @return Element
* @param dbSpecies cbit.vcell.dictionary.DBSpecies
*/
private Element getXML(DBSpecies dbSpecies) throws XmlParseException {
// create xml node
Element dbSpeciesElement = new Element(XMLTags.DBSpeciesTag);
if (this.printKeysFlag) {
// add the DBSpecieKey (IT ALWAYS NEED THE KEY!)
dbSpeciesElement.setAttribute(XMLTags.KeyValueAttrTag, dbSpecies.getDBSpeciesKey().toString());
}
// detect the type of DBSpecie
if (dbSpecies instanceof BoundCompound) {
// add type
dbSpeciesElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.CompoundTypeTag);
// add FormalCompound
dbSpeciesElement.addContent(getXML(((BoundCompound) dbSpecies).getFormalCompound()));
} else if (dbSpecies instanceof BoundEnzyme) {
// add type
dbSpeciesElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.EnzymeTypeTag);
// add FormalEnzyme
dbSpeciesElement.addContent(getXML(((BoundEnzyme) dbSpecies).getFormalEnzyme()));
} else if (dbSpecies instanceof BoundProtein) {
// add type
dbSpeciesElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.ProteinTypeTag);
// add FormalProtein
dbSpeciesElement.addContent(getXML(((BoundProtein) dbSpecies).getProteinEnzyme()));
} else {
throw new XmlParseException("DBSpecies type " + dbSpecies.getClass().getName() + " not supported yet!");
}
return dbSpeciesElement;
}
use of cbit.vcell.dictionary.BoundEnzyme 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;
}
Aggregations