X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2FAlignmentUtilsTests.java;h=f017662081eda164e5a0605f6c28743c97d82ec5;hb=56d72101b0584635cf539d5413db27abc8deb575;hp=0f3ea960a6f5a622cff1be6092cedf2bdfe8ec39;hpb=57924096fd7009330b3d879874f7d42874b4f416;p=jalview.git diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 0f3ea96..f017662 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -2605,25 +2605,29 @@ public class AlignmentUtilsTests assertSame(seq, cds1.getDatasetSequence()); } - @Test(groups = "Functional") public void testAddReferenceAnnotations() { - SequenceI longseq= new Sequence("longA","ASDASDASDASDAASDASDASDASDA"); + SequenceI longseq = new Sequence("longA", "ASDASDASDASDAASDASDASDASDA"); Annotation[] aa = new Annotation[longseq.getLength()]; - - for (int p=0;p tipEntries = new TreeMap<>(); Map> candidates = new LinkedHashMap<>(); @@ -2633,9 +2637,9 @@ public class AlignmentUtilsTests AlignmentUtils.addReferenceAnnotations(candidates, ourAl, null); assertNotNull(ourAl.getAlignmentAnnotation()); - assertEquals(ourAl.getAlignmentAnnotation().length,2); - - for (AlignmentAnnotation alan:ourAl.getAlignmentAnnotation()) + assertEquals(ourAl.getAlignmentAnnotation().length, 2); + + for (AlignmentAnnotation alan : ourAl.getAlignmentAnnotation()) { verifyExpectedSequenceAnnotation(alan); } @@ -2643,12 +2647,14 @@ public class AlignmentUtilsTests // now simulate copy/paste to new alignment SequenceI[] newSeqAl = new SequenceI[2]; // copy sequences but no annotation - newSeqAl[0]=new Sequence(ourAl.getSequenceAt(0),ourAl.getSequenceAt(0).getAnnotation()); - newSeqAl[1]=new Sequence(ourAl.getSequenceAt(1),ourAl.getSequenceAt(1).getAnnotation()); - + newSeqAl[0] = new Sequence(ourAl.getSequenceAt(0), + ourAl.getSequenceAt(0).getAnnotation()); + newSeqAl[1] = new Sequence(ourAl.getSequenceAt(1), + ourAl.getSequenceAt(1).getAnnotation()); + Alignment newAl = new Alignment(newSeqAl); // delete annotation - for (SequenceI sq:newAl.getSequences()) + for (SequenceI sq : newAl.getSequences()) { sq.setAlignmentAnnotation(new AlignmentAnnotation[0]); } @@ -2656,28 +2662,37 @@ public class AlignmentUtilsTests SequenceGroup sg = new SequenceGroup(Arrays.asList(newSeqAl)); sg.setStartRes(0); sg.setEndRes(newAl.getWidth()); - AlignmentUtils.addReferenceAnnotationTo(newAl, newSeqAl[0], newSeqAl[0].getDatasetSequence().getAnnotation()[0], sg); - AlignmentUtils.addReferenceAnnotationTo(newAl, newSeqAl[1], newSeqAl[1].getDatasetSequence().getAnnotation()[0], sg); - for (AlignmentAnnotation alan:newAl.getAlignmentAnnotation()) + AlignmentUtils.addReferenceAnnotationTo(newAl, newSeqAl[0], + newSeqAl[0].getDatasetSequence().getAnnotation()[0], sg); + AlignmentUtils.addReferenceAnnotationTo(newAl, newSeqAl[1], + newSeqAl[1].getDatasetSequence().getAnnotation()[0], sg); + for (AlignmentAnnotation alan : newAl.getAlignmentAnnotation()) { verifyExpectedSequenceAnnotation(alan); } } - + /** - * helper - tests annotation is mapped to position it was originally created for + * helper - tests annotation is mapped to position it was originally created + * for + * * @param alan */ private void verifyExpectedSequenceAnnotation(AlignmentAnnotation alan) { - for (int c=0;c=alan.sequenceRef.getLength() || Comparison.isGap(alan.sequenceRef.getCharAt(c))); + assertEquals("Misaligned annotation at " + c, + (float) alan.sequenceRef.findPosition(c), a.value); + } + else + { + assertTrue("Unexpected Null at position " + c, + c >= alan.sequenceRef.getLength() + || Comparison.isGap(alan.sequenceRef.getCharAt(c))); } } } @@ -2707,15 +2722,17 @@ public class AlignmentUtilsTests AlignmentAnnotation alan = al.findAnnotations(sq, null, cm_aan.label) .iterator().next(); ContactMatrixI t_cm = al.getContactMatrixFor(alan); - assertNotNull("No contact map for the transferred annotation row.",t_cm); + assertNotNull("No contact map for the transferred annotation row.", + t_cm); assertTrue(t_cm instanceof SeqDistanceContactMatrix); - assertTrue(((SeqDistanceContactMatrix)t_cm).hasReferenceSeq()); - + assertTrue(((SeqDistanceContactMatrix) t_cm).hasReferenceSeq()); + ContactListI cl = al.getContactListFor(alan, 1); assertNotNull( "No contact matrix recovered after reference annotation transfer", cl); - // semantics of sequence associated contact list is slightly tricky - column 3 in alignment should have data + // semantics of sequence associated contact list is slightly tricky - column + // 3 in alignment should have data cl = al.getContactListFor(alan, 3); assertNotNull( "Contact matrix should have data for last position in sequence",