Skip to content
Snippets Groups Projects

issues that were discovered during biohackathon 2019 in Paris

Merged Piotr Gawron requested to merge wikipathways-issues into master
3 files
+ 73
29
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -14,7 +14,9 @@ import org.xml.sax.SAXException;
import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.common.geometry.LineTransformation;
import lcsb.mapviewer.converter.ConverterException;
import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.PolylineDataFactory;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.wikipathway.model.*;
@@ -148,6 +150,7 @@ public class GpmlParser {
}
if (style != null &&
!"Complex".equalsIgnoreCase(style) &&
!"Pathway".equalsIgnoreCase(style) &&
!"Group".equalsIgnoreCase(style)) {
throw new UnknownAttributeValueException(
"Unknown value of \"style\" attribute for group node: " + style
@@ -432,6 +435,8 @@ public class GpmlParser {
}
addGroups(groups, graph);
resizeGroupsByIncludedLines(graph.getGroups(), lines);
graph.addDataNodes(dataNodeParser.parseCollection(dataNodes));
graph.addLabels(labelParser.parseCollection(labels));
graph.addShapes(shapeParser.parseCollection(shapes));
@@ -466,6 +471,22 @@ public class GpmlParser {
}
}
private void resizeGroupsByIncludedLines(Collection<Group> groups, List<Node> lines) throws UnknownTypeException {
for (Node lNode : lines) {
String groupId = XmlParser.getNodeAttr("GroupRef", lNode);
if (groupId != null) {
for (Group group : groups) {
if (group.getGroupId().equals(groupId)) {
PolylineData polyline = parseLine(lNode);
if (polyline != null) {
group.addBounds(PolylineDataFactory.getBounds(polyline));
}
}
}
}
}
}
/**
* This method merge edges that should be merged into single line.
*
@@ -622,41 +643,49 @@ public class GpmlParser {
* thrown when the type of line defined in xml node is unknown
*/
private Collection<PolylineData> parseLines(List<Node> lines) throws UnknownTypeException {
List<PolylineData> result = new ArrayList<PolylineData>();
List<PolylineData> result = new ArrayList<>();
for (Node lNode : lines) {
int refs = 0;
PolylineData line = new PolylineData();
NodeList nodes = lNode.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equalsIgnoreCase("Graphics")) {
NodeList nodes2 = node.getChildNodes();
for (int j = 0; j < nodes2.getLength(); j++) {
Node node2 = nodes2.item(j);
if (node2.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node2;
if (node2.getNodeName().equalsIgnoreCase("Point")) {
PointData point = pointParser.parse(element);
if (point.hasGraphRef()) {
refs++;
}
line.addPoint(point.toPoint());
} else {
logger.warn("Unknown node in line: " + node2.getNodeName());
PolylineData line = parseLine(lNode);
if (line != null) {
result.add(line);
}
}
return result;
}
private PolylineData parseLine(Node lNode) throws UnknownTypeException {
int refs = 0;
PolylineData line = new PolylineData();
NodeList nodes = lNode.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equalsIgnoreCase("Graphics")) {
NodeList nodes2 = node.getChildNodes();
for (int j = 0; j < nodes2.getLength(); j++) {
Node node2 = nodes2.item(j);
if (node2.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node2;
if (node2.getNodeName().equalsIgnoreCase("Point")) {
PointData point = pointParser.parse(element);
if (point.hasGraphRef()) {
refs++;
}
line.addPoint(point.toPoint());
} else {
logger.warn("Unknown node in line: " + node2.getNodeName());
}
}
} else {
logger.warn("Unknown node in line: " + node.getNodeName());
}
} else {
logger.warn("Unknown node in line: " + node.getNodeName());
}
}
if (refs < 2) {
result.add(line);
}
}
return result;
if (refs >= 2) {
line = null;
}
return line;
}
}
Loading