Commit 2dcc5326 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1472-missing-info-about-species-id-for-sbml-import-warnings' into 'master'

Resolve "missing info about species id for sbml import warnings"

Closes #1472

See merge request !1294
parents 74f87ef3 a65a8f68
Pipeline #40064 failed with stage
in 23 minutes and 29 seconds
...@@ -2,6 +2,9 @@ minerva (16.0.0~alpha.2) stable; urgency=medium ...@@ -2,6 +2,9 @@ minerva (16.0.0~alpha.2) stable; urgency=medium
* Backward incompatibility: debian package cannot be upgraded from version * Backward incompatibility: debian package cannot be upgraded from version
prior to 12.1.0 (#1464) prior to 12.1.0 (#1464)
* Small improvement: homomultimer information is provided in API (#1468) * Small improvement: homomultimer information is provided in API (#1468)
* Small improvement: missing info about species for SBML parsing warning
(#1472)
* Small improvement: glyph quality is improved (#1458)
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 26 Mar 2021 10:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 26 Mar 2021 10:00:00 +0200
......
...@@ -88,7 +88,7 @@ public class CopyPasteAbstractAction { ...@@ -88,7 +88,7 @@ public class CopyPasteAbstractAction {
*/ */
protected String getCopyString(String annotationString, String notesString) throws InvalidXmlSchemaException { protected String getCopyString(String annotationString, String notesString) throws InvalidXmlSchemaException {
XmlAnnotationParser xap = new XmlAnnotationParser(); XmlAnnotationParser xap = new XmlAnnotationParser();
Set<MiriamData> set = xap.parse(annotationString); Set<MiriamData> set = xap.parse(annotationString, null);
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (MiriamData md : set) { for (MiriamData md : set) {
result.append(serialize(md) + "\n"); result.append(serialize(md) + "\n");
......
...@@ -395,7 +395,7 @@ public class CellDesignerXmlParser extends Converter { ...@@ -395,7 +395,7 @@ public class CellDesignerXmlParser extends Converter {
private void processModelRdfNode(Model model, Node node) throws InvalidXmlSchemaException { private void processModelRdfNode(Model model, Node node) throws InvalidXmlSchemaException {
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser( XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser(
CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER); CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
model.addMiriamData(xmlAnnotationParser.parseRdfNode(node)); model.addMiriamData(xmlAnnotationParser.parseRdfNode(node, null));
model.addAuthors(xmlAnnotationParser.getAuthorsFromRdf(node)); model.addAuthors(xmlAnnotationParser.getAuthorsFromRdf(node));
model.setCreationDate(xmlAnnotationParser.getCreateDateFromRdf(node)); model.setCreationDate(xmlAnnotationParser.getCreateDateFromRdf(node));
model.addModificationDates(xmlAnnotationParser.getModificationDatesFromRdf(node)); model.addModificationDates(xmlAnnotationParser.getModificationDatesFromRdf(node));
......
...@@ -885,7 +885,8 @@ public class RestAnnotationParser { ...@@ -885,7 +885,8 @@ public class RestAnnotationParser {
Matcher nodeMatcher = rdfNodePattern.matcher(notes); Matcher nodeMatcher = rdfNodePattern.matcher(notes);
if (nodeMatcher.find()) { if (nodeMatcher.find()) {
String rdfString = "<rdf:RDF" + nodeMatcher.group(1) + "</rdf:RDF>"; String rdfString = "<rdf:RDF" + nodeMatcher.group(1) + "</rdf:RDF>";
element.addMiriamData(xmlAnnotationParser.parse(rdfString)); element.addMiriamData(
xmlAnnotationParser.parse(rdfString, new LogMarker(ProjectLogEntryType.PARSING_ISSUE, element)));
notes = notes.substring(0, nodeMatcher.start() - "<rdf:RDF".length()) notes = notes.substring(0, nodeMatcher.start() - "<rdf:RDF".length())
+ notes.substring(nodeMatcher.end() + "</rdf:RDF>".length()); + notes.substring(nodeMatcher.end() + "</rdf:RDF>".length());
......
...@@ -15,6 +15,8 @@ import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationPars ...@@ -15,6 +15,8 @@ import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationPars
import lcsb.mapviewer.converter.model.celldesigner.species.AbstractElementXmlParser; import lcsb.mapviewer.converter.model.celldesigner.species.AbstractElementXmlParser;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
...@@ -144,7 +146,9 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC ...@@ -144,7 +146,9 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC
Node node = annotationNodes.item(y); Node node = annotationNodes.item(y);
if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equalsIgnoreCase("rdf:RDF")) { if (node.getNodeName().equalsIgnoreCase("rdf:RDF")) {
compartment.addMiriamData(xmlAnnotationParser.parseRdfNode(node)); compartment.addMiriamData(xmlAnnotationParser.parseRdfNode(node,
new LogMarker(ProjectLogEntryType.PARSING_ISSUE, compartment.getClass().getSimpleName(),
compartment.getElementId(), "")));
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:extension")) { } else if (node.getNodeName().equalsIgnoreCase("celldesigner:extension")) {
parseExtensionNode(compartment, node); parseExtensionNode(compartment, node);
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:name")) { } else if (node.getNodeName().equalsIgnoreCase("celldesigner:name")) {
......
...@@ -19,6 +19,8 @@ import lcsb.mapviewer.converter.model.celldesigner.geometry.ReactionCellDesigner ...@@ -19,6 +19,8 @@ import lcsb.mapviewer.converter.model.celldesigner.geometry.ReactionCellDesigner
import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.*; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.*;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.*; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.*;
import lcsb.mapviewer.converter.model.celldesigner.types.*; import lcsb.mapviewer.converter.model.celldesigner.types.*;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.graphics.*; import lcsb.mapviewer.model.graphics.*;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.Model;
...@@ -313,7 +315,8 @@ public class ReactionFromXml { ...@@ -313,7 +315,8 @@ public class ReactionFromXml {
try { try {
XmlAnnotationParser xmlParser = new XmlAnnotationParser( XmlAnnotationParser xmlParser = new XmlAnnotationParser(
CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER); CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
result.addMiriamData(xmlParser.parseRdfNode(node)); result.addMiriamData(xmlParser.parseRdfNode(node, new LogMarker(ProjectLogEntryType.PARSING_ISSUE,
result.getClass().getSimpleName(), result.getElementId(), model.getName())));
} catch (InvalidXmlSchemaException e) { } catch (InvalidXmlSchemaException e) {
throw new ReactionParserException("Problem with parsing RDF", result, e); throw new ReactionParserException("Problem with parsing RDF", result, e);
} }
......
...@@ -17,6 +17,8 @@ import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationPars ...@@ -17,6 +17,8 @@ import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationPars
import lcsb.mapviewer.converter.model.celldesigner.structure.*; import lcsb.mapviewer.converter.model.celldesigner.structure.*;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
import lcsb.mapviewer.model.map.kinetics.SbmlUnit; import lcsb.mapviewer.model.map.kinetics.SbmlUnit;
...@@ -198,7 +200,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec ...@@ -198,7 +200,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
if (rdfNode != null) { if (rdfNode != null) {
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser( XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser(
CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER); CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
species.addMiriamData(xmlAnnotationParser.parseRdfNode(rdfNode)); species.addMiriamData(xmlAnnotationParser.parseRdfNode(rdfNode, new LogMarker(ProjectLogEntryType.PARSING_ISSUE,
species.getClass().getSimpleName(), species.getElementId(), "")));
} }
return result; return result;
......
...@@ -984,7 +984,8 @@ public class SbgnmlXmlParser { ...@@ -984,7 +984,8 @@ public class SbgnmlXmlParser {
"No rdf node provided in annotation extension"); "No rdf node provided in annotation extension");
} else { } else {
try { try {
element.addMiriamData(new XmlAnnotationParser().parseRdfNode(rdf)); element.addMiriamData(
new XmlAnnotationParser().parseRdfNode(rdf, new LogMarker(ProjectLogEntryType.PARSING_ISSUE, element)));
} catch (InvalidXmlSchemaException e) { } catch (InvalidXmlSchemaException e) {
logger.error(e, e); logger.error(e, e);
} }
...@@ -1677,7 +1678,7 @@ public class SbgnmlXmlParser { ...@@ -1677,7 +1678,7 @@ public class SbgnmlXmlParser {
List<Line2D> lines = new ArrayList<>(product.getLine().getLines()); List<Line2D> lines = new ArrayList<>(product.getLine().getLines());
product.getLine().removeLines(); product.getLine().removeLines();
Collections.reverse(lines); Collections.reverse(lines);
for (Line2D l: lines) { for (Line2D l : lines) {
product.getLine().addLine(l.getP2(), l.getP1()); product.getLine().addLine(l.getP2(), l.getP1());
} }
} }
......
...@@ -99,10 +99,11 @@ public abstract class ElementConverter<T extends Element> extends BioEntityConve ...@@ -99,10 +99,11 @@ public abstract class ElementConverter<T extends Element> extends BioEntityConve
protected void drawGlyph(T bioEntity, Graphics2D graphics) throws DrawingException { protected void drawGlyph(T bioEntity, Graphics2D graphics) throws DrawingException {
try { try {
Image img = ImageIO.read(new ByteArrayInputStream(bioEntity.getGlyph().getFile().getFileContent())); Image img = ImageIO.read(new ByteArrayInputStream(bioEntity.getGlyph().getFile().getFileContent()));
graphics.drawImage(img,
Image scaledImage = img.getScaledInstance(bioEntity.getWidth().intValue(), bioEntity.getHeight().intValue(), Image.SCALE_SMOOTH);
graphics.drawImage(scaledImage,
bioEntity.getX().intValue(), bioEntity.getY().intValue(), bioEntity.getX().intValue(), bioEntity.getY().intValue(),
(int) (bioEntity.getX() + bioEntity.getWidth()), (int) (bioEntity.getY() + bioEntity.getHeight()),
0, 0, img.getWidth(null), img.getHeight(null),
null); null);
} catch (IOException e) { } catch (IOException e) {
throw new DrawingException( throw new DrawingException(
......
...@@ -16,6 +16,7 @@ import lcsb.mapviewer.common.UnitTestFailedWatcher; ...@@ -16,6 +16,7 @@ import lcsb.mapviewer.common.UnitTestFailedWatcher;
import lcsb.mapviewer.model.graphics.*; import lcsb.mapviewer.model.graphics.*;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
import lcsb.mapviewer.model.map.compartment.SquareCompartment; import lcsb.mapviewer.model.map.compartment.SquareCompartment;
import lcsb.mapviewer.model.map.layout.graphics.LayerText;
import lcsb.mapviewer.model.map.modifier.Catalysis; import lcsb.mapviewer.model.map.modifier.Catalysis;
import lcsb.mapviewer.model.map.reaction.*; import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
...@@ -93,6 +94,19 @@ public abstract class GraphicsTestFunctions { ...@@ -93,6 +94,19 @@ public abstract class GraphicsTestFunctions {
return complex; return complex;
} }
protected LayerText createText() {
LayerText layerText = new LayerText();
layerText.setX(256.0);
layerText.setY(79.0);
layerText.setWidth(233.0);
layerText.setHeight(188.0);
layerText.setZ(0);
layerText.setNotes("asd as");
layerText.setColor(Color.BLACK);
return layerText;
}
protected List<Color> removeAlpha(List<Color> allValues) { protected List<Color> removeAlpha(List<Color> allValues) {
List<Color> result = new ArrayList<>(); List<Color> result = new ArrayList<>();
for (Color color : allValues) { for (Color color : allValues) {
......
package lcsb.mapviewer.converter.graphics; package lcsb.mapviewer.converter.graphics;
import java.awt.*; import java.awt.Color;
import java.awt.Desktop;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.io.File;
import java.nio.file.Files;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -10,12 +13,12 @@ import org.junit.*; ...@@ -10,12 +13,12 @@ import org.junit.*;
import lcsb.mapviewer.commands.CreateHierarchyCommand; import lcsb.mapviewer.commands.CreateHierarchyCommand;
import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.*;
import lcsb.mapviewer.model.map.layout.graphics.LayerText;
import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.*;
public class NormalImageGeneratorTest extends GraphicsTestFunctions { public class NormalImageGeneratorTest extends GraphicsTestFunctions {
static Logger logger = LogManager.getLogger(); static Logger logger = LogManager.getLogger();
...@@ -33,27 +36,15 @@ public class NormalImageGeneratorTest extends GraphicsTestFunctions { ...@@ -33,27 +36,15 @@ public class NormalImageGeneratorTest extends GraphicsTestFunctions {
model.setWidth(526); model.setWidth(526);
model.setHeight(346); model.setHeight(346);
LayerText compAlias = new LayerText(); LayerText layerText = createText();
compAlias.setX(256.0);
compAlias.setY(79.0);
compAlias.setWidth(233.0);
compAlias.setHeight(188.0);
compAlias.setNotes("asd as");
compAlias.setColor(Color.BLACK);
Layer layer = new Layer(); Layer layer = new Layer();
layer.addLayerText(compAlias); layer.addLayerText(layerText);
layer.setVisible(true); layer.setVisible(true);
model.addLayer(layer); model.addLayer(layer);
layer.addLayerLine(new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(100, 100))); layer.addLayerLine(new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(100, 100)));
Complex alias = new Complex("1"); model.addElement(createComplex());
alias.setName("a");
alias.setX(300);
alias.setY(90);
alias.setWidth(100);
alias.setHeight(50);
model.addElement(alias);
return model; return model;
} }
......
...@@ -83,8 +83,7 @@ public class BioEntityConverterImplTest extends GraphicsTestFunctions { ...@@ -83,8 +83,7 @@ public class BioEntityConverterImplTest extends GraphicsTestFunctions {
BioEntityConverterImpl converter = new BioEntityConverterImpl(alias, false, colorExtractor); BioEntityConverterImpl converter = new BioEntityConverterImpl(alias, false, colorExtractor);
converter.draw(alias, graphics, new ConverterParams()); converter.draw(alias, graphics, new ConverterParams());
verify(graphics, times(1)).drawImage(any(Image.class), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), verify(graphics, times(1)).drawImage(any(Image.class), anyInt(), anyInt(), nullable(ImageObserver.class));
anyInt(), anyInt(), nullable(ImageObserver.class));
} }
private Reaction createReaction(double lineWidth) { private Reaction createReaction(double lineWidth) {
......
...@@ -367,8 +367,7 @@ public class SpeciesConverterTest extends GraphicsTestFunctions { ...@@ -367,8 +367,7 @@ public class SpeciesConverterTest extends GraphicsTestFunctions {
alias.setGlyph(glyph); alias.setGlyph(glyph);
rc.draw(alias, graphics, new ConverterParams()); rc.draw(alias, graphics, new ConverterParams());
verify(graphics, times(1)).drawImage(any(Image.class), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), verify(graphics, times(1)).drawImage(any(Image.class), anyInt(), anyInt(), nullable(ImageObserver.class));
anyInt(), anyInt(), nullable(ImageObserver.class));
} }
protected GenericProtein createProtein() { protected GenericProtein createProtein() {
......
...@@ -18,6 +18,8 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; ...@@ -18,6 +18,8 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.converter.InvalidInputDataExecption; import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.converter.annotation.XmlAnnotationParser; import lcsb.mapviewer.converter.annotation.XmlAnnotationParser;
import lcsb.mapviewer.converter.model.sbml.species.ElementColorEnum; import lcsb.mapviewer.converter.model.sbml.species.ElementColorEnum;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.BioEntity; import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
...@@ -68,13 +70,13 @@ public class SbmlBioEntityParser { ...@@ -68,13 +70,13 @@ public class SbmlBioEntityParser {
this.layout = getSbmlLayout(sbmlModel); this.layout = getSbmlLayout(sbmlModel);
} }
protected Set<MiriamData> extractMiriamDataFromAnnotation(Annotation annotation) throws InvalidInputDataExecption { protected Set<MiriamData> extractMiriamDataFromAnnotation(Annotation annotation, LogMarker marker) throws InvalidInputDataExecption {
XmlAnnotationParser parser = new XmlAnnotationParser(); XmlAnnotationParser parser = new XmlAnnotationParser();
Set<MiriamData> result = new HashSet<>(); Set<MiriamData> result = new HashSet<>();
try { try {
Node rdfNode = getRdfNodeFromAnnotation(annotation); Node rdfNode = getRdfNodeFromAnnotation(annotation);
if (rdfNode != null) { if (rdfNode != null) {
result.addAll(parser.parseRdfNode(rdfNode)); result.addAll(parser.parseRdfNode(rdfNode, marker));
} }
} catch (InvalidXmlSchemaException e) { } catch (InvalidXmlSchemaException e) {
throw new InvalidInputDataExecption(e); throw new InvalidInputDataExecption(e);
...@@ -136,7 +138,7 @@ public class SbmlBioEntityParser { ...@@ -136,7 +138,7 @@ public class SbmlBioEntityParser {
protected void assignBioEntityData(AbstractNamedSBase sbmlElement, BioEntity result) protected void assignBioEntityData(AbstractNamedSBase sbmlElement, BioEntity result)
throws InvalidInputDataExecption { throws InvalidInputDataExecption {
result.addMiriamData(extractMiriamDataFromAnnotation(sbmlElement.getAnnotation())); result.addMiriamData(extractMiriamDataFromAnnotation(sbmlElement.getAnnotation(), new LogMarker(ProjectLogEntryType.PARSING_ISSUE, result)));
result.setName(sbmlElement.getName()); result.setName(sbmlElement.getName());
String notes = NotesUtility.extractNotes(sbmlElement); String notes = NotesUtility.extractNotes(sbmlElement);
result.setNotes(notes); result.setNotes(notes);
......
...@@ -4,12 +4,15 @@ import java.awt.Color; ...@@ -4,12 +4,15 @@ import java.awt.Color;
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 org.sbml.jsbml.AbstractNamedSBase;
import org.sbml.jsbml.Model; import org.sbml.jsbml.Model;
import org.sbml.jsbml.ext.SBasePlugin; import org.sbml.jsbml.ext.SBasePlugin;
import org.sbml.jsbml.ext.layout.*; import org.sbml.jsbml.ext.layout.*;
import org.sbml.jsbml.ext.render.*; import org.sbml.jsbml.ext.render.*;
import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.graphics.ArrowType; import lcsb.mapviewer.model.graphics.ArrowType;
public class SbmlModelUtils { public class SbmlModelUtils {
...@@ -247,4 +250,14 @@ public class SbmlModelUtils { ...@@ -247,4 +250,14 @@ public class SbmlModelUtils {
return result; 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());
}
}
} }
...@@ -72,7 +72,7 @@ public class SbmlParser extends Converter { ...@@ -72,7 +72,7 @@ public class SbmlParser extends Converter {
SbmlParameterParser parameterParser = new SbmlParameterParser(sbmlModel, model); SbmlParameterParser parameterParser = new SbmlParameterParser(sbmlModel, model);
SbmlFunctionParser functionParser = new SbmlFunctionParser(sbmlModel, model); SbmlFunctionParser functionParser = new SbmlFunctionParser(sbmlModel, model);
model.addMiriamData(compartmentParser.extractMiriamDataFromAnnotation(sbmlModel.getAnnotation())); model.addMiriamData(compartmentParser.extractMiriamDataFromAnnotation(sbmlModel.getAnnotation(), null));
model.addAuthors(compartmentParser.extractAuthorsFromAnnotation(sbmlModel.getAnnotation())); model.addAuthors(compartmentParser.extractAuthorsFromAnnotation(sbmlModel.getAnnotation()));
model.addModificationDates(compartmentParser.extractModificationDatesFromAnnotation(sbmlModel.getAnnotation())); model.addModificationDates(compartmentParser.extractModificationDatesFromAnnotation(sbmlModel.getAnnotation()));
model.setCreationDate(compartmentParser.extractCreationDateFromAnnotation(sbmlModel.getAnnotation())); model.setCreationDate(compartmentParser.extractCreationDateFromAnnotation(sbmlModel.getAnnotation()));
......
...@@ -5,7 +5,10 @@ import java.util.List; ...@@ -5,7 +5,10 @@ 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 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.modifier.*;
import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.Modifier;
...@@ -31,7 +34,8 @@ public enum SBOTermModifierType { ...@@ -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()) { if (sboTerm == null || sboTerm.isEmpty()) {
return Modifier.class; return Modifier.class;
} }
...@@ -43,8 +47,10 @@ public enum SBOTermModifierType { ...@@ -43,8 +47,10 @@ public enum SBOTermModifierType {
} }
} }
} }
if (result == null) { 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; result = Modifier.class;
} }
return result; return result;
......
...@@ -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,12 @@ public enum SBOTermReactionType { ...@@ -49,7 +51,12 @@ public enum SBOTermReactionType {
} }
} }
public static Class<? extends Reaction> getTypeSBOTerm(String sboTerm) { public static Class<? extends Reaction> getTypeSBOTerm(org.sbml.jsbml.Reaction reaction) {
if (reaction == null) {
return StateTransitionReaction.class;
}
String sboTerm = reaction.getSBOTermID();
if (sboTerm == null || sboTerm.isEmpty()) { if (sboTerm == null || sboTerm.isEmpty()) {