Commit a5d9331e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

import from sbml could be problematic when provided layout placed two elements...

import from sbml could be problematic when provided layout placed two elements in exactly the same position
parent 46870d8b
Pipeline #8912 passed with stage
in 16 minutes and 49 seconds
minerva (12.2.0~beta.2) unstable; urgency=medium
* Bug fix: import from sbml with layout could crash when two elements
occupied the exact same position (#717)
* Bug fix: overlays added via API couldn't be visualized after refresh (#718)
* Bug fix: Safari sometimes cached server responses and used wrong data, for
example in admin panel configuration tab (#719)
......
......@@ -19,7 +19,6 @@ import org.sbml.jsbml.ext.SBasePlugin;
import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.layout.LayoutModelPlugin;
import org.sbml.jsbml.ext.multi.MultiModelPlugin;
import org.sbml.jsbml.ext.render.LocalStyle;
import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.commands.layout.ApplySimpleLayoutModelCommand;
......@@ -157,7 +156,7 @@ public class SbmlParser implements IConverter {
if (element instanceof Complex && element != species) {
Complex complex = (Complex) element;
if (complex.getWidth() != 0 || complex.getHeight() != 0) {
if (complex.contains(species)) {
if (complex.contains(species) && complex.getSize() > species.getSize()) {
if (result == null) {
result = complex;
} else if (result.getSize() > complex.getSize()) {
......
......@@ -5,9 +5,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.awt.Color;
import java.io.FileNotFoundException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
......@@ -15,7 +16,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.commands.CreateHierarchyCommand;
import lcsb.mapviewer.common.EventStorageLoggerAppender;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.InvalidInputDataExecption;
......@@ -23,6 +24,7 @@ import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.ReactionNode;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Species;
......@@ -199,9 +201,32 @@ public class SbmlParserTest {
@Test
public void testParseConflictingTypesFromMulti() throws Exception {
Model model = parser.createModel(new ConverterParams().filename("testFiles/multi_features/conflicting_species_type.xml"));
Model model = parser
.createModel(new ConverterParams().filename("testFiles/multi_features/conflicting_species_type.xml"));
assertTrue(model.getElementByElementId("species_0") instanceof GenericProtein);
assertEquals(1, getWarnings().size());
}
@Test
public void testCyclicComplexes() throws Exception {
try {
Model model = parser.createModel(new ConverterParams().filename("testFiles/cyclic_complex.xml"));
new CreateHierarchyCommand(model, 8, 80).execute();
for (Species species : model.getSpeciesList()) {
Set<Element> parents = new HashSet<Element>();
while (species.getComplex() != null) {
assertFalse("Cyclic nesting", parents.contains(species.getComplex()));
species= species.getComplex();
parents.add(species);
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment