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

element info added to modifier warnings: Don't know how to handle SBOTerm

parent 74f87ef3
......@@ -4,12 +4,15 @@ import java.awt.Color;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.sbml.jsbml.AbstractNamedSBase;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.ext.SBasePlugin;
import org.sbml.jsbml.ext.layout.*;
import org.sbml.jsbml.ext.render.*;
import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.graphics.ArrowType;
public class SbmlModelUtils {
......@@ -247,4 +250,14 @@ public class SbmlModelUtils {
return result;
}
public static LogMarker createMarker(ProjectLogEntryType type, AbstractNamedSBase element) {
if (element == null) {
return new LogMarker(type, "", "N/A", "N/A");
} else if (element.getModel() == null) {
return new LogMarker(type, element.getClass().getSimpleName(), element.getId(), "");
} else {
return new LogMarker(type, element.getClass().getSimpleName(), element.getId(), element.getModel().getName());
}
}
}
......@@ -5,7 +5,10 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.sbml.jsbml.ModifierSpeciesReference;
import lcsb.mapviewer.converter.model.sbml.SbmlModelUtils;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.modifier.*;
import lcsb.mapviewer.model.map.reaction.Modifier;
......@@ -31,7 +34,8 @@ public enum SBOTermModifierType {
}
}
public static Class<? extends Modifier> getTypeSBOTerm(String sboTerm) {
public static Class<? extends Modifier> getTypeSBOTerm(ModifierSpeciesReference modifier) {
String sboTerm = modifier.getSBOTermID();
if (sboTerm == null || sboTerm.isEmpty()) {
return Modifier.class;
}
......@@ -43,8 +47,10 @@ public enum SBOTermModifierType {
}
}
}
if (result == null) {
logger.warn("Don't know how to handle SBOTerm " + sboTerm + " for modifier");
logger.warn(SbmlModelUtils.createMarker(ProjectLogEntryType.PARSING_ISSUE, modifier),
"Don't know how to handle SBOTerm " + sboTerm + " for modifier");
result = Modifier.class;
}
return result;
......
......@@ -707,7 +707,7 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
for (ModifierSpeciesReference modifier : sbmlReaction.getListOfModifiers()) {
Species element = getMinervaModel().getElementByElementId(modifier.getSpecies());
Class<? extends Modifier> nodeClass = SBOTermModifierType.getTypeSBOTerm(modifier.getSBOTermID());
Class<? extends Modifier> nodeClass = SBOTermModifierType.getTypeSBOTerm(modifier);
try {
Modifier newNode = nodeClass.getConstructor(Element.class).newInstance(element);
reaction.addModifier(newNode);
......
......@@ -8,7 +8,8 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({ SbmlReactionExportArrowType.class,
SbmlReactionExporterTest.class,
SbmlReactionParserTest.class,
SbmlReactionParserExtractCurveTest.class
SbmlReactionParserExtractCurveTest.class,
SBOTermModifierTypeTest.class
})
public class AllSbmlReactionParserTests {
......
package lcsb.mapviewer.converter.model.sbml.reaction;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.sbml.jsbml.ModifierSpeciesReference;
import lcsb.mapviewer.converter.model.sbml.SbmlTestFunctions;
import lcsb.mapviewer.model.map.reaction.Modifier;
public class SBOTermModifierTypeTest extends SbmlTestFunctions {
@Test
public void testUnknownId() {
ModifierSpeciesReference reference = new ModifierSpeciesReference(3, 2);
reference.setSBOTerm("SBO:0000000");
Class<? extends Modifier> clazz = SBOTermModifierType.getTypeSBOTerm(reference);
assertNotNull(clazz);
assertEquals(1, super.getWarnings().size());
assertNotNull(super.getWarnings().get(0).getMarker());
}
}
This diff is collapsed.
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