From b691a827f39b1d02cd01ee2f2e0b2077c01818bd Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 9 Oct 2017 15:24:10 +0100 Subject: [PATCH] JAL-2523 convenience method to get model organisms --- src/jalview/ext/ensembl/Species.java | 20 +++++++++++++++++++ test/jalview/ext/ensembl/SpeciesTest.java | 30 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/jalview/ext/ensembl/SpeciesTest.java diff --git a/src/jalview/ext/ensembl/Species.java b/src/jalview/ext/ensembl/Species.java index af01225..cc5465e 100644 --- a/src/jalview/ext/ensembl/Species.java +++ b/src/jalview/ext/ensembl/Species.java @@ -20,6 +20,9 @@ */ package jalview.ext.ensembl; +import java.util.HashSet; +import java.util.Set; + /** * Selected species identifiers used by Ensembl * @@ -38,6 +41,18 @@ enum Species chimpanzee(false), cat(false), zebrafish(true), chicken(true), dmelanogaster(true); + static Set modelOrganisms = new HashSet<>(); + + static + { + for (Species s : values()) + { + if (s.isModelOrganism()) + { + modelOrganisms.add(s); + } + } + } boolean modelOrganism; private Species(boolean model) @@ -49,4 +64,9 @@ enum Species { return modelOrganism; } + + public static Set getModelOrganisms() + { + return modelOrganisms; + } } diff --git a/test/jalview/ext/ensembl/SpeciesTest.java b/test/jalview/ext/ensembl/SpeciesTest.java new file mode 100644 index 0000000..44658e7 --- /dev/null +++ b/test/jalview/ext/ensembl/SpeciesTest.java @@ -0,0 +1,30 @@ +package jalview.ext.ensembl; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.testng.annotations.Test; + +public class SpeciesTest +{ + @Test + public void testGetModelOrganisms() + { + Set models = Species.getModelOrganisms(); + assertTrue(models.contains(Species.human)); + assertFalse(models.contains(Species.horse)); + for (Species s : Species.values()) + { + if (s.isModelOrganism()) + { + assertTrue(models.contains(s)); + } + else + { + assertFalse(models.contains(s)); + } + } + } +} -- 1.7.10.2