| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.datamodel; |
| 22 |
|
|
| 23 |
|
import static org.testng.Assert.*; |
| 24 |
|
|
| 25 |
|
import org.testng.Assert; |
| 26 |
|
import org.testng.annotations.BeforeClass; |
| 27 |
|
import org.testng.annotations.Test; |
| 28 |
|
|
| 29 |
|
import jalview.analysis.AlignmentUtils; |
| 30 |
|
import jalview.analysis.SeqsetUtils; |
| 31 |
|
import jalview.gui.JvOptionPane; |
| 32 |
|
import jalview.util.MapList; |
| 33 |
|
import jalview.ws.datamodel.MappableContactMatrixI; |
| 34 |
|
import jalview.ws.datamodel.alphafold.PAEContactMatrix; |
| 35 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (129) |
Complexity: 6 |
Complexity Density: 0.05 |
|
| 36 |
|
public class PAEContactMatrixTest |
| 37 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 38 |
1 |
@BeforeClass(alwaysRun = true)... |
| 39 |
|
public void setUpJvOptionPane() |
| 40 |
|
{ |
| 41 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 42 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
static float[][] PAEdata = { { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }, |
| 46 |
|
{ 2.0f, 1.0f, 2.0f, 3.0f, 4.0f }, |
| 47 |
|
{ 3.0f, 2.0f, 1.0f, 2.0f, 3.0f }, |
| 48 |
|
{ 4.0f, 3.0f, 2.0f, 1.0f, 2.0f }, |
| 49 |
|
{ 5.0f, 4.0f, 3.0f, 2.0f, 1.0f } }; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (77) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
| 54 |
1 |
@Test(groups = { "Functional" })... |
| 55 |
|
public void testSeqAssociatedPAEMatrix() |
| 56 |
|
{ |
| 57 |
1 |
Sequence seq = new Sequence("Seq", "ASDQE"); |
| 58 |
1 |
AlignmentAnnotation aa = seq |
| 59 |
|
.addContactList(new PAEContactMatrix(seq, PAEdata)); |
| 60 |
1 |
assertNotNull(seq.getContactListFor(aa, 0)); |
| 61 |
1 |
assertEquals(seq.getContactListFor(aa, 0).getContactAt(0), 1.0); |
| 62 |
1 |
assertNotNull(seq.getContactListFor(aa, 1)); |
| 63 |
1 |
assertEquals(seq.getContactListFor(aa, 1).getContactAt(1), 1.0); |
| 64 |
1 |
assertNotNull(seq.getContactListFor(aa, 2)); |
| 65 |
1 |
assertEquals(seq.getContactListFor(aa, 2).getContactAt(2), 1.0); |
| 66 |
1 |
assertNotNull(seq.getContactListFor(aa, 3)); |
| 67 |
1 |
assertEquals(seq.getContactListFor(aa, 3).getContactAt(3), 1.0); |
| 68 |
1 |
assertNotNull(seq.getContactListFor(aa, 4)); |
| 69 |
1 |
assertEquals(seq.getContactListFor(aa, 4).getContactAt(4), 1.0); |
| 70 |
|
|
| 71 |
1 |
assertNotNull(seq.getContactListFor(aa, seq.getEnd() - 1)); |
| 72 |
1 |
assertNull(seq.getContactListFor(aa, seq.getEnd())); |
| 73 |
|
|
| 74 |
1 |
ContactListI cm = seq.getContactListFor(aa, seq.getStart()); |
| 75 |
1 |
assertEquals(cm.getContactAt(seq.getStart()), 1d); |
| 76 |
1 |
verifyPAEmatrix(seq, aa, 0, 0, 4); |
| 77 |
|
|
| 78 |
|
|
| 79 |
1 |
seq = new Sequence("Seq/5-9", "ASDQE"); |
| 80 |
1 |
ContactMatrixI paematrix = new PAEContactMatrix(seq, PAEdata); |
| 81 |
1 |
aa = seq.addContactList(paematrix); |
| 82 |
1 |
assertNotNull(aa); |
| 83 |
|
|
| 84 |
|
|
| 85 |
1 |
Annotation ae5 = aa.getAnnotationForPosition(5); |
| 86 |
1 |
Annotation ae6 = aa.getAnnotationForPosition(6); |
| 87 |
1 |
assertNotNull(ae5); |
| 88 |
1 |
assertNotNull(ae6); |
| 89 |
1 |
assertTrue(ae5 != ae6); |
| 90 |
|
|
| 91 |
1 |
cm = seq.getContactListFor(aa, 0); |
| 92 |
1 |
assertEquals(cm.getContactAt(0), 1d); |
| 93 |
1 |
verifyPAEmatrix(seq, aa, 0, 0, 4); |
| 94 |
|
|
| 95 |
|
|
| 96 |
1 |
paematrix.setGroupSet( |
| 97 |
|
GroupSet.makeGroups(paematrix, false, 0.1f, false)); |
| 98 |
|
|
| 99 |
|
|
| 100 |
1 |
SequenceI newseq = new Sequence("Seq", "ASDQEASDQEASDQE"); |
| 101 |
1 |
Mapping sqmap = new Mapping(seq, |
| 102 |
|
new MapList(new int[] |
| 103 |
|
{ 5, 8, 10, 10 }, new int[] { 5, 9 }, 1, 1)); |
| 104 |
1 |
assertTrue(paematrix instanceof MappableContactMatrixI); |
| 105 |
|
|
| 106 |
1 |
MappableContactMatrixI remapped = ((MappableContactMatrixI) paematrix) |
| 107 |
|
.liftOver(newseq, sqmap); |
| 108 |
1 |
assertTrue(remapped instanceof PAEContactMatrix); |
| 109 |
|
|
| 110 |
1 |
AlignmentAnnotation newaa = newseq.addContactList(remapped); |
| 111 |
1 |
assertNull(newseq.getContactListFor(newaa, -1 + newseq.findIndex(1))); |
| 112 |
1 |
assertNull(newseq.getContactListFor(newaa, -1 + newseq.findIndex(4))); |
| 113 |
1 |
assertNotNull( |
| 114 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(5))); |
| 115 |
1 |
assertNotNull( |
| 116 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(6))); |
| 117 |
1 |
assertNotNull( |
| 118 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(7))); |
| 119 |
1 |
assertNotNull( |
| 120 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(8))); |
| 121 |
|
|
| 122 |
1 |
assertNull(newseq.getContactListFor(newaa, -1 + newseq.findIndex(9))); |
| 123 |
|
|
| 124 |
1 |
assertNotNull( |
| 125 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(10))); |
| 126 |
|
|
| 127 |
|
|
| 128 |
1 |
int[] mappedCl = newseq.getContactListFor(newaa, 5) |
| 129 |
|
.getMappedPositionsFor(0, 4); |
| 130 |
1 |
assertEquals(4, mappedCl.length, |
| 131 |
|
"getMappedPositionsFor doesn't support discontinuous mappings to contactList"); |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
1 |
SequenceI alseq = newseq.getSubSequence(6, 10); |
| 136 |
1 |
alseq.insertCharAt(2, 2, '-'); |
| 137 |
1 |
AlignmentI alForSeq = new Alignment(new SequenceI[] { alseq }); |
| 138 |
1 |
newaa = AlignmentUtils.addReferenceAnnotationTo(alForSeq, alseq, newaa, |
| 139 |
|
null); |
| 140 |
|
|
| 141 |
1 |
ContactListI alcl = alForSeq.getContactListFor(newaa, |
| 142 |
|
newaa.annotations.length); |
| 143 |
1 |
assertNull(alcl, "Should've gotten null!"); |
| 144 |
|
|
| 145 |
1 |
alcl = alForSeq.getContactListFor(newaa, 1); |
| 146 |
1 |
assertNotNull(alcl); |
| 147 |
1 |
mappedCl = alcl.getMappedPositionsFor(0, 4); |
| 148 |
1 |
assertNotNull(mappedCl); |
| 149 |
1 |
assertEquals(4, mappedCl.length, |
| 150 |
|
"getMappedPositionsFor doesn't support discontinuous mappings to contactList"); |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
1 |
seq = new Sequence("Seq/1-5", "ASDQE"); |
| 155 |
1 |
paematrix = new PAEContactMatrix(seq, PAEdata); |
| 156 |
1 |
assertTrue(paematrix instanceof MappableContactMatrixI); |
| 157 |
1 |
aa = seq.addContactList(paematrix); |
| 158 |
|
|
| 159 |
1 |
newseq = new Sequence("Seq", "ASDQEASDQEASDQE"); |
| 160 |
1 |
sqmap = new Mapping(seq, |
| 161 |
|
new MapList(new int[] |
| 162 |
|
{ 5, 9 }, new int[] { 1, 5 }, 1, 1)); |
| 163 |
|
|
| 164 |
1 |
remapped = ((MappableContactMatrixI) paematrix).liftOver(newseq, sqmap); |
| 165 |
1 |
assertTrue(remapped instanceof PAEContactMatrix); |
| 166 |
|
|
| 167 |
1 |
newaa = newseq.addContactList(remapped); |
| 168 |
1 |
verify_mapping(newseq, newaa); |
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
1 |
seq = new Sequence("Seq/1-5", "ASDQE"); |
| 173 |
1 |
paematrix = new PAEContactMatrix(seq, PAEdata); |
| 174 |
1 |
assertTrue(paematrix instanceof MappableContactMatrixI); |
| 175 |
1 |
aa = seq.addContactList(paematrix); |
| 176 |
|
|
| 177 |
1 |
newseq = new Sequence("Seq", "ASDQEASDQEASDQE"); |
| 178 |
1 |
sqmap = new Mapping(newseq, |
| 179 |
|
new MapList(new int[] |
| 180 |
|
{ 1, 5 }, new int[] { 5, 9 }, 1, 1)); |
| 181 |
|
|
| 182 |
1 |
remapped = ((MappableContactMatrixI) paematrix).liftOver(newseq, sqmap); |
| 183 |
1 |
assertTrue(remapped instanceof PAEContactMatrix); |
| 184 |
|
|
| 185 |
1 |
newaa = newseq.addContactList(remapped); |
| 186 |
1 |
verify_mapping(newseq, newaa); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
@param |
| 194 |
|
@param |
| 195 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 196 |
2 |
private void verify_mapping(SequenceI newseq, AlignmentAnnotation newaa)... |
| 197 |
|
{ |
| 198 |
2 |
assertNull(newseq.getContactListFor(newaa, -1 + newseq.findIndex(1))); |
| 199 |
2 |
assertNull(newseq.getContactListFor(newaa, -1 + newseq.findIndex(4))); |
| 200 |
2 |
assertNotNull( |
| 201 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(5))); |
| 202 |
2 |
assertNotNull( |
| 203 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(6))); |
| 204 |
2 |
assertNotNull( |
| 205 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(7))); |
| 206 |
2 |
assertNotNull( |
| 207 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(8))); |
| 208 |
2 |
assertNotNull( |
| 209 |
|
newseq.getContactListFor(newaa, -1 + newseq.findIndex(9))); |
| 210 |
|
|
| 211 |
2 |
assertNull(newseq.getContactListFor(newaa, -1 + newseq.findIndex(10))); |
| 212 |
|
|
| 213 |
2 |
verifyPAEmatrix(newseq, newaa, 4, 4, 8); |
| 214 |
|
} |
| 215 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 216 |
4 |
private void verifyPAEmatrix(SequenceI seq, AlignmentAnnotation aa,... |
| 217 |
|
int topl, int rowl, int rowr) |
| 218 |
|
{ |
| 219 |
4 |
int[] mappedCl; |
| 220 |
24 |
for (int f = rowl; f <= rowr; f++) |
| 221 |
|
{ |
| 222 |
20 |
ContactListI clist = seq.getContactListFor(aa, f); |
| 223 |
20 |
assertNotNull(clist, "No ContactListI for position " + (f)); |
| 224 |
20 |
assertEquals(clist.getContactAt(0), (double) f - topl + 1, |
| 225 |
|
"for column " + f + " relative to " + topl); |
| 226 |
20 |
mappedCl = clist.getMappedPositionsFor(0, 0); |
| 227 |
20 |
assertNotNull(mappedCl); |
| 228 |
20 |
assertEquals(mappedCl[0], mappedCl[1]); |
| 229 |
20 |
assertEquals(mappedCl[0], seq.findIndex(seq.getStart() + topl)); |
| 230 |
20 |
assertEquals(clist.getContactAt(f - topl), 1d, |
| 231 |
|
"for column and row " + f + " relative to " + topl); |
| 232 |
|
} |
| 233 |
|
} |
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 238 |
1 |
@Test(groups = { "Functional" })... |
| 239 |
|
public void testMappableContactMatrix() |
| 240 |
|
{ |
| 241 |
1 |
SequenceI newseq = new Sequence("Seq", "ASDQEASDQEASDQE"); |
| 242 |
1 |
MapList map = new MapList(new int[] { 5, 9 }, new int[] { 1, 5 }, 1, 1); |
| 243 |
1 |
AlignmentAnnotation aa = newseq.addContactList( |
| 244 |
|
new PAEContactMatrix(newseq, map, PAEdata, null)); |
| 245 |
1 |
ContactListI clist = newseq.getContactListFor(aa, 4); |
| 246 |
1 |
assertNotNull(clist); |
| 247 |
1 |
clist = newseq.getContactListFor(aa, 3); |
| 248 |
1 |
assertNull(clist); |
| 249 |
|
|
| 250 |
1 |
ContactMatrixI cm = newseq.getContactMatrixFor(aa); |
| 251 |
1 |
MappableContactMatrixI mcm = (MappableContactMatrixI) cm; |
| 252 |
1 |
int[] pos = mcm.getMappedPositionsFor(newseq, 0); |
| 253 |
1 |
assertNull(pos); |
| 254 |
|
|
| 255 |
1 |
pos = mcm.getMappedPositionsFor(newseq, 1); |
| 256 |
1 |
assertNotNull(pos); |
| 257 |
1 |
assertEquals(pos[0], 4 + newseq.getStart()); |
| 258 |
|
|
| 259 |
1 |
pos = mcm.getMappedPositionsFor(newseq, 6); |
| 260 |
1 |
assertNull(pos); |
| 261 |
1 |
pos = mcm.getMappedPositionsFor(newseq, 5); |
| 262 |
1 |
assertNotNull(pos); |
| 263 |
1 |
assertEquals(pos[0], 8 + newseq.getStart()); |
| 264 |
1 |
SequenceI alseq = newseq.deriveSequence(); |
| 265 |
1 |
alseq.insertCharAt(5, '-'); |
| 266 |
1 |
pos = mcm.getMappedPositionsFor(alseq, 5); |
| 267 |
1 |
assertNotNull(pos); |
| 268 |
1 |
assertEquals(pos[0], 8 + newseq.getStart()); |
| 269 |
|
|
| 270 |
|
} |
| 271 |
|
} |