public class FeatureStoreJSTest
{
+ private int intervalStoreOption = FeatureStore.intervalStoreJSOption;
+
@Test(groups = "Functional")
public void testFindFeatures_nonNested()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
fs.addFeature(new SequenceFeature("", "", 10, 20, Float.NaN,
null));
// same range different description
overlaps = fs.findOverlappingFeatures(12, 16);
assertEquals(overlaps.size(), 3);
- assertEquals(overlaps.get(0).getEnd(), 20);
- assertEquals(overlaps.get(1).getEnd(), 20);
assertEquals(overlaps.get(2).getEnd(), 25);
+ assertEquals(overlaps.get(1).getEnd(), 20);
+ assertEquals(overlaps.get(0).getEnd(), 20);
overlaps = fs.findOverlappingFeatures(33, 33);
assertEquals(overlaps.size(), 1);
assertEquals(overlaps.get(0).getEnd(), 35);
}
- private FeatureStoreI newFeatureStore()
+ private FeatureStore newFeatureStore()
{
- return new FeatureStoreJS();
- // return new FeatureStoreImpl();
+ return new FeatureStore(intervalStoreOption);
}
@Test(groups = "Functional")
public void testFindFeatures_nested()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
SequenceFeature sf1 = addFeature(fs, 10, 50);
SequenceFeature sf2 = addFeature(fs, 10, 40);
SequenceFeature sf3 = addFeature(fs, 20, 30);
assertTrue(overlaps.contains(sf4));
}
+ private void testFind()
+ {
+ FeatureStore fs1 = newFeatureStore();
+
+ SequenceFeature sf = addFeature(fs1, 1, 3000);
+
+ for (int i = 1; i < 1000; i++)
+
+ {
+
+ addFeature(fs1, 1 + i, 1000 + i);
+
+ }
+
+ // 1.......3000
+ // 2....1001
+ // 3....1002
+ // 4....1003
+ // ...
+ // 1000..1999
+
+ List<SequenceFeature> overlaps1 = fs1.findOverlappingFeatures(2000,
+ 2001);
+
+ assertEquals(overlaps1.size(), 1);
+
+ assertTrue(overlaps1.contains(sf));
+
+ }
+
@Test(groups = "Functional")
public void testFindFeatures_mixed()
{
- FeatureStoreI fs = newFeatureStore();
+ testFind();
+
+ FeatureStore fs = newFeatureStore();
SequenceFeature sf1 = addFeature(fs, 10, 50);
SequenceFeature sf2 = addFeature(fs, 1, 15);
SequenceFeature sf3 = addFeature(fs, 20, 30);
* @param to
* @return
*/
- SequenceFeature addFeature(FeatureStoreI fs, int from, int to)
+ SequenceFeature addFeature(FeatureStore fs, int from, int to)
{
SequenceFeature sf1 = new SequenceFeature("", "", from, to, Float.NaN,
null);
@Test(groups = "Functional")
public void testFindFeatures_contactFeatures()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
SequenceFeature sf = new SequenceFeature("disulphide bond", "bond", 10,
20, Float.NaN, null);
@Test(groups = "Functional")
public void testGetPositionalFeatures()
{
- FeatureStoreI store = newFeatureStore();
+ FeatureStore store = newFeatureStore();
SequenceFeature sf1 = new SequenceFeature("Metal", "desc", 10, 20,
Float.NaN, null);
store.addFeature(sf1);
@Test(groups = "Functional")
public void testDelete()
{
- FeatureStoreI store = newFeatureStore();
+ FeatureStore store = newFeatureStore();
SequenceFeature sf1 = addFeature(store, 10, 20);
assertTrue(store.getPositionalFeatures().contains(sf1));
@Test(groups = "Functional")
public void testAddFeature()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
SequenceFeature sf1 = new SequenceFeature("Cath", "", 10, 20,
Float.NaN, null);
@Test(groups = "Functional")
public void testIsEmpty()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
assertTrue(fs.isEmpty());
assertEquals(fs.getFeatureCount(true), 0);
@Test(groups = "Functional")
public void testGetFeatureGroups()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
assertTrue(fs.getFeatureGroups(true).isEmpty());
assertTrue(fs.getFeatureGroups(false).isEmpty());
@Test(groups = "Functional")
public void testGetTotalFeatureLength()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
assertEquals(fs.getTotalFeatureLength(), 0);
addFeature(fs, 10, 20); // 11
@Test(groups = "Functional")
public void testGetMinimumScore_getMaximumScore()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
assertEquals(fs.getMinimumScore(true), Float.NaN); // positional
assertEquals(fs.getMaximumScore(true), Float.NaN);
assertEquals(fs.getMinimumScore(false), Float.NaN); // non-positional
@Test(groups = "Functional")
public void testListContains()
{
- FeatureStoreI featureStore = newFeatureStore();
+ FeatureStore featureStore = newFeatureStore();
assertFalse(featureStore.listContains(null, null));
List<SequenceFeature> features = new ArrayList<>();
assertFalse(featureStore.listContains(features, null));
@Test(groups = "Functional")
public void testGetFeaturesForGroup()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
/*
* with no features
@Test(groups = "Functional")
public void testShiftFeatures()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
assertFalse(fs.shiftFeatures(0, 1)); // nothing to do
SequenceFeature sf1 = new SequenceFeature("Cath", "", 2, 5, 0f, null);
/*
* add a feature and a nested feature
*/
- FeatureStoreI store = newFeatureStore();
+ FeatureStore store = newFeatureStore();
SequenceFeature sf1 = addFeature(store, 10, 20);
// sf2 is nested in sf1 so will be stored in nestedFeatures
SequenceFeature sf2 = addFeature(store, 12, 14);
@Test(groups = "Functional")
public void testContains()
{
- FeatureStoreI fs = newFeatureStore();
+ FeatureStore fs = newFeatureStore();
SequenceFeature sf1 = new SequenceFeature("Cath", "", 10, 20,
Float.NaN, "group1");
SequenceFeature sf2 = new SequenceFeature("Cath", "", 10, 20,