Commit 88d42a60 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1268-export-as-gpml-nice-to-have' into 'master'

Resolve "export as GPML - nice to have"

Closes #1268

See merge request !1165
parents 70641c12 e8ae8ebd
Pipeline #27937 passed with stage
in 12 minutes and 8 seconds
......@@ -8,6 +8,12 @@ minerva (15.0.0~beta.5) unstable; urgency=medium
* Bug fix: there is a bug in PathVisio that breaks short segments being the
end of catalist therefore short segments are removed from export (#1263)
* Bug fix: conversion of file containing BOM did not work (#1264)
* Bug fix: dashed elements imported from GPML are treated as hypothetical
(#1268)
* Bug fix: hypothetical elements exported to GPML are drawn with dashed line
(#1268)
* Bug fix: proper color is parsed from CellDesigner species marked as 'brief'
(#1268)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 2 Jun 2020 16:00:00 +0200
......
......@@ -114,7 +114,7 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
if (state.equalsIgnoreCase("usual")) {
view = usualView;
} else if (state.equalsIgnoreCase("brief")) {
view = briefView;
view = usualView;
}
if (view != null) {
......
......@@ -125,6 +125,9 @@ public class ModelContructor {
}
species.addMiriamData(dataNode.getReferences());
if (dataNode.getLineType() == LineType.DASHED) {
species.setHypothetical(true);
}
species.setName(dataNode.getName());
StringBuilder notes = new StringBuilder();
for (String comment : dataNode.getComments()) {
......
......@@ -17,7 +17,6 @@ import lcsb.mapviewer.converter.ConverterException;
import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.PolylineDataFactory;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamData;
......@@ -61,7 +60,6 @@ public class ModelToGPML {
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private final Logger logger = LogManager.getLogger();
/**
......@@ -597,6 +595,11 @@ public class ModelToGPML {
private String speciesToDataNode(Species species) throws ConverterException {
StringBuilder result = new StringBuilder();
String lineStyle = null;
if (species.isHypothetical()) {
lineStyle = GpmlLineType.DASHED.getGpmlString();
}
result.append(
" <DataNode TextLabel=\"" + species.getName() + "\" "
+ "GraphId=\"" + species.getElementId() + "\""
......@@ -620,8 +623,12 @@ public class ModelToGPML {
"FontSize=\"" + species.getFontSize().intValue() + "\" " +
"Valign=\"Middle\" " +
"Color=\"" + colorToString(species.getFontColor()) + "\" " +
"ShapeType=\"" + ShapeMapping.getShape(species.getClass()).getStringRepresentation() + "\" " +
"FillColor=\"" + colorToString(species.getFillColor()) + "\"/>\n");
"ShapeType=\"" + ShapeMapping.getShape(species.getClass()).getStringRepresentation() + "\" ");
if (lineStyle != null) {
result.append("LineStyle=\"" + lineStyle + "\" ");
}
result.append("FillColor=\"" + colorToString(species.getFillColor()) + "\"/>\n");
result.append(
referenceParser.toXml(species.getMiriamData(), new LogMarker(ProjectLogEntryType.EXPORT_ISSUE, species)));
......@@ -709,10 +716,7 @@ public class ModelToGPML {
String reactionArrowHead = InteractionMapping.getGpmlInteractionTypeForMinervaReactionClass(reaction.getClass())
.getGpmlString();
String lineStyle = null;
if (reaction.getLine().getType() == LineType.DASHED) {
lineStyle = GpmlLineType.DASHED.getGpmlString();
}
String lineStyle = GpmlLineType.getByLineType(reaction.getLine().getType()).getGpmlString();
StringBuilder anchors = new StringBuilder("");
StringBuilder tmp = new StringBuilder("");
......
......@@ -45,12 +45,12 @@ public enum GpmlLineType {
/**
* Returns {@link GpmlLineType type} identified by {@link #gpmlName gpml string}
* identifing the type.
* identifying the type.
*
* @param gpmlName
* {@link #gpmlString}
* @return {@link GpmlLineType type} identified by {@link #gpmlName gpml string}
* identifing the type
* identifying the type
* @throws UnknownTypeException
* thrown when type cannot be found
*/
......@@ -67,6 +67,15 @@ public enum GpmlLineType {
throw new UnknownTypeException("Unknown line type: " + gpmlName);
}
public static GpmlLineType getByLineType(LineType lineType) throws UnknownTypeException {
for (GpmlLineType type : values()) {
if (type.correspondingGlobalLineType == lineType) {
return type;
}
}
return GpmlLineType.SOLID;
}
/**
* @return the gpmlString
* @see #gpmlString
......
......@@ -321,7 +321,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
result.setX(1);
result.setY(1);
result.setZ(15);
result.setNamePoint(result.getCenter());
result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.MIDDLE);
......@@ -336,6 +336,11 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
protein.setX(100 * speciesCounter);
protein.setY(10 + 100 * speciesCounter * Math.random());
protein.setZ(15);
protein.setNamePoint(protein.getCenter());
protein.setNameHorizontalAlign(HorizontalAlign.CENTER);
protein.setNameVerticalAlign(VerticalAlign.MIDDLE);
return protein;
}
......@@ -360,4 +365,25 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
compartment.setZ(15);
return compartment;
}
@Test
public void testExportHypothetical() throws Exception {
Model model = new ModelFullIndexed(null);
model.setWidth(1000);
model.setHeight(1000);
Protein p1 = createProtein();
p1.setHypothetical(true);
p1.addResidue(createResidue(p1));
model.addElement(p1);
lcsb.mapviewer.wikipathway.GpmlParser parser = new lcsb.mapviewer.wikipathway.GpmlParser();
String xml = parser.model2String(model);
Model model2 = parser.createModel(new ConverterParams().inputStream(new ByteArrayInputStream(xml.getBytes())));
assertEquals(0, new ModelComparator().compare(model, model2));
}
}
......@@ -12,14 +12,14 @@ rootLogger.appenderRef.console.ref = STDOUT
logger.minerva.name = lcsb
logger.minerva.level = debug
logger.minerva-persist.name = lcsb.mapviewer.persist.DbUtils
logger.minerva-persist.level = info
logger.minerva-cache.name = lcsb.mapviewer.annotation.cache
logger.minerva-cache.level = info
logger.minerva-comparator.name = lcsb.mapviewer.common.Comparator
logger.minerva-comparator.level = info
logger.minerva-model.name = lcsb.mapviewer.model
logger.minerva-model.level = info
#logger.minerva-persist.name = lcsb.mapviewer.persist.DbUtils
#logger.minerva-persist.level = info
#logger.minerva-cache.name = lcsb.mapviewer.annotation.cache
#logger.minerva-cache.level = info
#logger.minerva-comparator.name = lcsb.mapviewer.common.Comparator
#logger.minerva-comparator.level = info
#logger.minerva-model.name = lcsb.mapviewer.model
#logger.minerva-model.level = info
logger.springframework.name = org.springframework
logger.springframework.level = warn
......
Supports Markdown
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