public PmfCompartment ToPMFCompartment() { string id = element.Attributes[NuMLTags.ID_ATTR].Value; string name = element.Attributes[NuMLTags.NAME_ATTR].Value; XmlElement annotationElement = (XmlElement)element.SelectSingleNode(NuMLTags.ANNOTATION); if (annotationElement == null) { return(SBMLFactory.createPMFCompartment(id, name)); } XmlElement metadataNode = (XmlElement)annotationElement.SelectSingleNode(SbmlTags.PMF_NS + ":" + SbmlTags.METADATA); XmlElement pmfCodeNode = (XmlElement)metadataNode.SelectSingleNode(SbmlTags.PMF_NS + ":" + SbmlTags.SOURCE); string pmfCode = pmfCodeNode == null ? "" : pmfCodeNode.InnerText; XmlElement detailNode = (XmlElement)metadataNode.SelectSingleNode(SbmlTags.PMMLAB_NS + ":" + SbmlTags.DETAIL); string detail = detailNode == null ? "" : detailNode.InnerText; List <ModelVariable> modelVariables = null; XmlNodeList varNodes = metadataNode.SelectNodes(SbmlTags.ENVIRONMENT); if (varNodes.Count > 0) { modelVariables = new List <ModelVariable>(varNodes.Count); for (int i = 0; i < varNodes.Count; i++) { XmlElement varElement = (XmlElement)varNodes.Item(i); string varName = varElement.GetAttribute(SbmlTags.ENVIRONMENT_NAME); double varValue; if (varElement.HasAttribute(SbmlTags.ENVIRONMENT_VALUE)) { varValue = double.Parse(varElement.GetAttribute(SbmlTags.ENVIRONMENT_VALUE)); } else { varValue = double.NaN; } modelVariables.Add(new ModelVariable(varName, varValue)); } } return(SBMLFactory.createPMFCompartment(id, name, pmfCode, detail, modelVariables)); }
public PmfSpecies toPMFSpecies() { string id = element.GetAttribute(NuMLTags.ID_ATTR); string name = element.GetAttribute(NuMLTags.NAME_ATTR); string compartment = element.GetAttribute(NuMLTags.COMPARTMENT_ATTR); string substanceUnits = element.GetAttribute(NuMLTags.SUBSTANCE_UNITS_ATTR); PmfSpecies species = SBMLFactory.createPMFSpecies(compartment, id, name, substanceUnits); XmlElement annotationNode = (XmlElement)element.SelectSingleNode(NuMLTags.ANNOTATION); if (annotationNode != null) { // metadata XmlElement metadataNode = (XmlElement)annotationNode.SelectSingleNode(SbmlTags.PMF_NS + ":" + SbmlTags.METADATA); // combase code XmlElement combaseCodeNode = (XmlElement)metadataNode.SelectSingleNode(SbmlTags.PMF_NS + ":" + SbmlTags.SOURCE); if (combaseCodeNode != null) { species.combaseCode = combaseCodeNode.InnerText; } // detail XmlElement detailNode = (XmlElement)metadataNode.SelectSingleNode(SbmlTags.PMMLAB_NS + ":" + SbmlTags.DETAIL); if (detailNode != null) { species.detail = detailNode.InnerText; } // description XmlElement descriptionNode = (XmlElement)metadataNode.SelectSingleNode(SbmlTags.PMMLAB_NS + ":" + SbmlTags.DESCRIPTION); if (descriptionNode != null) { species.description = descriptionNode.InnerText; } } return(species); }