Search in sources :

Example 1 with FormalSpeciesInfo

use of cbit.vcell.model.FormalSpeciesInfo 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)

Aggregations

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