Search in sources :

Example 1 with EnzymeRef

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

use of cbit.vcell.dictionary.EnzymeRef 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)

Aggregations

CompoundInfo (cbit.vcell.dictionary.CompoundInfo)2 EnzymeInfo (cbit.vcell.dictionary.EnzymeInfo)2 EnzymeRef (cbit.vcell.dictionary.EnzymeRef)2 ProteinInfo (cbit.vcell.dictionary.ProteinInfo)2 Element (org.jdom.Element)2 FormalSpeciesInfo (cbit.vcell.model.FormalSpeciesInfo)1