diff --git a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionParser.java b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionParser.java index 3a633ce4f7101f43ca7c18838751294dcaa62b39..88c9883007cfed756f09af0d53006e14491c97c0 100644 --- a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionParser.java +++ b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlReactionParser.java @@ -72,26 +72,27 @@ public class SbmlReactionParser { return sbmlModel.getListOfReactions(); } - protected void mergeLayout(Collection<Reaction> elements, Layout sbmlLayout, Model sbmlModel) + protected void mergeLayout(Collection<Reaction> reactions, Layout sbmlLayout, Model sbmlModel) throws InvalidInputDataExecption { Set<Reaction> used = new HashSet<>(); - Map<String, Reaction> elementById = new HashMap<>(); - for (Reaction species : elements) { - if (elementById.get(species.getIdReaction()) != null) { - throw new InvalidInputDataExecption("Duplicated reaction id: " + species.getIdReaction()); + Map<String, Reaction> reactionById = new HashMap<>(); + for (Reaction reaction : reactions) { + if (reactionById.get(reaction.getIdReaction()) != null) { + throw new InvalidInputDataExecption("Duplicated reaction id: " + reaction.getIdReaction()); } - elementById.put(species.getIdReaction(), species); + reactionById.put(reaction.getIdReaction(), reaction); } for (ReactionGlyph glyph : sbmlLayout.getListOfReactionGlyphs()) { - Reaction source = elementById.get(glyph.getReaction()); + Reaction source = reactionById.get(glyph.getReaction()); if (source == null) { throw new InvalidInputDataExecption("Layout contains invalid Species id: " + glyph.getReaction()); } used.add(source); try { Reaction reactionWithLayout = source.copy(); - reactionWithLayout.setIdReaction(glyph.getId()); + // getId doesn't have to be unique, therefore we concatenate with reaction + reactionWithLayout.setIdReaction(glyph.getId() + "_" + glyph.getReaction()); for (SpeciesReferenceGlyph speciesRefernceGlyph : glyph.getListOfSpeciesReferenceGlyphs()) { SpeciesGlyph speciesGlyph = layout.getSpeciesGlyph(speciesRefernceGlyph.getSpeciesGlyph()); ReactionNode minervaNode = null; @@ -206,16 +207,15 @@ public class SbmlReactionParser { operator.setLine(line); reactionWithLayout.addNode(operator); } - minervaModel.addReaction(new StateTransitionReaction(reactionWithLayout)); } catch (InvalidArgumentException e) { throw new InvalidInputDataExecption(e); } } Set<Reaction> elementsToRemove = new HashSet<>(); - for (Reaction reaction : elements) { + for (Reaction reaction : reactions) { if (!used.contains(reaction)) { - logger.warn("Layout doesn't contain information about Element: " + reaction.getIdReaction()); + logger.warn("Layout doesn't contain information about Reaction: " + reaction.getIdReaction()); } else { elementsToRemove.add(reaction); }