X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2FGroupingTest.java;h=cea8ae44123f6666d647d5a0fdc8b50dfbc39156;hb=37de9310bec3501cbc6381e0c3dcb282fcaad812;hp=6ac3c8cf05083849755529e696a9b83af11892c6;hpb=52288466dd1e71946a06fd1e6ea15fa8e652c693;p=jalview.git diff --git a/test/jalview/analysis/GroupingTest.java b/test/jalview/analysis/GroupingTest.java index 6ac3c8c..cea8ae4 100644 --- a/test/jalview/analysis/GroupingTest.java +++ b/test/jalview/analysis/GroupingTest.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.analysis; import jalview.datamodel.Alignment; @@ -7,7 +27,6 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; -import java.util.ArrayList; import java.util.Arrays; import org.testng.AssertJUnit; @@ -25,21 +44,26 @@ public class GroupingTest Sequence s5 = new Sequence("s5", "AAAADDEDTTEE"); - SequenceGroup sg1 = new SequenceGroup(Arrays.asList(new SequenceI[] { s1, - s2 }), "Group1", null, false, false, false, 0, 5); + 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, - s4, s5 }), "Group2", null, false, false, false, 0, 5); + 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 for the case where column selections are not added in + * left to right order + */ + int[] positions = new int[] { 7, 9, 1 }; @Test(groups = { "Functional" }) public void testMakeGroupsWithBoth() { - ArrayList str = new ArrayList(); + String[] str = new String[alignment.getHeight()]; + int seq = 0; for (SequenceI s : alignment.getSequences()) { StringBuilder sb = new StringBuilder(); @@ -47,12 +71,12 @@ public class GroupingTest { 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 })); + ColumnSelection cs = new ColumnSelection(); for (int p : positions) { @@ -60,7 +84,7 @@ public class GroupingTest } 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++)