Skip to content
Snippets Groups Projects
Commit 8bf97b9b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

parsing of compartment notes added

parent 91d3497e
No related branches found
No related tags found
1 merge request!30Fixes on showing semantic in compartments
......@@ -7,6 +7,7 @@ import org.w3c.dom.NodeList;
import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection;
import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
import lcsb.mapviewer.converter.model.celldesigner.annotation.XmlAnnotationParser;
import lcsb.mapviewer.converter.model.celldesigner.species.AbstractElementXmlParser;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment;
......@@ -26,12 +27,12 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(CompartmentXmlParser.class.getName());
private static Logger logger = Logger.getLogger(CompartmentXmlParser.class.getName());
/**
* Parser used to retrieve Miriam data for the element.
*/
private XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser();
private XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser();
/**
* Collection of {@link CellDesignerElement cell designer elements} parsed
......@@ -39,6 +40,11 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC
*/
private CellDesignerElementCollection elements;
/**
* Xml parser used for processing notes into structurized data.
*/
private RestAnnotationParser rap = new RestAnnotationParser();
/**
* Default constructor.
*
......@@ -63,6 +69,8 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equalsIgnoreCase("annotation")) {
parseAnnotationNode(compartment, node);
} else if (node.getNodeName().equalsIgnoreCase("notes")) {
compartment.setNotes(rap.getNotes(node));
} else {
throw new InvalidXmlSchemaException("Unknown element of Compartment: " + node.getNodeName());
}
......@@ -132,8 +140,7 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC
sb.append("size=\"1\" ");
sb.append("units=\"volume\" ");
String parentName = "default";
if (compartment.getCompartment() != null && !(compartment.getCompartment() instanceof PathwayCompartment)) {
parentName = elements.getElementId(compartment.getCompartment());
}
......
......@@ -975,4 +975,17 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
}
}
@Test
public void testCompartmentWithNotes() throws Exception {
try {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser.createModel(new ConverterParams().filename("testFiles/compartment_with_notes.xml"));
assertNotNull(model);
assertEquals("notes", model.getCompartments().get(0).getNotes());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="4">
<model metaid="untitled" id="untitled">
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>4.0</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="600" sizeY="400"/>
<celldesigner:listOfCompartmentAliases>
<celldesigner:compartmentAlias id="ca1" compartment="c1">
<celldesigner:class>SQUARE</celldesigner:class>
<celldesigner:bounds x="108.0" y="82.0" w="265.0" h="160.0"/>
<celldesigner:namePoint x="233.0" y="205.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 metaid="c1" id="c1" name="c1" size="1" units="volume" outside="default">
<notes>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body>notes
</body>
</html>
</notes>
<annotation>
<celldesigner:extension>
<celldesigner:name>c1</celldesigner:name>
</celldesigner:extension>
</annotation>
</compartment>
</listOfCompartments>
</model>
</sbml>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment