{
SEQUENCE_AND_LABEL, LABEL_AND_SEQUENCE, NONE
}
-
+
private final AlignmentI alignment;
private boolean showAutocalcAbove;
return 0;
}
};
-
+
/**
* Sort by the specified ordering of sequence-specific annotations.
*
public void sort(AlignmentAnnotation[] alignmentAnnotations,
SequenceAnnotationOrder order)
{
- if (order != SequenceAnnotationOrder.NONE)
- {
- Comparator<? super AlignmentAnnotation> comparator = getComparator(order);
+ Comparator<? super AlignmentAnnotation> comparator = getComparator(order);
- if (alignmentAnnotations != null)
+ if (alignmentAnnotations != null)
+ {
+ synchronized (alignmentAnnotations)
{
- synchronized (alignmentAnnotations)
- {
- Arrays.sort(alignmentAnnotations, comparator);
- }
+ Arrays.sort(alignmentAnnotations, comparator);
}
}
}
* </ul>
*/
@Test
- public void testSortBySequenceAndType()
+ public void testSortBySequenceAndType_autocalcLast()
{
// @formatter:off
anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
}
/**
+ * Variant with autocalculated annotations sorting to front
+ */
+ @Test
+ public void testSortBySequenceAndType_autocalcFirst()
+ {
+ // @formatter:off
+ anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
+ anns[1].sequenceRef = al.getSequenceAt(3); anns[1].label = "structure";
+ anns[2].sequenceRef = al.getSequenceAt(3); anns[2].label = "iron";
+ anns[3].sequenceRef = null; anns[3].label = "Quality";
+ anns[4].sequenceRef = null; anns[4].label = "Consensus";
+ anns[5].sequenceRef = al.getSequenceAt(0); anns[5].label = "label5";
+ anns[6].sequenceRef = al.getSequenceAt(3); anns[6].label = "IRP";
+ // @formatter:on
+
+ AnnotationSorter testee = new AnnotationSorter(al, true);
+ testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
+ assertEquals("Quality", anns[0].label); // non-sequence annotations
+ assertEquals("Consensus", anns[1].label); // retain ordering
+ assertEquals("label5", anns[2].label); // for sequence 0
+ assertEquals("label0", anns[3].label); // for sequence 1
+ assertEquals("iron", anns[4].label); // sequence 3 /iron
+ assertEquals("IRP", anns[5].label); // sequence 3/IRP
+ assertEquals("structure", anns[6].label); // sequence 3/structure
+ }
+
+ /**
* Test sorting by annotation type (label) within sequence order, including
* <ul>
* <li>annotations with no sequence reference - sort to end keeping mutual
* </ul>
*/
@Test
- public void testSortByTypeAndSequence()
+ public void testSortByTypeAndSequence_autocalcLast()
{
// @formatter:off
anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
assertEquals("Consensus", anns[6].label); // retain ordering
}
+ /**
+ * Variant of test with autocalculated annotations sorted to front
+ */
+ @Test
+ public void testSortByTypeAndSequence_autocalcFirst()
+ {
+ // @formatter:off
+ anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
+ anns[1].sequenceRef = al.getSequenceAt(3); anns[1].label = "structure";
+ anns[2].sequenceRef = al.getSequenceAt(3); anns[2].label = "iron";
+ anns[3].sequenceRef = null; anns[3].label = "Quality";
+ anns[4].sequenceRef = null; anns[4].label = "Consensus";
+ anns[5].sequenceRef = al.getSequenceAt(0); anns[5].label = "IRON";
+ anns[6].sequenceRef = al.getSequenceAt(2); anns[6].label = "Structure";
+ // @formatter:on
+
+ AnnotationSorter testee = new AnnotationSorter(al, true);
+ testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
+ assertEquals("Quality", anns[0].label); // non-sequence annotations
+ assertEquals("Consensus", anns[1].label); // retain ordering
+ assertEquals("IRON", anns[2].label); // IRON / sequence 0
+ assertEquals("iron", anns[3].label); // iron / sequence 3
+ assertEquals("label0", anns[4].label); // label0 / sequence 1
+ assertEquals("Structure", anns[5].label); // Structure / sequence 2
+ assertEquals("structure", anns[6].label); // structure / sequence 3
+ }
+
+ /**
+ * Variant of test with autocalculated annotations sorted to front but
+ * otherwise no change.
+ */
+ @Test
+ public void testNoSort_autocalcFirst()
+ {
+ // @formatter:off
+ anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
+ anns[1].sequenceRef = al.getSequenceAt(3); anns[1].label = "structure";
+ anns[2].sequenceRef = al.getSequenceAt(3); anns[2].label = "iron";
+ anns[3].sequenceRef = null; anns[3].label = "Quality";
+ anns[4].sequenceRef = null; anns[4].label = "Consensus";
+ anns[5].sequenceRef = al.getSequenceAt(0); anns[5].label = "IRON";
+ anns[6].sequenceRef = al.getSequenceAt(2); anns[6].label = "Structure";
+ // @formatter:on
+
+ AnnotationSorter testee = new AnnotationSorter(al, true);
+ testee.sort(anns, SequenceAnnotationOrder.NONE);
+ assertEquals("Quality", anns[0].label); // non-sequence annotations
+ assertEquals("Consensus", anns[1].label); // retain ordering
+ assertEquals("label0", anns[2].label);
+ assertEquals("structure", anns[3].label);
+ assertEquals("iron", anns[4].label);
+ assertEquals("IRON", anns[5].label);
+ assertEquals("Structure", anns[6].label);
+ }
+
@Test
public void testSort_timingPresorted()
{