From 3f95ee99cc72fa6bd89520e1141228b078d59d00 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 31 Jul 2018 11:18:35 +0200 Subject: [PATCH] selecting element by annotation type doesn't include annotator from which it was selected --- .../mapviewer/commands/ColorModelCommand.java | 9 ++- .../commands/ColorModelCommandTest.java | 55 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java index dc51d7bd73..0604eb7b48 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java @@ -221,7 +221,14 @@ public class ColorModelCommand extends ModelCommand { } } for (MiriamData md : schema.getMiriamData()) { - if (!element.getMiriamData().contains(md)) { + boolean found = false; + for (MiriamData elementMiriamData : element.getMiriamData()) { + if (elementMiriamData.getDataType().equals(md.getDataType()) + && elementMiriamData.getResource().equals(md.getResource())) { + found = true; + } + } + if (!found) { return false; } } diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java index 7d0d731afd..a7e8702c8f 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -360,6 +360,61 @@ public class ColorModelCommandTest extends CommandTestFunctions { } + @Test + public void testSpeciesMatchWithMiriamData() throws Exception { + try { + GenericColorSchema colorSchema = new GenericColorSchema(); + colorSchema.setName("s1"); + colorSchema.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); + + GenericColorSchema colorSchema2 = new GenericColorSchema(); + colorSchema2.setName("s1"); + colorSchema2.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "PARK7")); + + GenericProtein species = new GenericProtein("id"); + species.setName("s1"); + species.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); + + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(colorSchema); + + ColorModelCommand factory = new ColorModelCommand(new ModelFullIndexed(null), schemas, colorExtractor); + + assertTrue(factory.match(species, colorSchema)); + assertFalse(factory.match(species, colorSchema2)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testSpeciesMatchWithMiriamDataDifferentAnnotator() throws Exception { + try { + GenericColorSchema colorSchema = new GenericColorSchema(); + colorSchema.setName("s1"); + colorSchema.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); + + GenericProtein species = new GenericProtein("id"); + species.setName("s1"); + species.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA", Object.class)); + + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(colorSchema); + + ColorModelCommand factory = new ColorModelCommand(new ModelFullIndexed(null), schemas, colorExtractor); + + assertTrue(factory.match(species, colorSchema)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + @Test public void testReactionMatchWithProteinMiriamData() throws Exception { try { -- GitLab