import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import jalview.datamodel.SearchResults.Match;
+import java.util.BitSet;
import org.testng.annotations.Test;
assertEquals(2, m.getStart());
assertEquals(5, m.getEnd());
}
+
+ /**
+ * test markColumns for creating column selections
+ */
+ @Test(groups = { "Functional" })
+ public void testMarkColumns()
+ {
+ int marked = 0;
+ SequenceI seq1 = new Sequence("", "abcdefghijklm");
+ SequenceI seq2 = new Sequence("", "abcdefghijklm");
+ SequenceGroup s1g=new SequenceGroup(), s2g=new SequenceGroup(), sallg=new SequenceGroup();
+ s1g.addSequence(seq1, false);
+ s2g.addSequence(seq2, false);
+ sallg.addSequence(seq1, false);
+ sallg.addSequence(seq2, false);
+
+ SearchResultsI sr = new SearchResults();
+ BitSet bs = new BitSet();
+
+ sr.addResult(seq1, 1,1);
+ sr.addResult(seq2, 1,2);
+
+ // set start/end range for groups to cover matches
+
+ s1g.setStartRes(0);
+ s1g.setEndRes(5);
+ s2g.setStartRes(0);
+ s2g.setEndRes(5);
+ sallg.setStartRes(0);
+ sallg.setEndRes(5);
+
+ /*
+ * just seq1
+ */
+ marked = sr.markColumns(s1g, bs);
+ // check the bitset cardinality before checking the return value
+ assertEquals("Didn't mark expected number", 1, bs.cardinality());
+ assertEquals("Didn't return count of number of bits marked", 1, marked);
+ assertTrue("Didn't mark expected position", bs.get(0));
+ // now check return value for marking the same again
+ assertEquals(
+ "Didn't count number of bits marked for existing marked set",
+ 0,
+ sr.markColumns(s1g, bs));
+ bs.clear();
+
+ /*
+ * just seq2
+ */
+ marked = sr.markColumns(s2g, bs);
+ assertEquals("Didn't mark expected number", 2, bs.cardinality());
+ assertEquals("Didn't return count of number of bits marked", 2, marked);
+ assertTrue("Didn't mark expected position (1)", bs.get(0));
+ assertTrue("Didn't mark expected position (2)", bs.get(0));
+
+ /*
+ * both seq1 and seq2
+ * should be same as seq2
+ */
+ BitSet allbs = new BitSet();
+ assertEquals(2, sr.markColumns(sallg, allbs));
+ assertEquals(bs, allbs);
+
+ // now check range selecvtion
+
+ /*
+ * limit s2g to just the second column, sallg to the first column
+ */
+ s2g.setStartRes(1);
+ s2g.setEndRes(1);
+ sallg.setEndRes(0);
+ BitSet tbs;
+ assertEquals(1, sr.markColumns(s2g, tbs = new BitSet()));
+ assertEquals(1, sr.markColumns(sallg, tbs = new BitSet()));
+ }
}