* subselect the mapping search
*/
@Test(groups = { "Functional" })
- public void testFindMappingsBetweenSequenceAndOthers()
+ public void testFindMappingsForSequenceAndOthers()
{
SequenceI seq1 = new Sequence("Seq1", "ABC");
SequenceI seq2 = new Sequence("Seq2", "ABC");
seq4.createDatasetSequence();
/*
- * Create mappings from seq1 to seq2, seq2 to seq1, seq3 to seq1
+ * Create mappings from seq1 to seq2, seq2 to seq1, seq3 to seq1, seq3 to seq4
*/
AlignedCodonFrame acf1 = new AlignedCodonFrame();
MapList map = new MapList(new int[] { 1, 3 }, new int[] { 1, 3 }, 1, 1);
acf2.addMap(seq2.getDatasetSequence(), seq1.getDatasetSequence(), map);
AlignedCodonFrame acf3 = new AlignedCodonFrame();
acf3.addMap(seq3.getDatasetSequence(), seq1.getDatasetSequence(), map);
+ AlignedCodonFrame acf4 = new AlignedCodonFrame();
+ acf4.addMap(seq3.getDatasetSequence(), seq4.getDatasetSequence(), map);
List<AlignedCodonFrame> mappings = new ArrayList<AlignedCodonFrame>();
mappings.add(acf1);
mappings.add(acf2);
mappings.add(acf3);
+ mappings.add(acf4);
/*
- * Seq1 has three mappings
+ * test for null args
*/
List<AlignedCodonFrame> result = MappingUtils
- .findMappingsForSequenceAndOthers(seq1, mappings,
- new Alignment(new SequenceI[] { seq1, seq2 }));
+ .findMappingsForSequenceAndOthers(null, mappings,
+ Arrays.asList(new SequenceI[] { seq1, seq2 }));
+ assertTrue(result.isEmpty());
+
+ result = MappingUtils.findMappingsForSequenceAndOthers(seq1, null,
+ Arrays.asList(new SequenceI[] { seq1, seq2 }));
+ assertTrue(result.isEmpty());
+
+ /*
+ * Seq1 has three mappings, but filter argument will only accept
+ * those to seq2
+ */
+ result = MappingUtils.findMappingsForSequenceAndOthers(
+ seq1,
+ mappings,
+ Arrays.asList(new SequenceI[] { seq1, seq2,
+ seq1.getDatasetSequence() }));
+ assertEquals(2, result.size());
assertTrue(result.contains(acf1));
assertTrue(result.contains(acf2));
assertFalse("Did not expect to find mapping acf3 - subselect failed",
result.contains(acf3));
- assertEquals(2, result.size());
+ assertFalse(
+ "Did not expect to find mapping acf4 - doesn't involve sequence",
+ result.contains(acf4));
+
+ /*
+ * and verify the no filter case
+ */
+ result = MappingUtils.findMappingsForSequenceAndOthers(seq1, mappings,
+ null);
+ assertEquals(3, result.size());
+ assertTrue(result.contains(acf1));
+ assertTrue(result.contains(acf2));
+ assertTrue(result.contains(acf3));
}
@Test(groups = { "Functional" })