use of org.sbml.jsbml.Annotation in project vcell by virtualcell.
the class SBMLAnnotationUtil method readVCellSpecificAnnotation.
/**
* readVCellSpecificAnnotation : separate method to handle only the VCellRelatedInfo annotation stored in VCellInfo element of
* SBML <annotation>. This is currently used only for species and reactions, since the information stored in these
* elements in the SBML annotation is required for building the corresponding VCell element.
* @param sBase - the corresponding SBML element
* @return - the <VcellRelatedInfo> element
* @throws XMLStreamException
*/
public Element readVCellSpecificAnnotation(SBase sBase) throws XMLStreamException {
Element vcellSpecificElement = null;
Annotation annotation = sBase.getAnnotation();
XMLNode annotationRoot = annotation.getXMLNode();
if (annotationRoot != null) {
long childCount = annotationRoot.getNumChildren();
for (int i = 0; i < childCount; ++i) {
XMLNode annotationBranch = annotationRoot.getChild(i);
String namespace = annotationBranch.getNamespaceURI(annotationBranch.getPrefix());
if ((namespace != null) && (namespace.equals(tripleVCellInfo.getURI()) || namespace.equals(XMLTags.VCML_NS_OLD) || namespace.equals(XMLTags.VCML_NS))) {
int numChildren = (int) annotationBranch.getNumChildren();
for (int j = 0; j < numChildren; j++) {
XMLNode child = annotationBranch.getChild(j);
if (!child.isElement()) {
continue;
}
// if this child has a prefix, but no explicit namespace (it is defined in its parent); try getting prefix from parent
String childPrefix = child.getPrefix();
if (childPrefix != null) {
String childNamespaceURI = child.getNamespaceURI(childPrefix);
if (childNamespaceURI == null || childNamespaceURI.length() == 0) {
childNamespaceURI = annotationBranch.getNamespaceURI(childPrefix);
child.addNamespace(childNamespaceURI, childPrefix);
}
}
if (child.getName().equals(XMLTags.VCellRelatedInfoTag)) {
// new style VCellInfo element (with <FreeText> and <SbmlImportRelated> subelements
vcellSpecificElement = xmlNodeToElement(child);
} else {
// check if 'child' is oldStyle VCellInfo element.
vcellSpecificElement = processOldStyleVCellInfo(child);
if (vcellSpecificElement == null) {
System.out.println("Unknown VCellInfo annotation type : '" + child.getName());
}
}
// if - else (child is VCellRelatedInfoTag)
}
// for - numChildren
}
// nameSpace != null & equals VCell_NS
}
// for - childCount
}
// annotationRoot != null
return vcellSpecificElement;
}
Aggregations