X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fanalysis%2FAnnotationSorterTest.java;h=1731302357d835e9b3a07cccad6267aef9e64a87;hb=8bbcfb93404decd6d660ca32b69a29f8a1f34e82;hp=8c3489ba9d2fcd37bf82df45e78065a85f71e2e9;hpb=c93b9ad2ebfab4cad4608a8890132918589576be;p=jalview.git diff --git a/test/jalview/analysis/AnnotationSorterTest.java b/test/jalview/analysis/AnnotationSorterTest.java index 8c3489b..1731302 100644 --- a/test/jalview/analysis/AnnotationSorterTest.java +++ b/test/jalview/analysis/AnnotationSorterTest.java @@ -30,7 +30,7 @@ public class AnnotationSorterTest /* * Set up 6 sequences and 7 annotations. */ - @BeforeMethod + @BeforeMethod(alwaysRun = true) public void setUp() { al = buildAlignment(NUM_SEQS); @@ -84,7 +84,7 @@ public class AnnotationSorterTest * sequence ref * */ - @Test + @Test(groups ={ "Functional" }) public void testSortBySequenceAndType_autocalcLast() { // @formatter:off @@ -111,7 +111,7 @@ public class AnnotationSorterTest /** * Variant with autocalculated annotations sorting to front */ - @Test + @Test(groups ={ "Functional" }) public void testSortBySequenceAndType_autocalcFirst() { // @formatter:off @@ -147,7 +147,7 @@ public class AnnotationSorterTest * sequence ref * */ - @Test + @Test(groups ={ "Functional" }) public void testSortByTypeAndSequence_autocalcLast() { // @formatter:off @@ -174,7 +174,7 @@ public class AnnotationSorterTest /** * Variant of test with autocalculated annotations sorted to front */ - @Test + @Test(groups ={ "Functional" }) public void testSortByTypeAndSequence_autocalcFirst() { // @formatter:off @@ -202,7 +202,7 @@ public class AnnotationSorterTest * Variant of test with autocalculated annotations sorted to front but * otherwise no change. */ - @Test + @Test(groups ={ "Functional" }) public void testNoSort_autocalcFirst() { // @formatter:off @@ -226,7 +226,7 @@ public class AnnotationSorterTest assertEquals("Structure", anns[6].label); } - @Test + @Test(groups ={ "Functional" }) public void testSort_timingPresorted() { testTiming_presorted(50, 100); @@ -242,23 +242,23 @@ public class AnnotationSorterTest */ private void testTiming_presorted(final int numSeqs, final int numAnns) { - al = buildAlignment(numSeqs); - anns = buildAnnotations(numAnns); + Alignment alignment = buildAlignment(numSeqs); + AlignmentAnnotation[] annotations = buildAnnotations(numAnns); /* * Set the annotations presorted by label */ Random r = new Random(); - final SequenceI[] sequences = al.getSequencesArray(); - for (int i = 0; i < anns.length; i++) + final SequenceI[] sequences = alignment.getSequencesArray(); + for (int i = 0; i < annotations.length; i++) { SequenceI randomSequenceRef = sequences[r.nextInt(sequences.length)]; - anns[i].sequenceRef = randomSequenceRef; - anns[i].label = "label" + i; + annotations[i].sequenceRef = randomSequenceRef; + annotations[i].label = "label" + i; } long startTime = System.currentTimeMillis(); - AnnotationSorter testee = new AnnotationSorter(al, false); - testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + AnnotationSorter testee = new AnnotationSorter(alignment, false); + testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); long endTime = System.currentTimeMillis(); final long elapsed = endTime - startTime; System.out.println("Timing test for presorted " + numSeqs @@ -269,7 +269,7 @@ public class AnnotationSorterTest /** * Timing tests for sorting randomly sorted annotations for various sizes. */ - @Test + @Test(groups ={ "Functional" }) public void testSort_timingUnsorted() { testTiming_unsorted(50, 100); @@ -286,23 +286,23 @@ public class AnnotationSorterTest */ private void testTiming_unsorted(final int numSeqs, final int numAnns) { - al = buildAlignment(numSeqs); - anns = buildAnnotations(numAnns); + Alignment alignment = buildAlignment(numSeqs); + AlignmentAnnotation[] annotations = buildAnnotations(numAnns); /* * Set the annotations in random order with respect to the sequences */ Random r = new Random(); - final SequenceI[] sequences = al.getSequencesArray(); - for (int i = 0; i < anns.length; i++) + final SequenceI[] sequences = alignment.getSequencesArray(); + for (int i = 0; i < annotations.length; i++) { SequenceI randomSequenceRef = sequences[r.nextInt(sequences.length)]; - anns[i].sequenceRef = randomSequenceRef; - anns[i].label = "label" + i; + annotations[i].sequenceRef = randomSequenceRef; + annotations[i].label = "label" + i; } long startTime = System.currentTimeMillis(); - AnnotationSorter testee = new AnnotationSorter(al, false); - testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); + AnnotationSorter testee = new AnnotationSorter(alignment, false); + testee.sort(annotations, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); long endTime = System.currentTimeMillis(); final long elapsed = endTime - startTime; System.out.println("Timing test for unsorted " + numSeqs @@ -313,7 +313,7 @@ public class AnnotationSorterTest /** * Timing test for sorting annotations with a limited range of types (labels). */ - @Test + @Test(groups ={ "Functional" }) public void testSort_timingSemisorted() { testTiming_semiSorted(50, 100); @@ -336,8 +336,8 @@ public class AnnotationSorterTest */ private void testTiming_semiSorted(final int numSeqs, final int numAnns) { - al = buildAlignment(numSeqs); - anns = buildAnnotations(numAnns); + Alignment alignment = buildAlignment(numSeqs); + AlignmentAnnotation[] annotations = buildAnnotations(numAnns); String[] labels = new String[] { "label1", "label2", "label3", "label4", "label5", "label6" }; @@ -346,16 +346,16 @@ public class AnnotationSorterTest * Set the annotations in sequence order with randomly assigned labels. */ Random r = new Random(); - final SequenceI[] sequences = al.getSequencesArray(); - for (int i = 0; i < anns.length; i++) + final SequenceI[] sequences = alignment.getSequencesArray(); + for (int i = 0; i < annotations.length; i++) { SequenceI sequenceRef = sequences[i % sequences.length]; - anns[i].sequenceRef = sequenceRef; - anns[i].label = labels[r.nextInt(labels.length)]; + annotations[i].sequenceRef = sequenceRef; + annotations[i].label = labels[r.nextInt(labels.length)]; } long startTime = System.currentTimeMillis(); - AnnotationSorter testee = new AnnotationSorter(al, false); - testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + AnnotationSorter testee = new AnnotationSorter(alignment, false); + testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); long endTime = System.currentTimeMillis(); long elapsed = endTime - startTime; System.out.println("Sort by label for semisorted " + numSeqs @@ -364,7 +364,7 @@ public class AnnotationSorterTest // now resort by sequence startTime = System.currentTimeMillis(); - testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); + testee.sort(annotations, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); endTime = System.currentTimeMillis(); elapsed = endTime - startTime; System.out.println("Resort by sequence for semisorted " + numSeqs @@ -373,7 +373,7 @@ public class AnnotationSorterTest // now resort by label startTime = System.currentTimeMillis(); - testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); endTime = System.currentTimeMillis(); elapsed = endTime - startTime; System.out.println("Resort by label for semisorted " + numSeqs