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

export with MULTI property separates species wth different structural state

parent 79cbd71a
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!560Resolve "add support for modifications and states in sbml export/import"
...@@ -189,7 +189,6 @@ public class SbmlExporter { ...@@ -189,7 +189,6 @@ public class SbmlExporter {
private Map<Class<?>, MultiSpeciesType> speciesTypeByClass = new HashMap<>(); private Map<Class<?>, MultiSpeciesType> speciesTypeByClass = new HashMap<>();
@SuppressWarnings("unchecked")
protected MultiModelPlugin createSbmlMultiPlugin(Model result) { protected MultiModelPlugin createSbmlMultiPlugin(Model result) {
MultiModelPlugin multiPlugin = new MultiModelPlugin(result); MultiModelPlugin multiPlugin = new MultiModelPlugin(result);
result.addExtension("multi", multiPlugin); result.addExtension("multi", multiPlugin);
......
...@@ -159,7 +159,20 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j ...@@ -159,7 +159,20 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
if (element.getComplex() != null) { if (element.getComplex() != null) {
complexName = element.getComplex().getName(); complexName = element.getComplex().getName();
} }
return element.getClass().getSimpleName() + "\n" + element.getName() + "\n" + compartmentName + "\n" + complexName; String multiDistinguisher = null;
if (isExtensionEnabled(SbmlExtension.MULTI)) {
String structuralState = null;
if (element instanceof Protein) {
structuralState = ((Protein) element).getStructuralState();
} else if (element instanceof Complex) {
structuralState = ((Complex) element).getStructuralState();
}
multiDistinguisher = structuralState;
}
String result =element.getClass().getSimpleName() + "\n" + element.getName() + "\n" + compartmentName + "\n" + complexName
+ "\n" + multiDistinguisher;
return result;
} }
protected LocalStyle createStyle(Species element) { protected LocalStyle createStyle(Species element) {
......
package lcsb.mapviewer.converter.model.sbml.species; package lcsb.mapviewer.converter.model.sbml.species;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.Test; import org.junit.Test;
import org.sbml.jsbml.SBMLDocument; import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.ext.layout.Layout;
import lcsb.mapviewer.converter.model.sbml.SbmlExporter; import lcsb.mapviewer.converter.model.sbml.SbmlExporter;
import lcsb.mapviewer.converter.model.sbml.SbmlExtension; import lcsb.mapviewer.converter.model.sbml.SbmlExtension;
...@@ -18,15 +19,14 @@ import lcsb.mapviewer.model.map.model.Model; ...@@ -18,15 +19,14 @@ 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.Element; import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.map.species.Species;
public class SbmlSpeciesExporterTest { public class SbmlSpeciesExporterTest {
Logger logger = Logger.getLogger(SbmlSpeciesExporterTest.class); Logger logger = Logger.getLogger(SbmlSpeciesExporterTest.class);
SbmlCompartmentExporter compartmentExporter;
org.sbml.jsbml.Model sbmlModel; org.sbml.jsbml.Model sbmlModel;
Layout sbmlLayout;
@Test @Test
public void testOneElementWithTwoAliases() throws InconsistentModelException { public void testOneElementWithTwoAliases() throws InconsistentModelException {
...@@ -68,19 +68,39 @@ public class SbmlSpeciesExporterTest { ...@@ -68,19 +68,39 @@ public class SbmlSpeciesExporterTest {
} }
private SbmlSpeciesExporter createExporter(Model model) throws InconsistentModelException { private SbmlSpeciesExporter createExporter(Model model) throws InconsistentModelException {
return createExporter(model, Arrays.asList(new SbmlExtension[] { SbmlExtension.RENDER, SbmlExtension.LAYOUT }));
}
private SbmlSpeciesExporter createExporter(Model model, Collection<SbmlExtension> sbmlExtensions)
throws InconsistentModelException {
SBMLDocument doc = new SBMLDocument(3, 1); SBMLDocument doc = new SBMLDocument(3, 1);
sbmlModel = doc.createModel(model.getIdModel()); sbmlModel = doc.createModel(model.getIdModel());
SbmlExporter sbmlExporter = new SbmlExporter(); SbmlExporter sbmlExporter = new SbmlExporter();
sbmlLayout = sbmlExporter.createSbmlLayout(model, sbmlModel); sbmlExporter.createSbmlLayout(model, sbmlModel);
SbmlCompartmentExporter compartmentExporter = new SbmlCompartmentExporter(sbmlModel, model, SbmlCompartmentExporter compartmentExporter = new SbmlCompartmentExporter(sbmlModel, model,
Arrays.asList(SbmlExtension.values())); Arrays.asList(SbmlExtension.values()));
compartmentExporter.exportElements(); compartmentExporter.exportElements();
SbmlSpeciesExporter result = new SbmlSpeciesExporter(sbmlModel, model,
Arrays.asList(new SbmlExtension[] { SbmlExtension.RENDER, SbmlExtension.LAYOUT }), SbmlSpeciesExporter result = new SbmlSpeciesExporter(sbmlModel, model, sbmlExtensions, compartmentExporter);
compartmentExporter);
return result; return result;
} }
@Test
public void testIdsOfSpeciesWithStructuralStates() throws InconsistentModelException {
Species protein1 = new GenericProtein("sa1");
protein1.setName("SNCA");
Protein protein2 = new GenericProtein("sa2");
protein2.setName("SNCA");
protein2.setStructuralState("X");
Model model = new ModelFullIndexed(null);
model.addElement(protein1);
model.addElement(protein2);
SbmlSpeciesExporter exporter = createExporter(model, Arrays.asList(SbmlExtension.values()));
assertFalse(exporter.getSbmlIdKey(protein1).equals(exporter.getSbmlIdKey(protein2)));
}
} }
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