public class SequenceFeaturesTest
{
@Test(groups = "Functional")
+ public void testConstructor()
+ {
+ SequenceFeaturesI store = new SequenceFeatures();
+ assertFalse(store.hasFeatures());
+
+ store = new SequenceFeatures((List<SequenceFeature>) null);
+ assertFalse(store.hasFeatures());
+
+ List<SequenceFeature> 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();
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
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));
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));
+ }
}