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; ...@@ -6,6 +6,8 @@ import java.util.List;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; 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.Reaction;
import lcsb.mapviewer.model.map.reaction.type.*; import lcsb.mapviewer.model.map.reaction.type.*;
...@@ -49,7 +51,8 @@ public enum SBOTermReactionType { ...@@ -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()) { if (sboTerm == null || sboTerm.isEmpty()) {
return StateTransitionReaction.class; return StateTransitionReaction.class;
} }
...@@ -62,7 +65,8 @@ public enum SBOTermReactionType { ...@@ -62,7 +65,8 @@ public enum SBOTermReactionType {
} }
} }
if (result == null) { 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; result = StateTransitionReaction.class;
} }
return result; return result;
......
...@@ -740,16 +740,14 @@ public class SbmlReactionParser extends SbmlBioEntityParser { ...@@ -740,16 +740,14 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
reaction.addProduct(new Product(element)); reaction.addProduct(new Product(element));
} }
String sboTerm = sbmlReaction.getSBOTermID(); reaction = createProperReactionClassForSboTerm(reaction, sbmlReaction);
reaction = createProperReactionClassForSboTerm(reaction, sboTerm);
return reaction; return reaction;
} }
private Reaction createProperReactionClassForSboTerm(Reaction reaction, String sboTerm) private Reaction createProperReactionClassForSboTerm(Reaction reaction, org.sbml.jsbml.Reaction sbmlReaction)
throws InvalidInputDataExecption { throws InvalidInputDataExecption {
Class<? extends Reaction> reactionClass = SBOTermReactionType.getTypeSBOTerm(sboTerm); Class<? extends Reaction> reactionClass = SBOTermReactionType.getTypeSBOTerm(sbmlReaction);
try { try {
reaction = reactionClass.getConstructor(Reaction.class).newInstance(reaction); reaction = reactionClass.getConstructor(Reaction.class).newInstance(reaction);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
......
...@@ -9,7 +9,8 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -9,7 +9,8 @@ import org.junit.runners.Suite.SuiteClasses;
SbmlReactionExporterTest.class, SbmlReactionExporterTest.class,
SbmlReactionParserTest.class, SbmlReactionParserTest.class,
SbmlReactionParserExtractCurveTest.class, SbmlReactionParserExtractCurveTest.class,
SBOTermModifierTypeTest.class SBOTermModifierTypeTest.class,
SBOTermReactionTypeTest.class,
}) })
public class AllSbmlReactionParserTests { 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