From 11d8f4cd92b8dc2fb2ee0b5f7757a6c2cdae813b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 5 Jun 2017 14:00:08 +0100 Subject: [PATCH] JAL-2480 remove redundant method, further test coverage --- src/jalview/datamodel/features/FeatureStore.java | 21 -------- .../datamodel/features/SequenceFeaturesTest.java | 51 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/jalview/datamodel/features/FeatureStore.java b/src/jalview/datamodel/features/FeatureStore.java index 1b6277c..3e80966 100644 --- a/src/jalview/datamodel/features/FeatureStore.java +++ b/src/jalview/datamodel/features/FeatureStore.java @@ -820,27 +820,6 @@ public class FeatureStore } /** - * Scans all positional features to check whether the given feature group is - * found, and returns true if found, else false - * - * @param featureGroup - * @return - */ - protected boolean findFeatureGroup(String featureGroup) - { - for (SequenceFeature sf : getPositionalFeatures()) - { - String group = sf.getFeatureGroup(); - if (group == featureGroup - || (group != null && group.equals(featureGroup))) - { - return true; - } - } - return false; - } - - /** * Answers true if this store has no features, else false * * @return diff --git a/test/jalview/datamodel/features/SequenceFeaturesTest.java b/test/jalview/datamodel/features/SequenceFeaturesTest.java index f4ec05b..b7b52a7 100644 --- a/test/jalview/datamodel/features/SequenceFeaturesTest.java +++ b/test/jalview/datamodel/features/SequenceFeaturesTest.java @@ -17,6 +17,37 @@ import org.testng.annotations.Test; public class SequenceFeaturesTest { @Test(groups = "Functional") + public void testConstructor() + { + SequenceFeaturesI store = new SequenceFeatures(); + assertFalse(store.hasFeatures()); + + store = new SequenceFeatures((List) null); + assertFalse(store.hasFeatures()); + + List features = new ArrayList<>(); + store = new SequenceFeatures(features); + assertFalse(store.hasFeatures()); + + SequenceFeature sf1 = new SequenceFeature("Metal", "desc", 10, 20, + Float.NaN, null); + features.add(sf1); + SequenceFeature sf2 = new SequenceFeature("Metal", "desc", 15, 18, + Float.NaN, null); + features.add(sf2); // nested + SequenceFeature sf3 = new SequenceFeature("Pfam", "desc2", 0, 0, + Float.NaN, null); // non-positional + features.add(sf3); + store = new SequenceFeatures(features); + assertTrue(store.hasFeatures()); + assertEquals(2, store.getFeatureCount(true)); // positional + assertEquals(1, store.getFeatureCount(false)); // non-positional + assertFalse(store.add(sf1)); // already contained + assertFalse(store.add(sf2)); // already contained + assertFalse(store.add(sf3)); // already contained + } + + @Test(groups = "Functional") public void testGetPositionalFeatures() { SequenceFeaturesI store = new SequenceFeatures(); @@ -334,6 +365,11 @@ public class SequenceFeaturesTest groups = sf.getFeatureGroups(false); // for non-positional assertEquals(groups.size(), 1); assertTrue(groups.contains("AGroup")); + groups = sf.getFeatureGroups(false, "AType"); + assertEquals(groups.size(), 1); + assertTrue(groups.contains("AGroup")); + groups = sf.getFeatureGroups(true, "AnotherType"); + assertTrue(groups.isEmpty()); /* * add, then delete, more non-positional features of different types @@ -730,6 +766,8 @@ public class SequenceFeaturesTest Float.NaN, null); assertTrue(store.add(sf1)); assertEquals(store.getTotalFeatureLength(), 11); + assertEquals(store.getTotalFeatureLength("Metal"), 11); + assertEquals(store.getTotalFeatureLength("Plastic"), 0); // re-add does nothing! assertFalse(store.add(sf1)); @@ -1163,4 +1201,17 @@ public class SequenceFeaturesTest assertEquals(pos.get(1).getEnd(), 22); assertEquals(pos.get(1).getType(), "Disulfide bond"); } + + @Test(groups = "Functional") + public void testIsOntologyTerm() + { + SequenceFeatures store = new SequenceFeatures(); + assertTrue(store.isOntologyTerm("gobbledygook")); + assertTrue(store.isOntologyTerm("transcript", "transcript")); + assertTrue(store.isOntologyTerm("mRNA", "transcript")); + assertFalse(store.isOntologyTerm("transcript", "mRNA")); + assertTrue(store.isOntologyTerm("junk", "transcript", "junk")); + assertTrue(store.isOntologyTerm("junk", new String[] {})); + assertTrue(store.isOntologyTerm("junk", (String[]) null)); + } } -- 1.7.10.2