Commit 706980fa authored by Piotr Gawron's avatar Piotr Gawron
Browse files

properly handle compartments defined by CellDesigner 2.5

parent 7f6269a5
......@@ -137,15 +137,17 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC
private void parseAnnotationNode(CellDesignerCompartment compartment, Node xmlNode) throws InvalidXmlSchemaException {
NodeList annotationNodes = xmlNode.getChildNodes();
for (int y = 0; y < annotationNodes.getLength(); y++) {
Node annotationNode = annotationNodes.item(y);
if (annotationNode.getNodeType() == Node.ELEMENT_NODE) {
if (annotationNode.getNodeName().equalsIgnoreCase("rdf:RDF")) {
compartment.addMiriamData(xmlAnnotationParser.parseRdfNode(annotationNode));
} else if (annotationNode.getNodeName().equalsIgnoreCase("celldesigner:extension")) {
parseExtensionNode(compartment, annotationNode);
Node node = annotationNodes.item(y);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equalsIgnoreCase("rdf:RDF")) {
compartment.addMiriamData(xmlAnnotationParser.parseRdfNode(node));
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:extension")) {
parseExtensionNode(compartment, node);
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:name")) {
compartment.setName(decodeName(XmlParser.getNodeValue(node)));
} else {
throw new InvalidXmlSchemaException(
"Unknown xml tag of compartment->annotation: " + annotationNode.getNodeName());
"Unknown xml tag of compartment->annotation: " + node.getNodeName());
}
}
}
......
......@@ -118,4 +118,12 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
assertEquals(1, model.getElements().size());
}
@Test
public void testOldCellDesignerCompartment() throws Exception {
Model model = getModelForFile("testFiles/compartment/old_compartment.xml");
Compartment c = model.getElementByElementId("ca1");
assertEquals(1, model.getElements().size());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="1">
<model id="Activin_beta_signaling_pathway">
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>2.5</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="2262" sizeY="2010"/>
<celldesigner:listOfCompartmentAliases>
<celldesigner:compartmentAlias id="ca1" compartment="c1">
<celldesigner:class>SQUARE_CLOSEUP_NORTH</celldesigner:class>
<celldesigner:point x="85.0" y="648.0"/>
<celldesigner:namePoint x="802.0" y="1973.5"/>
<celldesigner:doubleLine thickness="12.0" outerWidth="2.0" innerWidth="1.0"/>
<celldesigner:paint color="ffcccc00" scheme="Color"/>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:compartmentAlias>
</celldesigner:listOfCompartmentAliases>
<celldesigner:listOfComplexSpeciesAliases/>
<celldesigner:listOfSpeciesAliases/>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins/>
<celldesigner:listOfGenes/>
<celldesigner:listOfRNAs/>
<celldesigner:listOfAntisenseRNAs/>
<celldesigner:listOfLayers/>
<celldesigner:listOfBlockDiagrams/>
</celldesigner:extension>
</annotation>
<listOfUnitDefinitions>
<unitDefinition metaid="substance" id="substance" name="substance">
<listOfUnits>
<unit metaid="CDMT00001" kind="mole"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="volume" id="volume" name="volume">
<listOfUnits>
<unit metaid="CDMT00002" kind="litre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="area" id="area" name="area">
<listOfUnits>
<unit metaid="CDMT00003" kind="metre" exponent="2"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="length" id="length" name="length">
<listOfUnits>
<unit metaid="CDMT00004" kind="metre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="time" id="time" name="time">
<listOfUnits>
<unit metaid="CDMT00005" kind="second"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment metaid="default" id="default" size="1" units="volume"/>
<compartment id="c1" name="cytosol" outside="default">
<annotation>
<celldesigner:name>cytosol</celldesigner:name>
</annotation>
</compartment>
</listOfCompartments>
</model>
</sbml>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment