assertFalse(fs.contains(sf1));
assertTrue(fs.contains(sf7));
}
+
+ @Test(groups = "Functional")
+ public void testFindFeatures_withResultList()
+ {
+ FeatureStore fs = newFeatureStore();
+ SequenceFeature sf1 = addFeature(fs, 10, 50);
+ SequenceFeature sf2 = addFeature(fs, 150, 250);
+
+ List<SequenceFeature> overlaps = new ArrayList<>();
+ List<SequenceFeature> result = fs.findOverlappingFeatures(200, 200,
+ overlaps);
+ assertSame(result, overlaps);
+ assertEquals(result.size(), 1);
+ assertTrue(result.contains(sf2));
+ assertFalse(result.contains(sf1));
+
+ /*
+ * if no list supplied, method creates one
+ */
+ result = fs.findOverlappingFeatures(200, 200, null);
+ assertEquals(result.size(), 1);
+ assertTrue(result.contains(sf2));
+ assertFalse(result.contains(sf1));
+ }
}
store.deleteAll();
assertFalse(store.hasFeatures());
}
+
+ @Test(groups = "Functional")
+ public void testFindFeatures_withResultList()
+ {
+ SequenceFeaturesI sf = new SequenceFeatures();
+ SequenceFeature sf1 = addFeature(sf, "Pfam", 10, 50);
+ SequenceFeature sf2 = addFeature(sf, "Pfam", 150, 250);
+
+ /*
+ * findFeatures with result list to append to
+ */
+ List<SequenceFeature> overlaps = new ArrayList<>();
+ List<SequenceFeature> result = sf.findFeatures(200, "Pfam", overlaps);
+ assertSame(result, overlaps);
+ assertEquals(result.size(), 1);
+ assertTrue(result.contains(sf2));
+ assertFalse(result.contains(sf1));
+
+ /*
+ * with no result list - method creates one
+ */
+ result = sf.findFeatures(200, "Pfam", null);
+ assertEquals(result.size(), 1);
+ assertTrue(result.contains(sf2));
+ assertFalse(result.contains(sf1));
+
+ /*
+ * verify the created list is extendable (is not immutable)
+ * notice it may contain duplicates
+ */
+ result = sf.findFeatures(220, "Pfam", result);
+ assertEquals(result.size(), 2);
+ assertSame(result.get(0), sf2); // in input list
+ assertSame(result.get(1), sf2); // duplicate added
+
+ /*
+ * no feature of requested type - with result list
+ */
+ overlaps.clear();
+ result = sf.findFeatures(200, "Rfam", overlaps);
+ assertTrue(result.isEmpty());
+
+ /*
+ * no feature of requested type - with no result list
+ */
+ result = sf.findFeatures(200, "Rfam", null);
+ assertTrue(result.isEmpty());
+
+ /*
+ * verify the created list is extendable (is not immutable)
+ */
+ result = sf.findFeatures(210, "Pfam", result);
+ assertEquals(result.size(), 1);
+ assertTrue(result.contains(sf2));
+ assertFalse(result.contains(sf1));
+ }
}