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 f6ff490e8d5364c39a14b0a0afe6d6c468e4be1f..43df86700d988312824773796cba1910b664808d 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java @@ -137,16 +137,16 @@ public class ColorModelCommand extends ModelCommand { if (schema.getGeneralIdentifier() != null && !schema.getGeneralIdentifier().equals("")) { MiriamData md = MiriamType.getMiriamDataFromIdentifier(schema.getGeneralIdentifier()); - if (reaction.getMiriamData().contains(md)) { - return true; + if (!reaction.getMiriamData().contains(md)) { + return false; } } for (Pair<MiriamType, String> pair : schema.getIdentifierColumns()) { if (pair.getRight() != null && !pair.getRight().equals("")) { MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, pair.getLeft(), pair.getRight()); - if (reaction.getMiriamData().contains(md)) { - return true; + if (!reaction.getMiriamData().contains(md)) { + 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 d240a93b7c25239f27c96d0db283afb02c1a5e30..b8d977f4464beee2fcbb76d195245dceee162434 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -17,6 +17,7 @@ import org.junit.Test; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.BioEntity; +import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; @@ -363,6 +364,51 @@ public class ColorModelCommandTest extends CommandTestFunctions { } + @Test + public void testReactionMatchWithProteinMiriamData() throws Exception { + try { + GenericColorSchema colorSchema = new GenericColorSchema(); + colorSchema.setGeneralIdentifier(MiriamType.HGNC_SYMBOL.getCommonName()+":SNCA"); + + Reaction reaction = new Reaction(); + + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(colorSchema); + + ColorModelCommand factory = new ColorModelCommand(new ModelFullIndexed(null), schemas, colorExtractor); + + assertFalse(factory.match(reaction, colorSchema)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testReactionMatchWithMiriamData() throws Exception { + try { + GenericColorSchema colorSchema = new GenericColorSchema(); + colorSchema.setGeneralIdentifier(MiriamType.PUBMED.getCommonName()+":1234"); + + Reaction reaction = new Reaction(); + reaction.addMiriamData(new MiriamData(MiriamType.PUBMED, "1234")); + + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(colorSchema); + + ColorModelCommand factory = new ColorModelCommand(new ModelFullIndexed(null), schemas, colorExtractor); + + assertTrue(factory.match(reaction, colorSchema)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + @Test public void testReactionColoringWithModelNotMatching() throws Exception { try {