X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FPAEContactMatrixTest.java;h=e4bb00038d8312dbe24f4a392a00fff6a9a1494b;hb=c1e71094304dcd2b975c485416ec5e25cca30815;hp=8cc2ec4dbaa851ca64275c6fe674aecf136dfe1a;hpb=80b889f0cca49103e1b20ed806755a0719789906;p=jalview.git diff --git a/test/jalview/datamodel/PAEContactMatrixTest.java b/test/jalview/datamodel/PAEContactMatrixTest.java index 8cc2ec4..e4bb000 100644 --- a/test/jalview/datamodel/PAEContactMatrixTest.java +++ b/test/jalview/datamodel/PAEContactMatrixTest.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.datamodel; import static org.testng.Assert.*; @@ -73,7 +93,8 @@ public class PAEContactMatrixTest verifyPAEmatrix(seq, aa, 0, 0, 4); // test clustering - paematrix.setGroupSet(GroupSet.makeGroups(paematrix, 0.1f, false)); + paematrix.setGroupSet( + GroupSet.makeGroups(paematrix, false, 0.1f, false)); // remap - test the MappableContactMatrix.liftOver method SequenceI newseq = new Sequence("Seq", "ASDQEASDQEASDQE"); @@ -116,7 +137,12 @@ public class PAEContactMatrixTest AlignmentI alForSeq = new Alignment(new SequenceI[] { alseq }); newaa = AlignmentUtils.addReferenceAnnotationTo(alForSeq, alseq, newaa, null); - ContactListI alcl = alForSeq.getContactListFor(newaa, 1); + // check for null on out of bounds + ContactListI alcl = alForSeq.getContactListFor(newaa, + newaa.annotations.length); + assertNull(alcl, "Should've gotten null!"); + // now check for mapping + alcl = alForSeq.getContactListFor(newaa, 1); assertNotNull(alcl); mappedCl = alcl.getMappedPositionsFor(0, 4); assertNotNull(mappedCl); @@ -206,4 +232,40 @@ public class PAEContactMatrixTest } } + /** + * check mapping and resolution methods work + */ + @Test(groups = { "Functional" }) + public void testMappableContactMatrix() + { + SequenceI newseq = new Sequence("Seq", "ASDQEASDQEASDQE"); + MapList map = new MapList(new int[] { 5, 9 }, new int[] { 1, 5 }, 1, 1); + AlignmentAnnotation aa = newseq.addContactList( + new PAEContactMatrix(newseq, map, PAEdata, null)); + ContactListI clist = newseq.getContactListFor(aa, 4); + assertNotNull(clist); + clist = newseq.getContactListFor(aa, 3); + assertNull(clist); + + ContactMatrixI cm = newseq.getContactMatrixFor(aa); + MappableContactMatrixI mcm = (MappableContactMatrixI) cm; + int[] pos = mcm.getMappedPositionsFor(newseq, 0); + assertNull(pos); + + pos = mcm.getMappedPositionsFor(newseq, 1); + assertNotNull(pos); + assertEquals(pos[0], 4 + newseq.getStart()); + + pos = mcm.getMappedPositionsFor(newseq, 6); // after end of matrix + assertNull(pos); + pos = mcm.getMappedPositionsFor(newseq, 5); // at end of matrix + assertNotNull(pos); + assertEquals(pos[0], 8 + newseq.getStart()); + SequenceI alseq = newseq.deriveSequence(); + alseq.insertCharAt(5, '-'); + pos = mcm.getMappedPositionsFor(alseq, 5); // at end of matrix + assertNotNull(pos); + assertEquals(pos[0], 8 + newseq.getStart()); + + } }