Skip to content
Snippets Groups Projects
Commit b3c504ac authored by Piotr Gawron's avatar Piotr Gawron
Browse files

notes are extracted properly

parent 660e66bd
No related branches found
No related tags found
1 merge request!186Resolve "upload of sbml"
......@@ -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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment