Commit 264c8d02 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

info about species is added to marker

parent dd880c0e
......@@ -2,6 +2,8 @@ minerva (16.0.0~alpha.2) stable; urgency=medium
* Backward incompatibility: debian package cannot be upgraded from version
prior to 12.1.0 (#1464)
* Small improvement: homomultimer information is provided in API (#1468)
* Small improvement: missing info about species for SBML parsing warning
(#1472)
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 26 Mar 2021 10:00:00 +0200
......
......@@ -8,6 +8,8 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.converter.model.sbml.SbmlModelUtils;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.species.*;
public enum SBOTermSpeciesType {
......@@ -50,7 +52,7 @@ public enum SBOTermSpeciesType {
this.hypothetical = hypothetical;
}
private static SBOTermSpeciesType getTypeSBOTerm(String sboTerm) {
private static SBOTermSpeciesType getTypeSBOTerm(String sboTerm, org.sbml.jsbml.Species species) {
if (sboTerm == null || sboTerm.isEmpty()) {
return SIMPLE_MOLECULE;
}
......@@ -63,17 +65,18 @@ public enum SBOTermSpeciesType {
}
}
if (result == null) {
logger.warn("Don't know how to handle SBOTerm " + sboTerm + " for species");
logger.warn(SbmlModelUtils.createMarker(ProjectLogEntryType.PARSING_ISSUE, species),
"Don't know how to handle SBOTerm " + sboTerm);
result = SIMPLE_MOLECULE;
}
return result;
}
public static Species createElementForSBOTerm(String sboTerm, String elementId) {
public static Species createElementForSBOTerm(String sboTerm, org.sbml.jsbml.Species species) {
try {
SBOTermSpeciesType type = getTypeSBOTerm(sboTerm);
SBOTermSpeciesType type = getTypeSBOTerm(sboTerm, species);
Class<? extends Species> clazz = type.clazz;
Species result = clazz.getConstructor(String.class).newInstance(elementId);
Species result = clazz.getConstructor(String.class).newInstance(species.getId());
if (type.hypothetical) {
result.setHypothetical(true);
}
......
......@@ -514,7 +514,7 @@ public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species>
@Override
protected Species parse(org.sbml.jsbml.Species species) throws InvalidInputDataExecption {
String sboTerm = extractSBOTermFromSpecies(species);
Species result = SBOTermSpeciesType.createElementForSBOTerm(sboTerm, species.getId());
Species result = SBOTermSpeciesType.createElementForSBOTerm(sboTerm, species);
if (!Double.isNaN(species.getInitialAmount())) {
result.setInitialAmount(species.getInitialAmount());
}
......
......@@ -6,10 +6,11 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
ModificationResidueExporterTest.class,
SbmlSpeciesExporterRenderShapeTest.class,
SbmlSpeciesExporterTest.class,
SbmlSpeciesParserTest.class })
ModificationResidueExporterTest.class,
SbmlSpeciesExporterRenderShapeTest.class,
SbmlSpeciesExporterTest.class,
SbmlSpeciesParserTest.class,
SBOTermSpeciesTypeTest.class })
public class AllSbmlSpeciesTests {
}
package lcsb.mapviewer.converter.model.sbml.species;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.sbml.jsbml.Species;
import lcsb.mapviewer.converter.model.sbml.SbmlTestFunctions;
import lcsb.mapviewer.model.map.species.Element;
public class SBOTermSpeciesTypeTest extends SbmlTestFunctions {
@Test
public void testCreateElementForSBOTerm() {
Species species = new Species(3, 2);
species.setSBOTerm("SBO:0000000");
Element element = SBOTermSpeciesType.createElementForSBOTerm("SBO:0000000", species);
assertNotNull(element);
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