Search in sources :

Example 1 with EnzymeInfo

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

the class XmlReader method getFormalSpeciesInfo.

/**
 * This method creates a FormalSpeciesInfo from a XML representation.
 * Creation date: (6/3/2003 9:11:26 PM)
 * @return cbit.vcell.dictionary.FormalSpeciesInfo
 * @param speciesInfoElement org.jdom.Element
 */
private FormalSpeciesInfo getFormalSpeciesInfo(Element speciesInfoElement) throws XmlParseException {
    // get formalID
    String formalID = unMangle(speciesInfoElement.getAttributeValue(XMLTags.FormalIDTag));
    // get names
    List<Element> namesList = speciesInfoElement.getChildren(XMLTags.NameTag, vcNamespace);
    String[] namesArray = new String[namesList.size()];
    int nameCounter = 0;
    for (Element nameElement : namesList) {
        namesArray[nameCounter] = unMangle(nameElement.getText());
        nameCounter++;
    }
    String tempstring;
    // get type
    String type = speciesInfoElement.getAttributeValue(XMLTags.TypeAttrTag);
    FormalSpeciesInfo formalSpeciesInfo = null;
    if (type.equalsIgnoreCase(XMLTags.CompoundTypeTag)) {
        // get formula
        String formula = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.FormulaTag);
        if (tempstring != null) {
            formula = unMangle(tempstring);
        }
        // get CASID
        String casid = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.CasIDTag);
        if (tempstring != null) {
            casid = unMangle(tempstring);
        }
        // get Enzymes
        List<Element> enzymelist = speciesInfoElement.getChildren(XMLTags.EnzymeTag, vcNamespace);
        EnzymeRef[] enzymeArray = null;
        if (enzymelist != null && enzymelist.size() > 0) {
            enzymeArray = new EnzymeRef[enzymelist.size()];
            int enzymeCounter = 0;
            for (Element enzymeElement : enzymelist) {
                // get ECNumber
                String ecnumber = unMangle(enzymeElement.getAttributeValue(XMLTags.ECNumberTag));
                // get Enzymetype
                String enztypestr = enzymeElement.getAttributeValue(XMLTags.TypeAttrTag);
                char enzymetype = enztypestr.charAt(0);
                enzymeArray[enzymeCounter] = new EnzymeRef(ecnumber, enzymetype);
                enzymeCounter++;
            }
        }
        // create new CompoundInfo
        formalSpeciesInfo = new CompoundInfo(formalID, namesArray, formula, casid, enzymeArray);
    } else if (type.equalsIgnoreCase(XMLTags.EnzymeTypeTag)) {
        // get reaction
        String reaction = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.ExpressionAttrTag);
        if (tempstring != null) {
            reaction = unMangle(tempstring);
        }
        // get sysname
        String sysname = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.SysNameTag);
        if (tempstring != null) {
            sysname = unMangle(tempstring);
        }
        // get argcasID
        String casid = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.CasIDTag);
        if (tempstring != null) {
            casid = unMangle(tempstring);
        }
        // create new EnzymeInfo
        formalSpeciesInfo = new EnzymeInfo(formalID, namesArray, reaction, sysname, casid);
    } else if (type.equalsIgnoreCase(XMLTags.ProteinTypeTag)) {
        // get organism
        String organism = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.OrganismTag);
        if (tempstring != null) {
            organism = unMangle(tempstring);
        }
        // get accession
        String accession = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.AccessionTag);
        if (tempstring != null) {
            accession = unMangle(tempstring);
        }
        // get keywords
        String keywords = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.KeywordsTag);
        if (tempstring != null) {
            keywords = unMangle(tempstring);
        }
        // get description
        String description = null;
        tempstring = speciesInfoElement.getAttributeValue(XMLTags.DescriptionTag);
        if (tempstring != null) {
            description = unMangle(tempstring);
        }
        // create new ProteinInfo
        formalSpeciesInfo = new ProteinInfo(formalID, namesArray, organism, accession, keywords, description);
    } else {
        throw new XmlParseException("FormalSpeciesInfo type " + type + ", not supported yet!");
    }
    return formalSpeciesInfo;
}
Also used : ProteinInfo(cbit.vcell.dictionary.ProteinInfo) Element(org.jdom.Element) EnzymeRef(cbit.vcell.dictionary.EnzymeRef) EnzymeInfo(cbit.vcell.dictionary.EnzymeInfo) CompoundInfo(cbit.vcell.dictionary.CompoundInfo) FormalSpeciesInfo(cbit.vcell.model.FormalSpeciesInfo)

Example 2 with EnzymeInfo

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

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation for a FormalSpeciesInfo.
 * Creation date: (6/3/2003 5:14:09 PM)
 * @return Element
 * @param speciesInfo cbit.vcell.dictionary.FormalSpeciesInfo
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private Element getXML(FormalSpeciesInfo speciesInfo) throws XmlParseException {
    // Create XML object
    Element speciesInfoElement = new Element(XMLTags.FormalSpeciesInfoTag);
    // add formalID
    speciesInfoElement.setAttribute(XMLTags.FormalIDTag, mangle(speciesInfo.getFormalID()));
    // add names
    String[] namesArray = speciesInfo.getNames();
    for (int i = 0; i < namesArray.length; i++) {
        Element nameElement = new Element(XMLTags.NameTag);
        nameElement.addContent(mangle(namesArray[i]));
        speciesInfoElement.addContent(nameElement);
    }
    String temp;
    // add type plus extra parameters
    if (speciesInfo instanceof CompoundInfo) {
        CompoundInfo info = (CompoundInfo) speciesInfo;
        // add formula
        temp = info.getFormula();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.FormulaTag, mangle(temp));
        }
        // add casID
        temp = info.getCasID();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.CasIDTag, mangle(temp));
        }
        // add enzymes
        if (info.getEnzymes() != null) {
            for (int i = 0; i < info.getEnzymes().length; i++) {
                Element enzymeElement = new Element(XMLTags.EnzymeTag);
                EnzymeRef ref = info.getEnzymes()[i];
                // add ECNumber
                enzymeElement.setAttribute(XMLTags.ECNumberTag, mangle(ref.getEcNumber()));
                // add EnzymeType
                enzymeElement.setAttribute(XMLTags.TypeAttrTag, String.valueOf(ref.getEnzymeType()));
                // add the enzymeElement to the speciesInfoElement
                speciesInfoElement.addContent(enzymeElement);
            }
        }
        // add type
        speciesInfoElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.CompoundTypeTag);
    } else if (speciesInfo instanceof EnzymeInfo) {
        EnzymeInfo info = (EnzymeInfo) speciesInfo;
        // add reaction
        temp = info.getReaction();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.ExpressionAttrTag, mangle(temp));
        }
        // add sysname
        temp = info.getSysname();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.SysNameTag, mangle(temp));
        }
        // add argcasID
        temp = info.getCasID();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.CasIDTag, mangle(temp));
        }
        // addtype
        speciesInfoElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.EnzymeTypeTag);
    } else if (speciesInfo instanceof ProteinInfo) {
        ProteinInfo info = (ProteinInfo) speciesInfo;
        // add Organism
        temp = info.getOrganism();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.OrganismTag, mangle(temp));
        }
        // add accession
        temp = info.getAccession();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.AccessionTag, mangle(temp));
        }
        // add KeyWords
        temp = info.getKeyWords();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.KeywordsTag, mangle(temp));
        }
        // add description
        temp = info.getDescription();
        if (temp != null) {
            speciesInfoElement.setAttribute(XMLTags.DescriptionTag, mangle(temp));
        }
        // add type
        speciesInfoElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.ProteinTypeTag);
    } else {
        throw new XmlParseException("FormalSpeciesInfo type " + speciesInfo.getClass().getName() + ", not supported yet!");
    }
    return speciesInfoElement;
}
Also used : ProteinInfo(cbit.vcell.dictionary.ProteinInfo) Element(org.jdom.Element) EnzymeRef(cbit.vcell.dictionary.EnzymeRef) EnzymeInfo(cbit.vcell.dictionary.EnzymeInfo) CompoundInfo(cbit.vcell.dictionary.CompoundInfo)

Example 3 with EnzymeInfo

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

use of cbit.vcell.dictionary.EnzymeInfo 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;
}
Also used : FormalEnzyme(cbit.vcell.dictionary.FormalEnzyme) KeyValue(org.vcell.util.document.KeyValue) EnzymeInfo(cbit.vcell.dictionary.EnzymeInfo) DBFormalSpecies(cbit.vcell.model.DBFormalSpecies) KeyValue(org.vcell.util.document.KeyValue) BoundEnzyme(cbit.vcell.dictionary.BoundEnzyme) Vector(java.util.Vector)

Aggregations

EnzymeInfo (cbit.vcell.dictionary.EnzymeInfo)4 CompoundInfo (cbit.vcell.dictionary.CompoundInfo)3 EnzymeRef (cbit.vcell.dictionary.EnzymeRef)2 FormalEnzyme (cbit.vcell.dictionary.FormalEnzyme)2 ProteinInfo (cbit.vcell.dictionary.ProteinInfo)2 Vector (java.util.Vector)2 Element (org.jdom.Element)2 KeyValue (org.vcell.util.document.KeyValue)2 BoundEnzyme (cbit.vcell.dictionary.BoundEnzyme)1 DBNonFormalUnboundSpecies (cbit.vcell.dictionary.DBNonFormalUnboundSpecies)1 FormalCompound (cbit.vcell.dictionary.FormalCompound)1 DBFormalSpecies (cbit.vcell.model.DBFormalSpecies)1 FormalSpeciesInfo (cbit.vcell.model.FormalSpeciesInfo)1 ReactionDescription (cbit.vcell.model.ReactionDescription)1