Gitlab is now using https://gitlab.lcsb.uni.lu as it's primary address. Please update your bookmarks. FAQ.

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

Merge branch '1515-separate-backgrounds-and-overlays-in-admin-panel' into 'master'

Resolve "separate backgrounds and overlays in admin panel"

Closes #1515

See merge request !1311
parents 697151dd edbccb7a
Pipeline #43179 failed with stage
in 18 minutes and 59 seconds
minerva (16.0.0~beta.1) stable; urgency=medium
* Backward incompatibility: layout parameter in minerva url is not supported
anymore
* Small improvement: info about background and dat aoverlays is separated in
edit project panel (#1515)
* Bug fix: there was issue with updating data overlay in admin panel "Unknown
parameter: defaultOverlay"
* Bug fix: data overlays uploaded in complex map were not processed properly
(#1485)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 9 Jun 2021 15:00:00 +0200
minerva (16.0.0~beta.0) stable; urgency=medium
* Backward incompatibility: debian package cannot be upgraded from version
prior to 12.1.0 (#1464)
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>CellDesigner-plugin</artifactId>
<!-- dependency from the MapViewer model -->
......@@ -50,19 +50,19 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>commons</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-CellDesigner</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>annotation</artifactId>
<name>Annotation module</name>
......@@ -18,7 +18,7 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<!-- dependency from the MapViewer dao -->
......@@ -26,7 +26,7 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<!-- dependency from the MapViewer cell designer parser (we need access
......@@ -34,13 +34,13 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-CellDesigner</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<!-- Log4J2 -->
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>commons</artifactId>
<name>Mapviewer commons</name>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>converter-CellDesigner</artifactId>
<name>CellDesigner converter</name>
......@@ -17,13 +17,13 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<!-- Log4J2 -->
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>converter-SBGNML</artifactId>
......@@ -20,26 +20,26 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-CellDesigner</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-graphics</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>converter-graphics</artifactId>
<name>MapViewer graphics converter</name>
......@@ -18,13 +18,13 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model-command</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<!-- Log4J2-->
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>converter-sbml</artifactId>
<name>converter-sbml</name>
......@@ -40,22 +40,22 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model-command</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-CellDesigner</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<!-- Log4J2 -->
......@@ -154,7 +154,7 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>converter-graphics</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
<scope>test</scope>
</dependency>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</parent>
<artifactId>converter</artifactId>
......@@ -15,7 +15,7 @@
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId>
<version>16.0.0~beta.0</version>
<version>16.0.0~beta.1</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
......
package lcsb.mapviewer.services.utils.data;
package lcsb.mapviewer.converter;
import java.util.HashSet;
import java.util.Set;
......
package lcsb.mapviewer.services.utils;
package lcsb.mapviewer.converter;
import java.awt.Color;
import java.io.*;
import java.lang.reflect.Field;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.annotation.services.MiriamConnector;
import lcsb.mapviewer.common.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.common.geometry.ColorParser;
import lcsb.mapviewer.converter.model.celldesigner.species.SpeciesMapping;
import lcsb.mapviewer.converter.zip.ZipEntryFileFactory;
import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.layout.ReferenceGenomeType;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.overlay.*;
import lcsb.mapviewer.services.utils.data.ColorSchemaColumn;
/**
* Class that reads information about set of {@link DataOverlayEntry color
......@@ -46,6 +43,22 @@ public class ColorSchemaReader {
*/
private static final int MIN_GV_RED_VALUE = 128;
private static Map<String, Class<? extends BioEntity>> speciesMapping;
static {
speciesMapping = new HashMap<>();
speciesMapping.put("protein", Protein.class);
speciesMapping.put("gene", Gene.class);
speciesMapping.put("complex", Complex.class);
speciesMapping.put("simple_molecule", SimpleMolecule.class);
speciesMapping.put("ion", Ion.class);
speciesMapping.put("phenotype", Phenotype.class);
speciesMapping.put("drug", Drug.class);
speciesMapping.put("rna", Rna.class);
speciesMapping.put("antisense_rna", AntisenseRna.class);
speciesMapping.put("unknown", Unknown.class);
speciesMapping.put("degraded", Degraded.class);
}
/**
* Object that parses colors from string.
*/
......@@ -56,11 +69,6 @@ public class ColorSchemaReader {
*/
private Logger logger = LogManager.getLogger();
/**
* Objects that manipulates {@link MiriamData}.
*/
private MiriamConnector mc = new MiriamConnector();
/**
* Reads information about set of {@link DataOverlayEntry color schemas} from
* the input stream.
......@@ -196,9 +204,9 @@ public class ColorSchemaReader {
if (typeColumn != null) {
String[] types = values[typeColumn].split(",");
for (String string : types) {
SpeciesMapping mapping = SpeciesMapping.getMappingByString(string);
if (mapping != null) {
schema.addType(mapping.getModelClazz());
Class<? extends BioEntity> clazz = speciesMapping.get(string.toLowerCase());
if (clazz != null) {
schema.addType(clazz);
} else {
throw new InvalidDataOverlayException("[Line " + lineIndex + "] Unknown class type: " + string + ".");
}
......@@ -274,10 +282,10 @@ public class ColorSchemaReader {
private void processGeneralIdentifier(String string, DataOverlayEntry schema, String errorPrefix)
throws InvalidDataOverlayException {
if (mc.isValidIdentifier(string)) {
try {
schema.addMiriamData(MiriamType.getMiriamDataFromIdentifier(string));
} else {
throw new InvalidDataOverlayException(errorPrefix + " Invalid identifier: " + string);
} catch (InvalidArgumentException e) {
throw new InvalidDataOverlayException(errorPrefix + " Invalid identifier: " + string, e);
}
}
......@@ -564,16 +572,13 @@ public class ColorSchemaReader {
String[] types = typesString.split(",");
for (String string : types) {
if (!string.isEmpty()) {
SpeciesMapping mapping = SpeciesMapping.getMappingByString(string);
if (mapping != null) {
result.add(mapping.getModelClazz());
Class<? extends BioEntity> clazz = speciesMapping.get(string.toLowerCase());
if (clazz != null) {
result.add(clazz);
} else {
String validStrings = "";
for (SpeciesMapping speciesMapping : SpeciesMapping.values()) {
validStrings += speciesMapping.getCellDesignerString() + ", ";
}
throw new InvalidDataOverlayException(
errorPrefix + "Unknown class type: " + string + ". Valid values are: " + validStrings);
errorPrefix + "Unknown class type: " + string + ". Valid values are: "
+ StringUtils.join(speciesMapping.values(), ","));
}
}
}
......
......@@ -21,8 +21,7 @@ import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.overlay.DataOverlayType;
import lcsb.mapviewer.model.overlay.DataOverlay;
import lcsb.mapviewer.model.overlay.*;
/**
* This class allows to create complex {@link Model} that contains submaps. It's
......@@ -304,9 +303,10 @@ public class ComplexZipConverter {
* @return {@link DataOverlay} for a given {@link LayoutZipEntryFile}
* @throws IOException
* thrown when there is a problem with accessing {@link ZipFile}
* @throws InvalidInputDataExecption
*/
public DataOverlay layoutZipEntryFileToLayout(ComplexZipConverterParams params, ZipFile zipFile, ZipEntry entry,
LayoutZipEntryFile layoutEntry, int order) throws IOException {
LayoutZipEntryFile layoutEntry, int order) throws IOException, InvalidInputDataExecption {
DataOverlay layout = new DataOverlay();
layout.setDescription(layoutEntry.getDescription());
UploadedFileEntry fileEntry = new UploadedFileEntry();
......@@ -329,6 +329,14 @@ public class ComplexZipConverter {
layout.setPublic(true);
layout.setName(layoutEntry.getName());
layout.setOrderIndex(order);
ColorSchemaReader reader = new ColorSchemaReader();
ByteArrayInputStream baos = new ByteArrayInputStream(fileEntry.getFileContent());
try {
layout.addEntries(reader.readColorSchema(baos, parameters));
} catch (InvalidDataOverlayException e) {
throw new InvalidInputDataExecption(e);
}
return layout;
}
......
......@@ -7,7 +7,9 @@ import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.converter.annotation.XmlAnnotationParserTest;
@RunWith(Suite.class)
@SuiteClasses({ ComplexZipConverterParamsTest.class,
@SuiteClasses({
ColorSchemaReaderTest.class,
ComplexZipConverterParamsTest.class,
ComplexZipConverterTest.class,
OverviewParserTest.class,
ProjectFactoryTest.class,
......
package lcsb.mapviewer.services.utils;
package lcsb.mapviewer.converter;
import static org.junit.Assert.*;
......@@ -12,16 +12,13 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.commands.ColorModelCommand;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.TextFileUtils;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.overlay.*;
import lcsb.mapviewer.services.ServiceTestFunctions;
public class ColorSchemaReaderTest extends ServiceTestFunctions {
public class ColorSchemaReaderTest extends ConverterTestFunctions {
Logger logger = LogManager.getLogger();
ColorSchemaReader reader;
......@@ -37,17 +34,17 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
@Test
public void testReadSchema() throws Exception {
Collection<DataOverlayEntry> schemas = reader.readColorSchema("testFiles/enricoData/ageing.txt");
Collection<DataOverlayEntry> schemas = reader.readColorSchema("testFiles/coloring/ageing.txt");
assertNotNull(schemas);
assertEquals(412, schemas.size());
schemas = reader.readColorSchema("testFiles/enricoData/ge001.txt");
schemas = reader.readColorSchema("testFiles/coloring/ge001.txt");
assertNotNull(schemas);
assertEquals(3057, schemas.size());
schemas = reader.readColorSchema("testFiles/enricoData/ge005.txt");
schemas = reader.readColorSchema("testFiles/coloring/ge005.txt");
assertNotNull(schemas);
assertEquals(4338, schemas.size());
......@@ -174,7 +171,7 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
assertEquals(1, collection.size());
DataOverlayEntry schema = collection.iterator().next();
assertEquals("re1", schema.getElementId());
assertEquals(3.0, schema.getLineWidth(), EPSILON);
assertEquals(3.0, schema.getLineWidth(), Configuration.EPSILON);
assertEquals(Color.RED, schema.getColor());
}
......@@ -186,19 +183,6 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
assertEquals(3, schemas.size());
}
@Test
public void testColoring3() throws Exception {
ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE, Color.WHITE);
Model model = getModelForFile("testFiles/coloring/protein_to_color.xml", false);
Collection<DataOverlayEntry> schemas = reader.readColorSchema("testFiles/coloring/problematicSchema.txt");
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
factory.execute();
assertFalse(model.getElementByElementId("sa1").getFillColor().equals(Color.WHITE));
}
@Test
public void testColoringWithValueOrColor() throws Exception {
Map<String, String> params = new HashMap<>();
......
......@@ -284,17 +284,18 @@ public class ComplexZipConverterTest extends ConverterTestFunctions {
public void testLayoutZipEntryFileToLayoutOrder() throws Exception {
ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class);
ComplexZipConverterParams params = new ComplexZipConverterParams();
ZipFile file = Mockito.mock(ZipFile.class);
params.zipFile(file);
ZipFile file1 = Mockito.mock(ZipFile.class);
ZipFile file2 = Mockito.mock(ZipFile.class);
LayoutZipEntryFile entry1 = new LayoutZipEntryFile("overlay1.txt", "name", "desc1");
LayoutZipEntryFile entry2 = new LayoutZipEntryFile("overlay2.txt", "name", "desc1");
params.entry(entry1);
params.entry(entry2);
ZipEntry entry = Mockito.mock(ZipEntry.class);
Mockito.when(file.getInputStream(entry)).thenReturn(new ByteArrayInputStream("".getBytes()));
Mockito.when(file1.getInputStream(entry)).thenReturn(new ByteArrayInputStream("name\tvalue\n".getBytes()));
Mockito.when(file2.getInputStream(entry)).thenReturn(new ByteArrayInputStream("name\tvalue\n".getBytes()));
DataOverlay overlay1 = converter.layoutZipEntryFileToLayout(params, file, entry, entry1, 1);
DataOverlay overlay2 = converter.layoutZipEntryFileToLayout(params, file, entry, entry2, 2);
DataOverlay overlay1 = converter.layoutZipEntryFileToLayout(params, file1, entry, entry1, 1);
DataOverlay overlay2 = converter.layoutZipEntryFileToLayout(params, file2, entry, entry2, 2);
assertTrue(overlay1.getOrderIndex() > 0);
assertTrue(overlay2.getOrderIndex() > overlay1.getOrderIndex());
}
......
......@@ -18,8 +18,10 @@ import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
import lcsb.mapviewer.model.map.layout.graphics.LayerText;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.overlay.DataOverlay;
public class ProjectFactoryTest extends ConverterTestFunctions {
Logger logger = LogManager.getLogger();
......@@ -221,4 +223,28 @@ public class ProjectFactoryTest extends ConverterTestFunctions {
return result;
}
@Test
public void testWithOverlay() throws Exception {
ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class);
ProjectFactory projectFactory = new ProjectFactory(converter);
ZipFile zipFile = new ZipFile("testFiles/complex_model_with_layouts.zip");
ComplexZipConverterParams params = new ComplexZipConverterParams();
params.zipFile(zipFile);
ZipEntryFileFactory factory = new ZipEntryFileFactory();
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
params.entry(factory.createZipEntryFile(entry, zipFile));
}
}
Project project = projectFactory.create(params);
assertNotNull(project);
assertEquals(1, project.getDataOverlays().size());
DataOverlay overlay = project.getDataOverlays().get(0);
assertTrue(overlay.getEntries().size() > 0);
}
}
#TYPE=GENETIC_VARIANT
#GENOME_TYPE=UCSC
#GENOME_VERSION=hg38
position original_dna alternative_dna gene_name description color contig