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

Merge branch 'bugs' into 'master'

Bug fixes

Issues solved:
#50, #31, #41, #46,  #38, #43, #48

See merge request !2
parents ba6e311f e5c8f78f
...@@ -6,3 +6,4 @@ map_images/ ...@@ -6,3 +6,4 @@ map_images/
*/target/ */target/
web/src/main/webapp/svnversion.txt web/src/main/webapp/svnversion.txt
*.war *.war
/target/
minerva (10.0.3) stable; urgency=medium
* Bug fix: login cannot contain whitespace
* Bug fix: search for multiple drugs will not return more drugs than
queried for
* Bug fix: drug list for some proteins (like RHOA) hung webpage
* Bug fix: comments on submaps issue
* Bug fix: link to submap from comment panel
* Overlay coloring can be defined in Configuration
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 10 Oct 2016 10:01:16 +0200
minerva (10.0.2) stable; urgency=medium minerva (10.0.2) stable; urgency=medium
* Bug fix: markers for mirna targets visibility * Bug fix: markers for mirna targets visibility
......
...@@ -68,7 +68,12 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { ...@@ -68,7 +68,12 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService {
/** /**
* Url that list of all child nodes for chembl ontology term. * Url that list of all child nodes for chembl ontology term.
*/ */
private static final String PARENT_CHILD_API_URL = "https://www.ebi.ac.uk/chembl/api/data/molecule_form?parent="; private static final String PARENT_CHILD_API_URL = "https://www.ebi.ac.uk/chembl/api/data/molecule_form/";
/**
* Suffix that should be added to {@link #PARENT_CHILD_API_URL}.
*/
private static final String PARENT_CHILD_API_URL_SUFFIX = ".xml";
/** /**
* Url used for finding targets containing uniprot identifiers. Important - * Url used for finding targets containing uniprot identifiers. Important -
...@@ -420,7 +425,7 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService { ...@@ -420,7 +425,7 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService {
List<Target> targets = new ArrayList<>(); List<Target> targets = new ArrayList<>();
try { try {
String id = drugId.getResource(); String id = drugId.getResource();
String query = PARENT_CHILD_API_URL + id; String query = PARENT_CHILD_API_URL + id + PARENT_CHILD_API_URL_SUFFIX;
String page = getWebPageContent(query); String page = getWebPageContent(query);
Document document = super.getXmlDocumentFromString(page); Document document = super.getXmlDocumentFromString(page);
......
...@@ -54,7 +54,7 @@ public class PubmedParser extends CachableInterface implements IExternalService ...@@ -54,7 +54,7 @@ public class PubmedParser extends CachableInterface implements IExternalService
/** /**
* Version of the remote API thnat is supported by this connecting class. * Version of the remote API thnat is supported by this connecting class.
*/ */
static final String SUPPORTED_VERSION = "4.5.2"; static final String SUPPORTED_VERSION = "4.5.3";
/** /**
* Connector used for accessing data from miriam registry. * Connector used for accessing data from miriam registry.
......
...@@ -18,7 +18,6 @@ import java.util.Set; ...@@ -18,7 +18,6 @@ import java.util.Set;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -64,7 +63,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions { ...@@ -64,7 +63,7 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
@Test @Test
public void test1FindDrug() throws Exception { public void test1FindDrug() throws Exception {
try { try {
//do it with cache turned on // do it with cache turned on
chemblParser.setCache(cache); chemblParser.setCache(cache);
Drug drug = chemblParser.findDrug("CABOZANTINIB"); Drug drug = chemblParser.findDrug("CABOZANTINIB");
...@@ -213,11 +212,11 @@ public class ChEMBLParserTest extends AnnotationTestFunctions { ...@@ -213,11 +212,11 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
@Test @Test
public void test9FindDrug() throws Exception { public void test9FindDrug() throws Exception {
try { try {
String n = "PONATINIB"; String name = "PONATINIB";
Drug test = chemblParser.findDrug(n); Drug test = chemblParser.findDrug(name);
assertEquals("CHEMBL1171837", test.getSources().get(0).getResource()); assertEquals("CHEMBL1171837", test.getSources().get(0).getResource());
assertEquals("PONATINIB", test.getName()); assertEquals(name, test.getName());
assertNull(test.getDescription()); assertNull(test.getDescription());
assertEquals(3, test.getTargets().size()); assertEquals(3, test.getTargets().size());
} catch (Exception e) { } catch (Exception e) {
...@@ -228,7 +227,6 @@ public class ChEMBLParserTest extends AnnotationTestFunctions { ...@@ -228,7 +227,6 @@ public class ChEMBLParserTest extends AnnotationTestFunctions {
} }
@Test @Test
@Ignore("Bug 452")
public void test10FindDrug() throws Exception { public void test10FindDrug() throws Exception {
try { try {
String n = "DEXAMETHASONE"; String n = "DEXAMETHASONE";
......
package lcsb.mapviewer.common.geometry;
import java.awt.Color;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
/**
* Parser clas to extract {@link Color} objects from {@link String}.
*
* @author Piotr Gawron
*
*/
public class ColorParser {
/**
* Base of the hex representation.
*/
private static final int HEX_BASE = 16;
/**
* Length of the string describing color in rgb: "#RRGGBB".
*/
private static final int COLOR_STRING_LENGTH = 7;
/**
* Where starts description of red color in stirng representing color.
*/
private static final int COLOR_SUBSTRING_START_RED = 1;
/**
* Where starts description of green color in stirng representing color.
*/
private static final int COLOR_SUBSTRING_START_GREEN = 3;
/**
* Where starts description of blue color in stirng representing color.
*/
private static final int COLOR_SUBSTRING_START_BLUE = 5;
/**
* Extracts {@link Color} from input {@link String}.
*
* @param string
* text to process
* @return {@link Color} obtained from input text
*/
public Color parse(String string) {
if (string.charAt(0) != '#') {
string = "#" + string;
}
if (string.length() != COLOR_STRING_LENGTH) {
throw new InvalidArgumentException("Invalid color value: " + string + ". Correct format: #xxxxxx (where x is a hex value)");
} else {
return new Color(Integer.valueOf(string.substring(COLOR_SUBSTRING_START_RED, COLOR_SUBSTRING_START_GREEN), HEX_BASE), //
Integer.valueOf(string.substring(COLOR_SUBSTRING_START_GREEN, COLOR_SUBSTRING_START_BLUE), HEX_BASE), //
Integer.valueOf(string.substring(COLOR_SUBSTRING_START_BLUE, COLOR_STRING_LENGTH), HEX_BASE));
}
}
}
package lcsb.mapviewer.common.geometry;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.awt.Color;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
public class ColorParserTest {
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testSetInvalidColor() throws Exception {
try {
ColorParser parser = new ColorParser();
parser.parse("qwe");
fail("Exception expected");
} catch (InvalidArgumentException e) {
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testSetInvalidColor2() throws Exception {
try {
ColorParser parser = new ColorParser();
parser.parse("fffffff");
fail("Exception expected");
} catch (InvalidArgumentException e) {
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testSetColor() throws Exception {
try {
ColorParser parser = new ColorParser();
Color color = parser.parse("#ffffff");
assertEquals(Color.WHITE, color);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>lcsb.mapviewer</groupId> <groupId>lcsb.mapviewer</groupId>
<artifactId>parent</artifactId> <artifactId>parent</artifactId>
<version>1.0</version> <version>1.0</version>
</parent> </parent>
<artifactId>converter-graphics</artifactId> <artifactId>converter-graphics</artifactId>
<name>MapViewer graphics converter</name> <name>MapViewer graphics converter</name>
<description>Converter that allows to transform model into graphic representation</description> <description>Converter that allows to transform model into graphic representation</description>
<dependencies> <dependencies>
<!-- dependency from the MapViewer model --> <!-- dependency from the MapViewer model -->
<dependency> <dependency>
<groupId>lcsb.mapviewer</groupId> <groupId>lcsb.mapviewer</groupId>
<artifactId>model</artifactId> <artifactId>model</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>lcsb.mapviewer</groupId> <groupId>lcsb.mapviewer</groupId>
<artifactId>model-command</artifactId> <artifactId>model-command</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<!-- Log4J --> <!-- Log4J -->
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>${log4j.version}</version> <version>${log4j.version}</version>
</dependency> </dependency>
<!-- Library used for generating svg --> <!-- Library used for generating svg -->
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-rasterizer</artifactId> <artifactId>batik-rasterizer</artifactId>
<version>${batik.version}</version> <version>${batik.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-svggen</artifactId> <artifactId>batik-svggen</artifactId>
<version>${batik.version}</version> <version>${batik.version}</version>
</dependency> </dependency>
<!-- iText library for generating pdf --> <dependency>
<dependency> <groupId>org.mockito</groupId>
<groupId>com.itextpdf</groupId> <artifactId>mockito-all</artifactId>
<artifactId>itextpdf</artifactId> <version>${mockito.version}</version>
<version>${itext.version}</version> <scope>test</scope>
</dependency> </dependency>
<dependency> <!-- iText library for generating pdf -->
<groupId>com.itextpdf</groupId> <dependency>
<artifactId>itextpdf</artifactId> <groupId>com.itextpdf</groupId>
<version>${itext.version}</version> <artifactId>itextpdf</artifactId>
</dependency> <version>${itext.version}</version>
</dependency>
</dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itext.version}</version>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
...@@ -14,6 +14,7 @@ import java.util.Map; ...@@ -14,6 +14,7 @@ import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.common.MimeType; import lcsb.mapviewer.common.MimeType;
import lcsb.mapviewer.converter.graphics.layer.LayerConverter; import lcsb.mapviewer.converter.graphics.layer.LayerConverter;
import lcsb.mapviewer.converter.graphics.reaction.ReactionConverter; import lcsb.mapviewer.converter.graphics.reaction.ReactionConverter;
...@@ -26,6 +27,7 @@ import lcsb.mapviewer.model.map.reaction.Reaction; ...@@ -26,6 +27,7 @@ import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.modelutils.map.ElementUtils;
/** /**
* This class is responsible for creation of the image from the model. It's an * This class is responsible for creation of the image from the model. It's an
...@@ -93,6 +95,16 @@ public abstract class AbstractImageGenerator { ...@@ -93,6 +95,16 @@ public abstract class AbstractImageGenerator {
*/ */
private Rectangle2D.Double border = null; private Rectangle2D.Double border = null;
/**
* Object that helps to convert {@link ColorSchema} values into colors.
*/
private ColorExtractor colorExtractor = null;
/**
* Util class for simple operations on {@link Element elements}.
*/
private ElementUtils eu = new ElementUtils();
/** /**
* This class contains a list of params that are used for drawing. * This class contains a list of params that are used for drawing.
* *
...@@ -170,6 +182,16 @@ public abstract class AbstractImageGenerator { ...@@ -170,6 +182,16 @@ public abstract class AbstractImageGenerator {
*/ */
private List<Map<Object, ColorSchema>> visibleLayouts = new ArrayList<>(); private List<Map<Object, ColorSchema>> visibleLayouts = new ArrayList<>();
/**
* Color that should be used for drawing overlays with minimum value.
*/
private Color minColor = Color.BLACK;
/**
* Color that should be used for drawing overlays with maximum value.
*/
private Color maxColor = Color.BLACK;
/** /**
* @param scale * @param scale
* scale to set * scale to set
...@@ -481,6 +503,50 @@ public abstract class AbstractImageGenerator { ...@@ -481,6 +503,50 @@ public abstract class AbstractImageGenerator {
return result; return result;
} }
/**
* Returns {@link Color} that should be used for drawing overlays with
* maximum value.
*
* @return {@link Color} that should be used for drawing overlays with
* maximum value
*/
public Color getMaxColor() {
return maxColor;
}
/**
* Returns {@link Color} that should be used for drawing overlays with
* minimum value.
*
* @return {@link Color} that should be used for drawing overlays with
* minimum value
*/
public Color getMinColor() {
return minColor;
}
/**
* @param minColor
* minColor to set
* @return object with all parameters
* @see #minColor
*/
public Params minColor(Color minColor) {
this.minColor = minColor;
return this;
}
/**
* @param maxColor
* maxColor to set
* @return object with all parameters
* @see #maxColor
*/
public Params maxColor(Color maxColor) {
this.maxColor = maxColor;
return this;
}
} }
/** /**
...@@ -526,6 +592,8 @@ public abstract class AbstractImageGenerator { ...@@ -526,6 +592,8 @@ public abstract class AbstractImageGenerator {
this.level = params.getLevel(); this.level = params.getLevel();
this.scale = params.getScale(); this.scale = params.getScale();
colorExtractor = new ColorExtractor(params.getMinColor(), params.getMaxColor());
// set border frame extended by a margin // set border frame extended by a margin
border = new Rectangle2D.Double( border = new Rectangle2D.Double(
params.getX() - SINGLE_FRAME_MARGIN, params.getY() - SINGLE_FRAME_MARGIN, params.getWidth() * scale + 2 * SINGLE_FRAME_MARGIN, params.getX() - SINGLE_FRAME_MARGIN, params.getY() - SINGLE_FRAME_MARGIN, params.getWidth() * scale + 2 * SINGLE_FRAME_MARGIN,
...@@ -557,17 +625,18 @@ public abstract class AbstractImageGenerator { ...@@ -557,17 +625,18 @@ public abstract class AbstractImageGenerator {
// Get the SBGN display format option from the model // Get the SBGN display format option from the model
this.sbgnFormat = params.getModel().isSbgnFormat(); this.sbgnFormat = params.getModel().isSbgnFormat();
// Correct order of displaying is: aliases, reactions, compartments, layers. // Correct order of displaying is: elements, reactions, compartments,
// layers.
// In this way we can display all reactions and overlay them by compartments // In this way we can display all reactions and overlay them by compartments
// or layers if they should be solid and hide complexity behind it // or layers if they should be solid and hide complexity behind it
// draw all aliases // draw all elements
for (Element alias : params.getModel().getSortedSpeciesList()) { for (Element element : params.getModel().getSortedSpeciesList()) {
// draw only aliases that don't have parents (aren't included in any // draw only elements that don't have parents (aren't included in any
// compartment/complexes) // compartment/complexes)
if (alias instanceof Species) { if (element instanceof Species) {
if (((Species) alias).getComplex() == null) { if (((Species) element).getComplex() == null) {
drawAlias((Species) alias, params.getVisibleLayoutsForElement(alias)); drawSpecies((Species) element, params.getVisibleLayoutsForElement(element));
} }
} }
} }
...@@ -576,11 +645,11 @@ public abstract class AbstractImageGenerator { ...@@ -576,11 +645,11 @@ public abstract class AbstractImageGenerator {
drawReaction(reaction, params.getVisibleLayoutsForElement(reaction)); drawReaction(reaction, params.getVisibleLayoutsForElement(reaction));
} }
// draw all compartments // draw all compartments
for (Compartment ca : params.getModel().getSortedCompartments()) { for (Compartment compartment : params.getModel().getSortedCompartments()) {
// draw only aliases that don't have parents (aren't included in any // draw only compartment that don't have parents (aren't included in any
// compartment/complexes) // compartment/complexes)
if (ca.getCompartment() == null) { if (compartment.getCompartment() == null) {
drawCompartmentAlias(ca, params.isNested(), params.getVisibleLayoutsForElement(ca), params); drawCompartment(compartment, params.isNested(), params.getVisibleLayoutsForElement(compartment), params);
} }
} }
...@@ -611,25 +680,26 @@ public abstract class AbstractImageGenerator { ...@@ -611,25 +680,26 @@ public abstract class AbstractImageGenerator {
} }
/** /**
* This method draw a compartment alias on a graphics. * This method draw a {@link Compartment} on a graphics.
* *
* @param compAlias * @param compartment
* object that we want to draw * object that we want to draw
* @param nested * @param nested
* are the compartments drawn in hierarchical view * are the compartments drawn in hierarchical view