Commit 3a4d05d0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge remote-tracking branch 'origin/master' into 1016-refactor-test-framework

parents b3eea197 d0e1d32e
Pipeline #31348 failed with stage
in 63 minutes and 22 seconds
......@@ -3,7 +3,22 @@ minerva (16.0.0~alpha.0) stable; urgency=medium
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 27 Feb 2020 14:00:00 +0200
minerva (15.1.0) unstable; urgency=medium
minerva (15.1.0~beta.1) unstable; urgency=medium
* Small improvement: "Human Disease Ontology", "IUPHAR ligand" and "Protein
Modification Ontology" annotation types are handled (#1359)
* Bug fix: SBML import - label aligned to top of species was inproperly drawn
(#1354)
* Bug fix: SBML text labels that were referencing layout aliases using
layout:graphicalObject attribute were not handled properly (#1356)
* Bug fix: miriam urls in new format
(like: https://identifiers.org/kegg.compound:197020) are parsed properly for
all know identifier types (#1359)
* Bug fix: in SBGN-like view protein state should be drawn as stadium-shape
(#1357)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 18 Aug 2020 15:00:00 +0200
minerva (15.1.0~beta.0) unstable; urgency=medium
* Small improvement: annotations are exported in SBGN extension that can be
opened by newt (#1296)
* Small improvement: plugin API allows to add/remove data overlays (#1153)
......@@ -30,6 +45,12 @@ minerva (15.1.0) unstable; urgency=medium
index
* Small improvement: pathways with glyphs and z index below 0 are not
clickable (#1314)
* Small improvement: Modifier Reaction from CellDesigner are exported properly
to SBGN-ML PD (#1320)
* Small improvement: SBGN notes are imported properly (#1319)
* Small improvement: SBGN notes are exported properly (#1319)
* Small improvement: possibility to customize request account email title
(#1330)
* Bug fix: export to image from selected polygon contained all elements
inside rectangle bounded by the polygon coordinates (#1096)
* Bug fix: continuous refreshing list of project when uploading/removing
......@@ -39,7 +60,32 @@ minerva (15.1.0) unstable; urgency=medium
* Bug fix: when content of element popover is too wide the scrollbar is
visible (#1269)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Jun 2020 16:00:00 +0200
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 13 Jul 2020 16:00:00 +0200
minerva (15.0.3) stable; urgency=medium
* Bug fix: caching chemicals/drug data on big map could cause Out of Memory
issues (#1315)
* Bug fix: when there is a problem with minerva deployment on tomcat proper
warning message is presented in admin panel (#1332)
* Bug fix: API call updating user preferences did not handle properly
conflicts on new gui properties (#1326)
* Bug fix: "bqbiol:hasTaxon" relation type is not supported by CellDedigner
and is now transformed during export into something readable by
CellDesigner (#1281)
* Bug fix: concurrency issue that could happen rarely on first search of the
map and put the project into "unsearchable" state is fixed (#1333)
* Bug fix: when edit project buton was clicked on project that was removed in
another tab there was an error thrown (#1343)
* Bug fix: chebi and entrez annotations were incorrectly exported to GPML
(#1349)
* Bug fix: exporting to GPML sometimes resulted in invalid modification point
end for catalysis (#1350)
* Bug fix: elements name were not escaped properly when exporting to GPML
(#1351)
* Bug fix: reaction with description and pubmed reference was incorrectly
exported to GPML (#1352)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 13 Aug 2020 15:00:00 +0200
minerva (15.0.2) stable; urgency=medium
* Bug fix: annotations using identifiers.org urls sometimes required http and
......@@ -60,9 +106,9 @@ minerva (15.0.2) stable; urgency=medium
* Bug fix: bqmodel:isInstanceOf and bqmodel:hasInstance relation types were
not handled properly (#1281)
* Bug fix: "bqmodel:isInstanceOf", "bqmodel:hasInstance",
"bqbiol:hasProperty", "bqbiol:isPropertyOf" and "bqbiol:hasTaxon" relation
types are not supported by CellDedigner and are now transformed during
export into something readable by CellDesigner (#1281)
"bqbiol:hasProperty", "bqbiol:isPropertyOf" relation types are not
supported by CellDedigner and are now transformed during export into
something readable by CellDesigner (#1281)
* Bug fix: at random time points there was an issue with cached data (#1323)
* Bug fix: connection to DAPI timeouted sometimes which resulted in error
when checking for all chemicals for specfific protein (#1324)
......
......@@ -37,12 +37,12 @@ public final class ApplicationLevelCache implements QueryCacheInterface {
/**
* Cached nodes stored locally and identified by string.
*/
private static Map<String, Node> cachedQueryNodes = new HashMap<String, Node>();
private static Map<String, Node> cachedQueryNodes = new HashMap<>();
/**
* Cached strings stored locally and identified by string.
*/
private static Map<String, String> cachedQueryString = new HashMap<String, String>();
private static Map<String, String> cachedQueryString = new HashMap<>();
/**
* Global instance of cache.
......@@ -109,8 +109,8 @@ public final class ApplicationLevelCache implements QueryCacheInterface {
@Override
public synchronized void clearCache() {
logger.info("Clearing application cache");
cachedQueryNodes.clear();
cachedQueryString.clear();
cachedQueryNodes = new HashMap<>();
cachedQueryString= new HashMap<>();
}
@Override
......@@ -144,6 +144,16 @@ public final class ApplicationLevelCache implements QueryCacheInterface {
logger.info("Elements in cache: " + cacheCount);
clearCache();
System.gc();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
maxMem = runtime.maxMemory();
useMem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
logger.info("Memory usage after cache is cleared: " + useMem + " out of " + maxMem + " is used. Exceeded: "
+ maxMem * Configuration.getMemorySaturationRatioTriggerClean());
}
}
}
......
......@@ -128,6 +128,8 @@ public class WebPageDownloader {
BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
result = IOUtils.toString(in);
} catch (IOException e) {
logger.error(
"Problem with fetching url (" + (HTTP_INTERNAL_ERROR_RECONNECT_TIMES + 1) + " tries): " + accessUrl);
if (e.getClass().equals(IOException.class) || e.getClass().equals(FileNotFoundException.class)) {
throw new WrongResponseCodeIOException(e, code);
} else {
......
......@@ -274,7 +274,6 @@ public abstract class DrugAnnotation extends CachableInterface {
private List<String> getSuggestedQueryListWithoutCache(Project project, MiriamData organism)
throws DrugSearchException {
Set<String> resultSet = new HashSet<>();
Set<MiriamData> targets = new HashSet<>();
for (ModelData model : project.getModels()) {
for (Element element : model.getElements()) {
......@@ -315,11 +314,15 @@ public abstract class DrugAnnotation extends CachableInterface {
if (organism != null) {
organisms.add(organism);
}
List<Drug> drugs = getDrugListByTargets(targets, organisms);
for (Drug chemical : drugs) {
resultSet.add(chemical.getName());
}
List<String> result = new ArrayList<>();
Set<String> resultSet = new HashSet<>();
for (MiriamData target: targets) {
List<Drug> drugs = getDrugListByTarget(target, organisms);
for (Drug chemical : drugs) {
resultSet.add(chemical.getName());
}
}
result.addAll(resultSet);
Collections.sort(result);
return result;
......
......@@ -43,7 +43,7 @@ public class PubmedParser extends CachableInterface implements IExternalService
/**
* Version of the remote API that is supported by this connecting class.
*/
static final String SUPPORTED_VERSION = "6.3";
static final String SUPPORTED_VERSION = "6.4";
static final String API_URL = "https://www.ebi.ac.uk/europepmc/webservices/rest/";
/**
* Length of {@link #PUBMED_PREFIX} string.
......
......@@ -87,7 +87,7 @@ public class ChemicalParser {
* @throws ChemicalSearchException
* thrown when there is a problem with accessing ctd database
*/
public List<Chemical> getChemicalListByTarget(Collection<MiriamData> targets, MiriamData disease)
public List<Chemical> getChemicalListByTargets(Collection<MiriamData> targets, MiriamData disease)
throws ChemicalSearchException {
Map<MiriamData, Chemical> chemicals = new HashMap<>();
......@@ -182,10 +182,14 @@ public class ChemicalParser {
}
}
Set<String> names = new HashSet<>();
List<Chemical> chemicals = getChemicalListByTarget(hgncSymbols, diseaseMiriam);
for (Chemical chemical : chemicals) {
names.add(chemical.getChemicalName());
names.addAll(chemical.getSynonyms());
for (MiriamData hgncSymbol : hgncSymbols) {
// fetching all chemicals for big map is very memory exhaustive, therefore do it
// step by step to prevent storing everything in the memory at single point
List<Chemical> chemicals = getChemicalListByTarget(hgncSymbol, diseaseMiriam);
for (Chemical chemical : chemicals) {
names.add(chemical.getChemicalName());
names.addAll(chemical.getSynonyms());
}
}
List<String> result = new ArrayList<>(names);
Collections.sort(result);
......
package lcsb.mapviewer.annotation.cache;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.UnknownHostException;
import java.net.*;
import org.junit.*;
import org.mockito.Mockito;
public class WebPageDownloaderTest {
import lcsb.mapviewer.annotation.AnnotationTestFunctions;
public class WebPageDownloaderTest extends AnnotationTestFunctions {
@AfterClass
public static void tearDownAfterClass() throws Exception {
......@@ -80,4 +82,24 @@ public class WebPageDownloaderTest {
}
@Test
public void testErrorLogResetConnection() throws IOException {
String accessUrl = "https://www.google.pl/?gws_rd=ssl";
HttpURLConnection invalidConnection = Mockito.mock(HttpURLConnection.class);
Mockito.doThrow(new SocketException()).when(invalidConnection).getResponseCode();
Mockito.doThrow(new SocketException()).when(invalidConnection).getInputStream();
WebPageDownloader downloader = Mockito.spy(new WebPageDownloader());
Mockito.when(downloader.openConnection(accessUrl))
.thenReturn(invalidConnection);
try {
downloader.getFromNetwork(accessUrl);
} catch (SocketException e) {
}
assertEquals(1, super.getErrors().size());
}
}
......@@ -113,7 +113,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, bloodLossDisease);
List<Chemical> list = chemicalParser.getChemicalListByTargets(targets, bloodLossDisease);
assertNotNull(list);
assertFalse(list.isEmpty());
}
......@@ -124,7 +124,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, bloodLossDisease);
List<Chemical> list = chemicalParser.getChemicalListByTargets(targets, bloodLossDisease);
assertNotNull(list);
assertFalse(list.isEmpty());
}
......@@ -134,7 +134,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
MiriamData target = new MiriamData(MiriamType.WIKIPEDIA, "TNF");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
chemicalParser.getChemicalListByTarget(targets, parkinsonDiseaseId);
chemicalParser.getChemicalListByTargets(targets, parkinsonDiseaseId);
}
@Test
......@@ -150,7 +150,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
MiriamData target = new MiriamData(MiriamType.HGNC_SYMBOL, "GALM");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, parkinsonDiseaseId);
List<Chemical> list = chemicalParser.getChemicalListByTargets(targets, parkinsonDiseaseId);
assertNotNull(list);
assertTrue(list.isEmpty());
}
......
......@@ -58,6 +58,7 @@ public class CommonXmlParser {
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_BIOL_IS_PROPERTY_OF);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_MODEL_IS_INSTANCE_OF);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_MODEL_HAS_INSTANCE);
RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER.remove(MiriamRelationType.BQ_BIOL_HAS_TAXON);
}
private DocumentBuilderFactory dbFactory;
......
......@@ -162,7 +162,11 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
"Don't know what to do with celldesigner:point for class: " + result.getClass());
}
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:namePoint")) {
result.setNamePoint(getCommonParser().getPosition(node));
Point2D position = getCommonParser().getPosition(node);
result.setNameX(position.getX());
result.setNameY(position.getY());
result.setNameWidth(result.getWidth() - (result.getNameX() - result.getX()));
result.setNameHeight(result.getHeight() - (result.getNameY() - result.getY()));
result.setNameHorizontalAlign(HorizontalAlign.LEFT);
result.setNameVerticalAlign(VerticalAlign.TOP);
} else {
......@@ -171,9 +175,13 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
}
}
}
if (result.getNamePoint()==null) {
logger.warn(new LogMarker(ProjectLogEntryType.PARSING_ISSUE,result),"Name point is not defined");
result.setNamePoint(new Point2D.Double(result.getX(), result.getY()));
if (result.getNameX() == null || result.getNameY() == null || result.getNameWidth() == null
|| result.getNameHeight() == null) {
logger.warn(new LogMarker(ProjectLogEntryType.PARSING_ISSUE, result), "Name point is not defined");
result.setNameX(result.getX());
result.setNameY(result.getY());
result.setNameWidth(result.getWidth());
result.setNameHeight(result.getHeight());
result.setNameHorizontalAlign(HorizontalAlign.LEFT);
result.setNameVerticalAlign(VerticalAlign.TOP);
}
......@@ -222,8 +230,8 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
}
sb.append("<celldesigner:namePoint ");
sb.append("x=\"" + compartment.getNamePoint().getX() + "\" ");
sb.append("y=\"" + compartment.getNamePoint().getY() + "\"/>\n");
sb.append("x=\"" + compartment.getNameX() + "\" ");
sb.append("y=\"" + compartment.getNameY() + "\"/>\n");
sb.append(getDoubleLineNode(compartment));
......
package lcsb.mapviewer.converter.model.celldesigner.alias;
import java.awt.geom.Point2D;
import java.util.HashMap;
import java.util.Map;
......@@ -176,7 +175,10 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> {
}
complexAliasesMapById.put(result.getElementId(), result);
species.updateModelElementAfterLayoutAdded(result);
result.setNamePoint(new Point2D.Double(result.getCenterX(), result.getY() + result.getHeight() - 2));
result.setNameX(result.getX());
result.setNameY(result.getY());
result.setNameWidth(result.getWidth());
result.setNameHeight(result.getHeight());
result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.BOTTOM);
return result;
......
......@@ -156,7 +156,10 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
}
species.updateModelElementAfterLayoutAdded(result);
result.setNamePoint(result.getCenter());
result.setNameX(result.getX());
result.setNameY(result.getY());
result.setNameWidth(result.getWidth());
result.setNameHeight(result.getHeight());
result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.MIDDLE);
return result;
......
......@@ -227,10 +227,10 @@ public abstract class CellDesignerTestFunctions {
Model model2 = serializeModel(model);
ModelComparator comparator = new ModelComparator();
//import of unbounded compartments is problematic
for (Compartment compartment :model.getCompartments()) {
if (compartment instanceof BottomSquareCompartment ||
// import of unbounded compartments is problematic
for (Compartment compartment : model.getCompartments()) {
if (compartment instanceof BottomSquareCompartment ||
compartment instanceof TopSquareCompartment ||
compartment instanceof LeftSquareCompartment ||
compartment instanceof RightSquareCompartment) {
......@@ -261,26 +261,39 @@ public abstract class CellDesignerTestFunctions {
GenericProtein protein = new GenericProtein("id" + (idCounter++));
protein.setActivity(true);
protein.setFontSize(4);
protein.setHeight(10);
protein.setWidth(20);
protein.setX(30);
protein.setY(40);
protein.setStateLabel("xxx");
protein.setStatePrefix("yyy");
protein.setNamePoint(protein.getCenter());
protein.setNameHorizontalAlign(HorizontalAlign.CENTER);
protein.setNameVerticalAlign(VerticalAlign.MIDDLE);
assignCoordinates(30, 40, 10, 20, protein);
return protein;
}
protected SimpleMolecule createSimpleMolecule() {
SimpleMolecule result = new SimpleMolecule("id" + (idCounter++));
result.setX(50);
result.setY(60);
result.setNamePoint(result.getCenter());
result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.MIDDLE);
assignCoordinates(50, 60, 20, 20, result);
return result;
}
static int zIndex = 10;
protected static void assignCoordinates(lcsb.mapviewer.model.map.species.Element element) {
assignCoordinates(10, 20, 30, 40, element);
}
protected static void assignCoordinates(double x, double y, double width, double height,
lcsb.mapviewer.model.map.species.Element element) {
element.setX(x);
element.setY(y);
element.setZ(zIndex++);
element.setWidth(width);
element.setHeight(height);
element.setNameX(x);
element.setNameY(y);
element.setNameWidth(width);
element.setNameHeight(height);
element.setNameVerticalAlign(VerticalAlign.MIDDLE);
element.setNameHorizontalAlign(HorizontalAlign.CENTER);
}
}
......@@ -2,7 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.alias;
import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
......@@ -285,11 +284,7 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions {
private Compartment createCompartment(String id) {
Compartment compartment = new SquareCompartment(id);
compartment.setName("name" + id);
compartment.setX(13);
compartment.setY(14);
compartment.setWidth(100);
compartment.setHeight(120);
compartment.setNamePoint(new Point2D.Double(0, 1));
assignCoordinates(13, 14, 100, 120, compartment);
return compartment;
}
......
......@@ -2,8 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.alias;
import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
......@@ -54,8 +52,10 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(compartment.getWidth(), alias2.getWidth(), 1e-6);
assertEquals(compartment.getX(), alias2.getX(), 1e-6);
assertEquals(compartment.getY(), alias2.getY(), 1e-6);
assertEquals(compartment.getNamePoint().getX(), alias2.getNamePoint().getX(), 1e-6);
assertEquals(compartment.getNamePoint().getY(), alias2.getNamePoint().getY(), 1e-6);
assertEquals(compartment.getNameX(), alias2.getNameX(), 1e-6);
assertEquals(compartment.getNameY(), alias2.getNameY(), 1e-6);
assertEquals(compartment.getNameWidth(), alias2.getNameWidth(), 1e-6);
assertEquals(compartment.getNameHeight(), alias2.getNameHeight(), 1e-6);
assertNotNull(alias2.getNameHorizontalAlign());
assertNotNull(alias2.getNameVerticalAlign());
}
......@@ -63,11 +63,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
private Compartment createCompartment() {
Compartment compartment = new SquareCompartment("comp_id");
compartment.setName("name");
compartment.setX(13);
compartment.setY(14);
compartment.setWidth(100);
compartment.setHeight(120);
compartment.setNamePoint(new Point2D.Double(0, 1));
assignCoordinates(13, 14, 100, 120, compartment);
return compartment;
}
......@@ -127,8 +123,9 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(139.0, alias.getX(), 1e-6);
assertEquals(55.0, alias.getY(), 1e-6);
assertEquals(522.0, alias.getWidth(), 1e-6);
assertEquals(392.5, alias.getNamePoint().getX(), 1e-6);
assertEquals(196.5, alias.getNamePoint().getY(), 1e-6);
assertEquals(392.5, alias.getNameX(), 1e-6);
assertEquals(196.5, alias.getNameY(), 1e-6);
assertEquals(522.0, alias.getNameWidth(), 1e-6);
assertEquals(0xffcccc00, alias.getFillColor().getRGB());
}
......@@ -142,7 +139,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test
public void testLeftToXml() throws Exception {
Compartment alias = new LeftSquareCompartment("id");
alias.setNamePoint(new Point2D.Double());
assignCoordinates(alias);
String xml = parser.toXml(alias);
assertNotNull(xml);
}
......@@ -150,7 +147,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test
public void testRightToXml() throws Exception {
Compartment alias = new RightSquareCompartment("id");
alias.setNamePoint(new Point2D.Double());
assignCoordinates(alias);
String xml = parser.toXml(alias);
assertNotNull(xml);
}
......@@ -158,7 +155,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test
public void testTopToXml() throws Exception {
Compartment alias = new TopSquareCompartment("id");
alias.setNamePoint(new Point2D.Double());
assignCoordinates(alias);
String xml = parser.toXml(alias);
assertNotNull(xml);
}
......@@ -166,7 +163,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test
public void testBotttomToXml() throws Exception {
Compartment alias = new BottomSquareCompartment("id");
alias.setNamePoint(new Point2D.Double());
assignCoordinates(alias);
String xml = parser.toXml(alias);
assertNotNull(xml);
}
......
......@@ -73,7 +73,10 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(100.0, alias.getWidth(), Configuration.EPSILON);
assertEquals(744.0, alias.getX(), Configuration.EPSILON);
assertEquals(0.0, alias.getY(), Configuration.EPSILON);
assertNotNull(alias.getNamePoint());
assertNotNull(alias.getNameX());
assertNotNull(alias.getNameY());
assertNotNull(alias.getNameWidth());
assertNotNull(alias.getNameHeight());
assertNotNull(alias.getNameHorizontalAlign());
assertNotNull(alias.getNameVerticalAlign());
}
......