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

unit test to check import export of structural state

parent d99ec5db
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"
......@@ -13,12 +13,15 @@ import java.io.File;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.reflections.Reflections;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.ext.multi.MultiModelPlugin;
import org.sbml.jsbml.ext.multi.MultiSpeciesType;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.converter.ConverterParams;
......@@ -37,9 +40,13 @@ import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.ReactionNode;
import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.IonChannelProtein;
import lcsb.mapviewer.model.map.species.ReceptorProtein;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.TruncatedProtein;
public class SbmlExporterTest {
Logger logger = Logger.getLogger(SbmlExporterTest.class);
......@@ -419,4 +426,59 @@ public class SbmlExporterTest {
assertTrue("Species types are not exported", multiPlugin.getListOfSpeciesTypes().size() > 0);
}
@Test
public void testMultiExtensionTypeWithStructuralState() throws Exception {
SbmlExporter exporter = new SbmlExporter();
SBMLDocument doc = new SBMLDocument(3, 2);
org.sbml.jsbml.Model result = doc.createModel("id");
MultiModelPlugin multiPlugin = exporter.createSbmlMultiPlugin(result);
Set<Class<?>> typesWithStructuralStates = new HashSet<>();
typesWithStructuralStates.addAll(Arrays.asList(new Class<?>[] { GenericProtein.class, TruncatedProtein.class,
Complex.class, IonChannelProtein.class, ReceptorProtein.class }));
for (Class<?> clazz : typesWithStructuralStates) {
MultiSpeciesType speciesType = multiPlugin
.getSpeciesType("minerva_species_type_" + clazz.getSimpleName());
assertTrue(clazz.getSimpleName() + " doesn't have any features, but at least structuralState expected",
speciesType.getListOfSpeciesFeatureTypes().size() > 0);
}
}
@Test
public void testMultiExtensionSBOTermsForTypes() throws Exception {
SbmlExporter exporter = new SbmlExporter();
SBMLDocument doc = new SBMLDocument(3, 2);
org.sbml.jsbml.Model result = doc.createModel("id");
MultiModelPlugin multiPlugin = exporter.createSbmlMultiPlugin(result);
for (MultiSpeciesType speciesType : multiPlugin.getListOfSpeciesTypes()) {
assertNotNull("SBO term not defined for type " + speciesType.getName(), speciesType.getSBOTermID());
assertFalse("SBO term not defined for type " + speciesType.getName(), speciesType.getSBOTermID().isEmpty());
}
}
@Test
public void testExportProteinState() throws Exception {
Model model = new ModelFullIndexed(null);
model.setIdModel("Test123");
model.setName("x");
model.setWidth("300");
model.setHeight("300");
GenericProtein element = new GenericProtein("id");
element.setName("test name");
element.setX(10);
element.setWidth(10);
element.setY(10);
element.setHeight(10);
element.setStructuralState("xxx");
model.addElement(element);
Model deserializedModel = getModelAfterSerializing(model);
assertEquals("Structural state not exported/imported properly", 0, comparator.compare(model, deserializedModel));
}
}
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