1 package jalview.ws.phyre2;
3 import jalview.datamodel.Sequence;
4 import jalview.datamodel.SequenceI;
5 import jalview.ext.jmol.JmolParser;
6 import jalview.io.DataSourceType;
7 import jalview.io.StructureFile;
9 import java.io.IOException;
10 import java.util.Arrays;
11 import java.util.HashMap;
13 import org.testng.Assert;
14 import org.testng.annotations.Test;
16 public class Phyre2ClientTest
18 private Phyre2Client phyre2Client = null;
23 @Test(groups = { "Functional" })
24 public void getPhyre2FastaMappingTest()
26 String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/c4n58A_.1.pdb";
27 String fastaMappingFile = "examples/testdata/phyre2results/56da5616b4559c93/c4n58A_.1.fasta";
29 SequenceI testSeq = new Sequence(
31 "MASVSATMISTSFMPRKPAVTSLKPIPNVGEALFGLKSANGGKVTCMASYKVKLITPDGPIEF"
32 + "DCPDNVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQL"
33 + "EEGWVLTCVAYPQSDVTIETHKEAELVG", 1, 144);
35 HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
37 expectedMapping.put(1, new int[] { -1, -1 });
38 expectedMapping.put(2, new int[] { -1, -1 });
39 expectedMapping.put(3, new int[] { -1, -1 });
40 expectedMapping.put(4, new int[] { -1, -1 });
41 expectedMapping.put(5, new int[] { -1, -1 });
42 expectedMapping.put(6, new int[] { -1, -1 });
43 expectedMapping.put(7, new int[] { -1, -1 });
44 expectedMapping.put(8, new int[] { -1, -1 });
45 expectedMapping.put(9, new int[] { -1, -1 });
46 expectedMapping.put(10, new int[] { -1, -1 });
47 expectedMapping.put(11, new int[] { -1, -1 });
48 expectedMapping.put(12, new int[] { -1, -1 });
49 expectedMapping.put(13, new int[] { -1, -1 });
50 expectedMapping.put(14, new int[] { -1, -1 });
51 expectedMapping.put(15, new int[] { -1, -1 });
52 expectedMapping.put(16, new int[] { -1, -1 });
53 expectedMapping.put(17, new int[] { -1, -1 });
54 expectedMapping.put(18, new int[] { -1, -1 });
55 expectedMapping.put(19, new int[] { -1, -1 });
56 expectedMapping.put(20, new int[] { -1, -1 });
57 expectedMapping.put(21, new int[] { -1, -1 });
58 expectedMapping.put(22, new int[] { -1, -1 });
59 expectedMapping.put(23, new int[] { -1, -1 });
60 expectedMapping.put(24, new int[] { -1, -1 });
61 expectedMapping.put(25, new int[] { -1, -1 });
62 expectedMapping.put(26, new int[] { -1, -1 });
63 expectedMapping.put(27, new int[] { -1, -1 });
64 expectedMapping.put(28, new int[] { -1, -1 });
65 expectedMapping.put(29, new int[] { -1, -1 });
66 expectedMapping.put(30, new int[] { -1, -1 });
67 expectedMapping.put(31, new int[] { -1, -1 });
68 expectedMapping.put(32, new int[] { -1, -1 });
69 expectedMapping.put(33, new int[] { -1, -1 });
70 expectedMapping.put(34, new int[] { -1, -1 });
71 expectedMapping.put(35, new int[] { -1, -1 });
72 expectedMapping.put(36, new int[] { -1, -1 });
73 expectedMapping.put(37, new int[] { -1, -1 });
74 expectedMapping.put(38, new int[] { -1, -1 });
75 expectedMapping.put(39, new int[] { -1, -1 });
76 expectedMapping.put(40, new int[] { -1, -1 });
77 expectedMapping.put(41, new int[] { -1, -1 });
78 expectedMapping.put(42, new int[] { -1, -1 });
79 expectedMapping.put(43, new int[] { -1, -1 });
80 expectedMapping.put(44, new int[] { -1, -1 });
81 expectedMapping.put(45, new int[] { -1, -1 });
82 expectedMapping.put(46, new int[] { -1, -1 });
83 expectedMapping.put(47, new int[] { -1, -1 });
84 // forty eight gaps in PDB sequence
85 expectedMapping.put(48, new int[] { 48, 1 });
86 expectedMapping.put(49, new int[] { 49, 6 });
87 expectedMapping.put(50, new int[] { 50, 12 });
88 expectedMapping.put(51, new int[] { 51, 24 });
89 expectedMapping.put(52, new int[] { 52, 33 });
90 expectedMapping.put(53, new int[] { 53, 40 });
91 expectedMapping.put(54, new int[] { 54, 49 });
92 expectedMapping.put(55, new int[] { 55, 57 });
93 expectedMapping.put(56, new int[] { 56, 65 });
94 expectedMapping.put(57, new int[] { 57, 72 });
95 expectedMapping.put(58, new int[] { 58, 79 });
96 expectedMapping.put(59, new int[] { 59, 87 });
97 expectedMapping.put(60, new int[] { -1, -1 });
98 expectedMapping.put(61, new int[] { -1, -1 });
99 // two gaps in PDB sequence
100 expectedMapping.put(62, new int[] { 60, -1 });
101 expectedMapping.put(63, new int[] { 61, -1 });
102 expectedMapping.put(64, new int[] { 62, 91 });
103 expectedMapping.put(65, new int[] { 63, 100 });
104 expectedMapping.put(66, new int[] { 64, 111 });
105 expectedMapping.put(67, new int[] { 65, 119 });
106 expectedMapping.put(68, new int[] { 66, 125 });
107 expectedMapping.put(69, new int[] { 67, 132 });
108 expectedMapping.put(70, new int[] { 68, 140 });
109 expectedMapping.put(71, new int[] { 69, 148 });
110 expectedMapping.put(72, new int[] { 70, 155 });
111 expectedMapping.put(73, new int[] { 71, 167 });
112 expectedMapping.put(74, new int[] { 72, 175 });
113 expectedMapping.put(75, new int[] { 73, 183 });
114 expectedMapping.put(76, new int[] { 74, 191 });
115 expectedMapping.put(77, new int[] { 75, 200 });
116 expectedMapping.put(78, new int[] { 76, 205 });
117 expectedMapping.put(79, new int[] { 77, 214 });
118 expectedMapping.put(80, new int[] { 78, 223 });
119 expectedMapping.put(81, new int[] { 79, 228 });
120 expectedMapping.put(82, new int[] { 80, 232 });
121 expectedMapping.put(83, new int[] { 81, 242 });
122 expectedMapping.put(84, new int[] { 82, 250 });
123 expectedMapping.put(85, new int[] { 83, 258 });
124 expectedMapping.put(86, new int[] { 84, 265 });
125 expectedMapping.put(87, new int[] { 85, 277 });
126 expectedMapping.put(88, new int[] { 86, 283 });
127 expectedMapping.put(89, new int[] { 87, 289 });
128 expectedMapping.put(90, new int[] { 88, 300 });
129 expectedMapping.put(91, new int[] { 89, 305 });
130 expectedMapping.put(92, new int[] { 90, 309 });
131 expectedMapping.put(93, new int[] { 91, 315 });
132 expectedMapping.put(94, new int[] { 92, 321 });
133 expectedMapping.put(95, new int[] { 93, 327 });
134 expectedMapping.put(96, new int[] { 94, 333 });
135 expectedMapping.put(97, new int[] { 95, 339 });
136 expectedMapping.put(98, new int[] { 96, 344 });
137 expectedMapping.put(99, new int[] { 97, 348 });
138 expectedMapping.put(100, new int[] { 98, 357 });
139 expectedMapping.put(101, new int[] { 99, 365 });
140 expectedMapping.put(102, new int[] { 100, 370 });
141 expectedMapping.put(103, new int[] { 101, 374 });
142 expectedMapping.put(104, new int[] { 102, 378 });
143 expectedMapping.put(105, new int[] { 103, 383 });
144 expectedMapping.put(106, new int[] { 104, 390 });
145 expectedMapping.put(107, new int[] { 105, 398 });
146 expectedMapping.put(108, new int[] { 106, 407 });
147 expectedMapping.put(109, new int[] { 107, 414 });
148 expectedMapping.put(110, new int[] { 108, 422 });
149 expectedMapping.put(111, new int[] { 109, 426 });
150 expectedMapping.put(112, new int[] { 110, 434 });
151 expectedMapping.put(113, new int[] { 111, 445 });
152 expectedMapping.put(114, new int[] { 112, 453 });
153 expectedMapping.put(115, new int[] { 113, 461 });
154 // one gap in PDB sequence
155 expectedMapping.put(116, new int[] { -1, -1 });
156 expectedMapping.put(117, new int[] { 114, 469 });
157 expectedMapping.put(118, new int[] { 115, 477 });
158 expectedMapping.put(119, new int[] { 116, -1 });
159 expectedMapping.put(120, new int[] { 117, 486 });
160 expectedMapping.put(121, new int[] { 118, 495 });
161 expectedMapping.put(122, new int[] { 119, 504 });
162 expectedMapping.put(123, new int[] { 120, 508 });
163 expectedMapping.put(124, new int[] { 121, 522 });
164 expectedMapping.put(125, new int[] { 122, 529 });
165 expectedMapping.put(126, new int[] { 123, 537 });
166 expectedMapping.put(127, new int[] { 124, 544 });
167 expectedMapping.put(128, new int[] { 125, 550 });
168 expectedMapping.put(129, new int[] { 126, 557 });
169 expectedMapping.put(130, new int[] { 127, 562 });
170 expectedMapping.put(131, new int[] { 128, 574 });
171 expectedMapping.put(132, new int[] { 129, 581 });
172 expectedMapping.put(133, new int[] { 130, 590 });
173 expectedMapping.put(134, new int[] { 131, 596 });
174 expectedMapping.put(135, new int[] { 132, 604 });
175 expectedMapping.put(136, new int[] { 133, 611 });
176 expectedMapping.put(137, new int[] { 134, 618 });
177 expectedMapping.put(138, new int[] { 135, 626 });
178 expectedMapping.put(139, new int[] { 136, 635 });
179 expectedMapping.put(140, new int[] { 137, 642 });
180 expectedMapping.put(141, new int[] { 138, 652 });
181 expectedMapping.put(142, new int[] { 139, 661 });
182 expectedMapping.put(143, new int[] { 140, 670 });
183 expectedMapping.put(144, new int[] { -1, -1 });
185 StructureFile structureFile;
188 structureFile = new JmolParser(phyre2ModelFile, DataSourceType.FILE);
189 phyre2Client = new Phyre2Client(structureFile);
190 phyre2Client.setFastaMappingFile(fastaMappingFile);
191 } catch (IOException e1)
193 e1.printStackTrace();
195 Assert.assertNotNull(phyre2Client);
196 Assert.assertNotNull(testSeq);
197 Assert.assertNotNull(expectedMapping);
200 HashMap<Integer, int[]> actualMapping = phyre2Client
201 .getPhyre2FastaMapping(testSeq, null);
203 Assert.assertEquals(testSeq.getStart(), 1);
204 Assert.assertEquals(testSeq.getEnd(), 144);
205 testMappings(actualMapping, expectedMapping);
206 } catch (Exception e)
209 Assert.fail("Exception thrown while performing Phyre2 model mapping...");
213 @Test(groups = { "Functional" })
214 public void getPhyre2FastaMappingTest2()
216 String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/d1a70a_.pdb";
217 String fastaMappingFile = "examples/testdata/phyre2results/56da5616b4559c93/d1a70a_.fasta";
219 SequenceI testSeq = new Sequence(
221 "APPPCFSSPLRLRVAVAKPLAAPMRRQLLRAQATYNVKLITPEGEVELQVPDDVYILDFAEEEGIDLPFSCRAGSCSSCAGKVVSGSVDQSDQSFLNDNQVADGWVLTCAAYPTSDVVIETHKEDDL",
224 HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
226 expectedMapping.put(13, new int[] { -1, -1 });
227 expectedMapping.put(14, new int[] { -1, -1 });
228 expectedMapping.put(15, new int[] { -1, -1 });
229 expectedMapping.put(16, new int[] { -1, -1 });
230 expectedMapping.put(17, new int[] { -1, -1 });
231 expectedMapping.put(18, new int[] { -1, -1 });
232 expectedMapping.put(19, new int[] { -1, -1 });
233 expectedMapping.put(20, new int[] { -1, -1 });
234 expectedMapping.put(21, new int[] { -1, -1 });
235 expectedMapping.put(22, new int[] { -1, -1 });
236 expectedMapping.put(23, new int[] { -1, -1 });
237 expectedMapping.put(24, new int[] { -1, -1 });
238 expectedMapping.put(25, new int[] { -1, -1 });
239 expectedMapping.put(26, new int[] { -1, -1 });
240 expectedMapping.put(27, new int[] { -1, -1 });
241 expectedMapping.put(28, new int[] { -1, -1 });
242 expectedMapping.put(29, new int[] { -1, -1 });
243 expectedMapping.put(30, new int[] { -1, -1 });
244 expectedMapping.put(31, new int[] { -1, -1 });
245 expectedMapping.put(32, new int[] { -1, -1 });
246 expectedMapping.put(33, new int[] { -1, -1 });
247 expectedMapping.put(34, new int[] { -1, -1 });
248 expectedMapping.put(35, new int[] { -1, -1 });
249 expectedMapping.put(36, new int[] { -1, -1 });
250 expectedMapping.put(37, new int[] { -1, -1 });
251 expectedMapping.put(38, new int[] { -1, -1 });
252 expectedMapping.put(39, new int[] { -1, -1 });
253 expectedMapping.put(40, new int[] { -1, -1 });
254 expectedMapping.put(41, new int[] { -1, -1 });
255 expectedMapping.put(42, new int[] { -1, -1 });
256 expectedMapping.put(43, new int[] { -1, -1 });
257 expectedMapping.put(44, new int[] { -1, -1 });
258 // thirty two gaps in PDB sequence
259 expectedMapping.put(45, new int[] { 33, 1 });
260 expectedMapping.put(46, new int[] { 34, 6 });
261 expectedMapping.put(47, new int[] { 35, 13 });
262 expectedMapping.put(48, new int[] { 36, 25 });
263 expectedMapping.put(49, new int[] { 37, 33 });
264 expectedMapping.put(50, new int[] { 38, 40 });
265 expectedMapping.put(51, new int[] { 39, 49 });
266 expectedMapping.put(52, new int[] { 40, 57 });
267 expectedMapping.put(53, new int[] { 41, 65 });
268 expectedMapping.put(54, new int[] { 42, 72 });
269 expectedMapping.put(55, new int[] { 43, 79 });
270 expectedMapping.put(56, new int[] { 44, 88 });
271 expectedMapping.put(57, new int[] { 45, 92 });
272 expectedMapping.put(58, new int[] { 46, 101 });
273 expectedMapping.put(59, new int[] { 47, 108 });
274 expectedMapping.put(60, new int[] { 48, 117 });
275 expectedMapping.put(61, new int[] { 49, 125 });
276 expectedMapping.put(62, new int[] { 50, 134 });
277 expectedMapping.put(63, new int[] { 51, 141 });
278 expectedMapping.put(64, new int[] { 52, 148 });
279 expectedMapping.put(65, new int[] { 53, 156 });
280 expectedMapping.put(66, new int[] { 54, 164 });
281 expectedMapping.put(67, new int[] { 55, 171 });
282 expectedMapping.put(68, new int[] { 56, 183 });
283 expectedMapping.put(69, new int[] { 57, 191 });
284 expectedMapping.put(70, new int[] { 58, 199 });
285 expectedMapping.put(71, new int[] { 59, 207 });
286 expectedMapping.put(72, new int[] { 60, 218 });
287 expectedMapping.put(73, new int[] { 61, 223 });
288 expectedMapping.put(74, new int[] { 62, 232 });
289 expectedMapping.put(75, new int[] { 63, 241 });
290 expectedMapping.put(76, new int[] { 64, 250 });
291 expectedMapping.put(77, new int[] { 65, 254 });
292 expectedMapping.put(78, new int[] { 66, 262 });
293 expectedMapping.put(79, new int[] { 67, 270 });
294 expectedMapping.put(80, new int[] { 68, 278 });
295 expectedMapping.put(81, new int[] { 69, 285 });
296 expectedMapping.put(82, new int[] { 70, 296 });
297 expectedMapping.put(83, new int[] { 71, 302 });
298 expectedMapping.put(84, new int[] { 72, 308 });
299 expectedMapping.put(85, new int[] { 73, 319 });
300 expectedMapping.put(86, new int[] { 74, 324 });
301 expectedMapping.put(87, new int[] { 75, 328 });
302 expectedMapping.put(88, new int[] { 76, 334 });
303 expectedMapping.put(89, new int[] { 77, 340 });
304 expectedMapping.put(90, new int[] { 78, 346 });
305 expectedMapping.put(91, new int[] { 79, 352 });
306 expectedMapping.put(92, new int[] { 80, 358 });
307 expectedMapping.put(93, new int[] { 81, 363 });
308 expectedMapping.put(94, new int[] { 82, 367 });
309 expectedMapping.put(95, new int[] { 83, 376 });
310 expectedMapping.put(96, new int[] { 84, 383 });
311 expectedMapping.put(97, new int[] { 85, 390 });
312 expectedMapping.put(98, new int[] { 86, 396 });
313 expectedMapping.put(99, new int[] { 87, 400 });
314 expectedMapping.put(100, new int[] { 88, 406 });
315 expectedMapping.put(101, new int[] { 89, 413 });
316 expectedMapping.put(102, new int[] { 90, 421 });
317 expectedMapping.put(103, new int[] { 91, 430 });
318 expectedMapping.put(104, new int[] { 92, 436 });
319 expectedMapping.put(105, new int[] { 93, 444 });
320 expectedMapping.put(106, new int[] { 94, 453 });
321 expectedMapping.put(107, new int[] { 95, 459 });
322 expectedMapping.put(108, new int[] { 96, 470 });
323 expectedMapping.put(109, new int[] { 97, 478 });
324 expectedMapping.put(110, new int[] { 98, 486 });
325 expectedMapping.put(111, new int[] { 99, 494 });
326 expectedMapping.put(112, new int[] { 100, 502 });
327 expectedMapping.put(113, new int[] { 101, 511 });
328 expectedMapping.put(114, new int[] { 102, 518 });
329 expectedMapping.put(115, new int[] { 103, 523 });
330 expectedMapping.put(116, new int[] { 104, 531 });
331 expectedMapping.put(117, new int[] { 105, 535 });
332 expectedMapping.put(118, new int[] { 106, 549 });
333 expectedMapping.put(119, new int[] { 107, 556 });
334 expectedMapping.put(120, new int[] { 108, 564 });
335 expectedMapping.put(121, new int[] { 109, 571 });
336 expectedMapping.put(122, new int[] { 110, 577 });
337 expectedMapping.put(123, new int[] { 111, 582 });
338 expectedMapping.put(124, new int[] { 112, 587 });
339 expectedMapping.put(125, new int[] { 113, 599 });
340 expectedMapping.put(126, new int[] { 114, 606 });
341 expectedMapping.put(127, new int[] { 115, 613 });
342 expectedMapping.put(128, new int[] { 116, 619 });
343 expectedMapping.put(129, new int[] { 117, 627 });
344 expectedMapping.put(130, new int[] { 118, 634 });
345 expectedMapping.put(131, new int[] { 119, 641 });
346 expectedMapping.put(132, new int[] { 120, 649 });
347 expectedMapping.put(133, new int[] { 121, 658 });
348 expectedMapping.put(134, new int[] { 122, 665 });
349 expectedMapping.put(135, new int[] { 123, 675 });
350 expectedMapping.put(136, new int[] { 124, 684 });
351 expectedMapping.put(137, new int[] { 125, 693 });
352 expectedMapping.put(138, new int[] { 126, 701 });
353 expectedMapping.put(139, new int[] { 127, 709 });
355 StructureFile structureFile;
358 structureFile = new JmolParser(phyre2ModelFile, DataSourceType.FILE);
359 phyre2Client = new Phyre2Client(structureFile);
360 phyre2Client.setFastaMappingFile(fastaMappingFile);
361 } catch (IOException e1)
363 e1.printStackTrace();
365 Assert.assertNotNull(phyre2Client);
366 Assert.assertNotNull(testSeq);
367 Assert.assertNotNull(expectedMapping);
370 HashMap<Integer, int[]> actualMapping = phyre2Client
371 .getPhyre2FastaMapping(testSeq, null);
373 Assert.assertEquals(testSeq.getStart(), 13);
374 Assert.assertEquals(testSeq.getEnd(), 139);
375 testMappings(actualMapping, expectedMapping);
376 } catch (Exception e)
379 Assert.fail("Exception thrown while performing Phyre2 model mapping...");
383 public void testMappings(HashMap<Integer, int[]> actualMapping,
384 HashMap<Integer, int[]> expectedMapping)
386 System.out.println("Expected Mapping size: " + expectedMapping.size());
387 System.out.println("Actual Mapping size: " + actualMapping.size());
389 Assert.assertEquals(actualMapping.size(), expectedMapping.size());
391 Assert.assertEquals(actualMapping.keySet(), expectedMapping.keySet());
393 for (int key : expectedMapping.keySet())
395 System.out.println(key + " ---> [" + expectedMapping.get(key)[0]
396 + ", " + expectedMapping.get(key)[1] + "] = ["
397 + actualMapping.get(key)[0] + ", "
398 + actualMapping.get(key)[1] + "]");
399 Assert.assertTrue(Arrays.equals(expectedMapping.get(key),
400 actualMapping.get(key)));