diff --git a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlBioEntityParser.java b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlBioEntityParser.java index 5f3ab3087ea63cc3b3db77b21cbc7ab6eb01f27f..c4fcd05ea7d615e8079dd0bc2dd75a75134380b4 100644 --- a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlBioEntityParser.java +++ b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlBioEntityParser.java @@ -5,6 +5,7 @@ import java.util.Set; import javax.xml.stream.XMLStreamException; +import org.apache.log4j.Logger; import org.sbml.jsbml.AbstractNamedSBase; import org.sbml.jsbml.Annotation; import org.sbml.jsbml.ext.layout.Layout; @@ -15,6 +16,7 @@ import lcsb.mapviewer.model.map.BioEntity; import lcsb.mapviewer.model.map.MiriamData; public class SbmlBioEntityParser { + Logger logger = Logger.getLogger(SbmlBioEntityParser.class); protected Layout layout; protected lcsb.mapviewer.model.map.model.Model minervaModel; @@ -31,17 +33,36 @@ public class SbmlBioEntityParser { return result; } - protected void assignBioEntityData(AbstractNamedSBase sbmlElement, BioEntity result) throws InvalidInputDataExecption { + protected void assignBioEntityData(AbstractNamedSBase sbmlElement, BioEntity result) + throws InvalidInputDataExecption { result.addMiriamData(parseAnnotation(sbmlElement.getAnnotation())); result.setName(sbmlElement.getName()); if (result.getName() == null || result.getName().isEmpty()) { result.setName(result.getElementId()); } + String notes = extractNotes(sbmlElement); + result.setNotes(notes); + } + + private String extractNotes(AbstractNamedSBase sbmlElement) throws InvalidInputDataExecption { + String notes = ""; try { - result.setNotes(sbmlElement.getNotesString()); + notes = sbmlElement.getNotesString(); } catch (XMLStreamException e) { throw new InvalidInputDataExecption(sbmlElement.getId() + " Invalid notes", e); } + if (sbmlElement.getNotes() != null) { + if (sbmlElement.getNotes().getChildCount() > 1) { + if (sbmlElement.getNotes().getChild(1).getChildCount() > 1) { + if (sbmlElement.getNotes().getChild(1).getChild(1).getChildCount() > 0) { + notes = sbmlElement.getNotes().getChild(1).getChild(1).getChild(0).getCharacters(); + } else { + notes = sbmlElement.getNotes().getChild(1).getChild(1).getCharacters(); + } + } + } + } + return notes; } } \ No newline at end of file diff --git a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionExporter.java b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionExporter.java index b568632df9c21053602755fa89d51f180243ca88..55b4d7cac4ea7cbde88ea609e9115a4d85226220 100644 --- a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionExporter.java +++ b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionExporter.java @@ -5,8 +5,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import javax.xml.stream.XMLStreamException; - import org.apache.log4j.Logger; import org.sbml.jsbml.SimpleSpeciesReference; import org.sbml.jsbml.Species; @@ -20,7 +18,6 @@ import org.sbml.jsbml.ext.layout.ReactionGlyph; import org.sbml.jsbml.ext.layout.SpeciesReferenceGlyph; import org.sbml.jsbml.ext.layout.SpeciesReferenceRole; -import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.map.InconsistentModelException; import lcsb.mapviewer.model.map.modifier.Inhibition; import lcsb.mapviewer.model.map.reaction.Modifier; @@ -43,28 +40,23 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb @Override public org.sbml.jsbml.Reaction createSbmlElement(Reaction reaction) throws InconsistentModelException { - try { - org.sbml.jsbml.Reaction result = sbmlModel.createReaction("reaction_" + (getNextId())); - result.setNotes(reaction.getNotes()); - for (Product product : reaction.getProducts()) { - Species sbmlSymbol = speciesExporter.sbmlElementByElementId.get(product.getElement().getElementId()); - SpeciesReference speciesReference = result.createProduct(sbmlSymbol); - speciesReferenceByReactionNode.put(product, speciesReference); - } - for (Reactant reactant : reaction.getReactants()) { - Species sbmlSymbol = speciesExporter.sbmlElementByElementId.get(reactant.getElement().getElementId()); - SpeciesReference speciesReference = result.createReactant(sbmlSymbol); - speciesReferenceByReactionNode.put(reactant, speciesReference); - } - for (Modifier modifier : reaction.getModifiers()) { - Species sbmlSymbol = speciesExporter.sbmlElementByElementId.get(modifier.getElement().getElementId()); - SimpleSpeciesReference speciesReference = result.createModifier(sbmlSymbol); - speciesReferenceByReactionNode.put(modifier, speciesReference); - } - return result; - } catch (XMLStreamException e) { - throw new InvalidStateException(e); + org.sbml.jsbml.Reaction result = sbmlModel.createReaction("reaction_" + (getNextId())); + for (Product product : reaction.getProducts()) { + Species sbmlSymbol = speciesExporter.sbmlElementByElementId.get(product.getElement().getElementId()); + SpeciesReference speciesReference = result.createProduct(sbmlSymbol); + speciesReferenceByReactionNode.put(product, speciesReference); + } + for (Reactant reactant : reaction.getReactants()) { + Species sbmlSymbol = speciesExporter.sbmlElementByElementId.get(reactant.getElement().getElementId()); + SpeciesReference speciesReference = result.createReactant(sbmlSymbol); + speciesReferenceByReactionNode.put(reactant, speciesReference); + } + for (Modifier modifier : reaction.getModifiers()) { + Species sbmlSymbol = speciesExporter.sbmlElementByElementId.get(modifier.getElement().getElementId()); + SimpleSpeciesReference speciesReference = result.createModifier(sbmlSymbol); + speciesReferenceByReactionNode.put(modifier, speciesReference); } + return result; } @Override