assertSame(pep.getDatasetSequence(), cds.getDBRefs()[0].map.to);
}
+ @Test(groups = { "Functional" })
+ public void testFindGroup()
+ {
+ SequenceI seq1 = new Sequence("seq1", "ABCDEF---GHI");
+ SequenceI seq2 = new Sequence("seq2", "---JKLMNO---");
+ AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2 });
+
+ assertNull(a.findGroup(null, 0));
+ assertNull(a.findGroup(seq1, 1));
+ assertNull(a.findGroup(seq1, -1));
+
+ /*
+ * add a group consisting of just "DEF"
+ */
+ SequenceGroup sg1 = new SequenceGroup();
+ sg1.addSequence(seq1, false);
+ sg1.setStartRes(3);
+ sg1.setEndRes(5);
+ a.addGroup(sg1);
+
+ assertNull(a.findGroup(seq1, 2)); // position not in group
+ assertNull(a.findGroup(seq1, 6)); // position not in group
+ assertNull(a.findGroup(seq2, 5)); // sequence not in group
+ assertSame(a.findGroup(seq1, 3), sg1); // yes
+ assertSame(a.findGroup(seq1, 4), sg1);
+ assertSame(a.findGroup(seq1, 5), sg1);
+
+ /*
+ * add a group consisting of
+ * EF--
+ * KLMN
+ */
+ SequenceGroup sg2 = new SequenceGroup();
+ sg2.addSequence(seq1, false);
+ sg2.addSequence(seq2, false);
+ sg2.setStartRes(4);
+ sg2.setEndRes(7);
+ a.addGroup(sg2);
+
+ assertNull(a.findGroup(seq1, 2)); // unchanged
+ assertSame(a.findGroup(seq1, 3), sg1); // unchanged
+ /*
+ * if a residue is in more than one group, method returns
+ * the first found (in order groups were added)
+ */
+ assertSame(a.findGroup(seq1, 4), sg1);
+ assertSame(a.findGroup(seq1, 5), sg1);
+
+ /*
+ * seq2 only belongs to the second group
+ */
+ assertSame(a.findGroup(seq2, 4), sg2);
+ assertSame(a.findGroup(seq2, 5), sg2);
+ assertSame(a.findGroup(seq2, 6), sg2);
+ assertSame(a.findGroup(seq2, 7), sg2);
+ assertNull(a.findGroup(seq2, 3));
+ assertNull(a.findGroup(seq2, 8));
+ }
+
}