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

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

parent c7034c9b
......@@ -6,6 +6,8 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.converter.model.sbml.SbmlModelUtils;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.*;
......@@ -49,7 +51,8 @@ public enum SBOTermReactionType {
}
}
public static Class<? extends Reaction> getTypeSBOTerm(String sboTerm) {
public static Class<? extends Reaction> getTypeSBOTerm(org.sbml.jsbml.Reaction reaction) {
String sboTerm = reaction.getSBOTermID();
if (sboTerm == null || sboTerm.isEmpty()) {
return StateTransitionReaction.class;
}
......@@ -62,7 +65,8 @@ public enum SBOTermReactionType {
}
}
if (result == null) {
logger.warn("Don't know how to handle SBOTerm " + sboTerm + " for reaction");
logger.warn(SbmlModelUtils.createMarker(ProjectLogEntryType.PARSING_ISSUE, reaction),
"Don't know how to handle SBOTerm " + sboTerm + " for reaction");
result = StateTransitionReaction.class;
}
return result;
......
......@@ -740,16 +740,14 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
reaction.addProduct(new Product(element));
}
String sboTerm = sbmlReaction.getSBOTermID();
reaction = createProperReactionClassForSboTerm(reaction, sboTerm);
reaction = createProperReactionClassForSboTerm(reaction, sbmlReaction);
return reaction;
}
private Reaction createProperReactionClassForSboTerm(Reaction reaction, String sboTerm)
private Reaction createProperReactionClassForSboTerm(Reaction reaction, org.sbml.jsbml.Reaction sbmlReaction)
throws InvalidInputDataExecption {
Class<? extends Reaction> reactionClass = SBOTermReactionType.getTypeSBOTerm(sboTerm);
Class<? extends Reaction> reactionClass = SBOTermReactionType.getTypeSBOTerm(sbmlReaction);
try {
reaction = reactionClass.getConstructor(Reaction.class).newInstance(reaction);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
......
......@@ -9,7 +9,8 @@ import org.junit.runners.Suite.SuiteClasses;
SbmlReactionExporterTest.class,
SbmlReactionParserTest.class,
SbmlReactionParserExtractCurveTest.class,
SBOTermModifierTypeTest.class
SBOTermModifierTypeTest.class,
SBOTermReactionTypeTest.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.Reaction;
import lcsb.mapviewer.converter.model.sbml.SbmlTestFunctions;
public class SBOTermReactionTypeTest extends SbmlTestFunctions {
@Test
public void testTypeForUnknownSBOTerm() {
Reaction reaction = new Reaction(3, 2);
reaction.setSBOTerm("SBO:0000000");
Class<? extends lcsb.mapviewer.model.map.reaction.Reaction> clazz = SBOTermReactionType.getTypeSBOTerm(reaction);
assertNotNull(clazz);
assertEquals(1, super.getWarnings().size());
assertNotNull(super.getWarnings().get(0).getMarker());
}
}
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