import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import java.util.ArrayList;
import java.util.Arrays;
import org.testng.AssertJUnit;
Sequence s5 = new Sequence("s5", "AAAADDEDTTEE");
- SequenceGroup sg1 = new SequenceGroup(Arrays.asList(new SequenceI[] { s1,
+ SequenceGroup sg_12 = new SequenceGroup(Arrays.asList(new SequenceI[] { s1,
s2 }), "Group1", null, false, false, false, 0, 5);
- SequenceGroup sg2 = new SequenceGroup(Arrays.asList(new SequenceI[] { s3,
+ SequenceGroup sg_345 = new SequenceGroup(Arrays.asList(new SequenceI[] { s3,
s4, s5 }), "Group2", null, false, false, false, 0, 5);
AlignmentI alignment = new Alignment(
new SequenceI[] { s1, s2, s3, s4, s5 });
- int[] positions = new int[] { 1, 7, 9 };
-
@Test(groups = { "Functional" })
public void testMakeGroupsWithBoth()
{
- ArrayList<String> str = new ArrayList<String>();
+ int[] positions = new int[] { 1, 7, 9 };
+ String[] str = new String[alignment.getHeight()];
+ int seq = 0;
for (SequenceI s : alignment.getSequences())
{
StringBuilder sb = new StringBuilder();
{
sb.append(s.getCharAt(p));
}
- str.add(sb.toString());
+ str[seq++] = sb.toString();
}
SequenceGroup[] seqgroupsString = Grouping.makeGroupsFrom(
- alignment.getSequencesArray(),
- str.toArray(new String[str.size()]),
- Arrays.asList(new SequenceGroup[] { sg1, sg2 }));
+ alignment.getSequencesArray(), str,
+ Arrays.asList(new SequenceGroup[] { sg_12, sg_345 }));
+
+ /*
+ * test for the case where column selections are not added in
+ * left to right order
+ */
+ positions = new int[] { 7, 9, 1 };
ColumnSelection cs = new ColumnSelection();
for (int p : positions)
{
}
SequenceGroup[] seqgroupsColSel = Grouping.makeGroupsFromCols(
alignment.getSequencesArray(), cs,
- Arrays.asList(new SequenceGroup[] { sg1, sg2 }));
+ Arrays.asList(new SequenceGroup[] { sg_12, sg_345 }));
AssertJUnit
.assertEquals(seqgroupsString.length, seqgroupsColSel.length);
for (int p = 0; p < seqgroupsString.length; p++)