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 dc51d7bd73453defe5766ff822ca1c53d2f436fa..0604eb7b481275c4ed3a5633bcbbfa0ec6712451 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 7d0d731afd3c9ca331c41b0b6391db033ca863e3..a7e8702c8fa6596d13dec3033575fef71122e445 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 {