Commit e5887345 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

export to SBGN fixed

parent cbf71479
......@@ -11,6 +11,8 @@ minerva (14.0.8) stable; urgency=medium
information (#1062)
* Bug fix: import of stimulation modifiers from SBGN-ML crashed converter
(#1063)
* Bug fix: export to SBGN files created from newt source produced corrupted
disconnected reactions
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 23 Jan 2020 12:00:00 +0200
......
......@@ -192,7 +192,7 @@ public class SbgnmlXmlExporter {
}
}
sourceTargetMap.put(newGlyph.getId(), newGlyph);
sourceTargetMap.put(element.getElementId(), newGlyph);
return newGlyph;
}
......@@ -844,6 +844,7 @@ public class SbgnmlXmlExporter {
if (!node.getLine().getEndAtd().getArrowType().equals(ArrowType.NONE)) {
arc.setTarget(sourceTargetMap.get(node.getReaction().getIdReaction()));
} else {
boolean found = false;
for (NodeOperator operator : node.getReaction().getOperators()) {
if (operator.getInputs().contains(node)) {
if (!parsedOperators.contains(operator)) {
......@@ -851,8 +852,13 @@ public class SbgnmlXmlExporter {
glyphList.add(newOperator);
}
arc.setTarget(sourceTargetMap.get(operatorIds.get(operator).concat(".1")));
found = true;
}
}
if (!found) {
throw new InvalidArgumentException(
new ElementUtils().getElementTag((Modifier) node) + "Problem with exportin modifier");
}
}
} else if (node instanceof NodeOperator) {
if ((node instanceof DissociationOperator) || (node instanceof AssociationOperator)) {
......@@ -873,7 +879,7 @@ public class SbgnmlXmlExporter {
}
}
}
List<Point2D> arcPoints = node.getLine().getPoints();
Start start = new Start();
if ((node instanceof Product) || (node instanceof NodeOperator)) {
......
......@@ -3,6 +3,7 @@ package lcsb.mapviewer.converter.model.sbgnml;
import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import java.io.InputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -13,6 +14,7 @@ import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.GenericProtein;
......@@ -116,7 +118,35 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
logger.debug(sbgn);
assertTrue("State variable is missing", sbgn.contains("state variable"));
assertTrue("State variable doesn't contain variable", sbgn.contains("variable=\"g\""));
}
@Test
public void testStimulationModification() throws Exception {
Converter converter = new SbgnmlXmlConverter();
Model model = converter.createModel(
new ConverterParams().filename("testFiles/sbgnmlParserTestFiles/sbgnmlFiles/stimulation_modification.sbgn"));
for (Reaction r : model.getReactions()) {
assertEquals(1, r.getModifiers().size());
}
}
@Test
public void testExportStimulationModification() throws Exception {
Converter converter = new SbgnmlXmlConverter();
Model model = converter.createModel(
new ConverterParams().filename("testFiles/sbgnmlParserTestFiles/sbgnmlFiles/stimulation_modification.sbgn"));
InputStream is = converter.model2InputStream(model);
Model model2 = converter.createModel(new ConverterParams().inputStream(is));
for (Reaction r : model2.getReactions()) {
assertEquals(1, r.getModifiers().size());
}
}
}
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