--- /dev/null
+package jalview.ws.phyre2;
+
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.ext.jmol.JmolParser;
+import jalview.io.DataSourceType;
+import jalview.io.StructureFile;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class Phyre2ClientTest
+{
+ private Phyre2Client phyre2Client = null;
+
+
+
+
+ @Test(groups = { "Functional" })
+ public void getPhyre2FastaMappingTest()
+ {
+ String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/c4n58A_.pdb";
+
+ SequenceI testSeq = new Sequence(
+ "FER_CAPAN",
+ "MASVSATMISTSFMPRKPAVTSLKPIPNVGEALFGLKSANGGKVTCMASYKVKLITPDGPIEF"
+ + "DCPDNVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQL"
+ + "EEGWVLTCVAYPQSDVTIETHKEAELVG", 1, 144);
+
+ HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
+
+ expectedMapping.put(1, new int[] { -1, -1 });
+ expectedMapping.put(2, new int[] { -1, -1 });
+ expectedMapping.put(3, new int[] { -1, -1 });
+ expectedMapping.put(4, new int[] { -1, -1 });
+ expectedMapping.put(5, new int[] { -1, -1 });
+ expectedMapping.put(6, new int[] { -1, -1 });
+ expectedMapping.put(7, new int[] { -1, -1 });
+ expectedMapping.put(8, new int[] { -1, -1 });
+ expectedMapping.put(9, new int[] { -1, -1 });
+ expectedMapping.put(10, new int[] { -1, -1 });
+ expectedMapping.put(11, new int[] { -1, -1 });
+ expectedMapping.put(12, new int[] { -1, -1 });
+ expectedMapping.put(13, new int[] { -1, -1 });
+ expectedMapping.put(14, new int[] { -1, -1 });
+ expectedMapping.put(15, new int[] { -1, -1 });
+ expectedMapping.put(16, new int[] { -1, -1 });
+ expectedMapping.put(17, new int[] { -1, -1 });
+ expectedMapping.put(18, new int[] { -1, -1 });
+ expectedMapping.put(19, new int[] { -1, -1 });
+ expectedMapping.put(20, new int[] { -1, -1 });
+ expectedMapping.put(21, new int[] { -1, -1 });
+ expectedMapping.put(22, new int[] { -1, -1 });
+ expectedMapping.put(23, new int[] { -1, -1 });
+ expectedMapping.put(24, new int[] { -1, -1 });
+ expectedMapping.put(25, new int[] { -1, -1 });
+ expectedMapping.put(26, new int[] { -1, -1 });
+ expectedMapping.put(27, new int[] { -1, -1 });
+ expectedMapping.put(28, new int[] { -1, -1 });
+ expectedMapping.put(29, new int[] { -1, -1 });
+ expectedMapping.put(30, new int[] { -1, -1 });
+ expectedMapping.put(31, new int[] { -1, -1 });
+ expectedMapping.put(32, new int[] { -1, -1 });
+ expectedMapping.put(33, new int[] { -1, -1 });
+ expectedMapping.put(34, new int[] { -1, -1 });
+ expectedMapping.put(35, new int[] { -1, -1 });
+ expectedMapping.put(36, new int[] { -1, -1 });
+ expectedMapping.put(37, new int[] { -1, -1 });
+ expectedMapping.put(38, new int[] { -1, -1 });
+ expectedMapping.put(39, new int[] { -1, -1 });
+ expectedMapping.put(40, new int[] { -1, -1 });
+ expectedMapping.put(41, new int[] { -1, -1 });
+ expectedMapping.put(42, new int[] { -1, -1 });
+ expectedMapping.put(43, new int[] { -1, -1 });
+ expectedMapping.put(44, new int[] { -1, -1 });
+ expectedMapping.put(45, new int[] { -1, -1 });
+ expectedMapping.put(46, new int[] { -1, -1 });
+ expectedMapping.put(47, new int[] { -1, -1 });
+ // forty eight gaps in PDB sequence
+ expectedMapping.put(48, new int[] { 48, 1 });
+ expectedMapping.put(49, new int[] { 49, 6 });
+ expectedMapping.put(50, new int[] { 50, 12 });
+ expectedMapping.put(51, new int[] { 51, 24 });
+ expectedMapping.put(52, new int[] { 52, 33 });
+ expectedMapping.put(53, new int[] { 53, 40 });
+ expectedMapping.put(54, new int[] { 54, 49 });
+ expectedMapping.put(55, new int[] { 55, 57 });
+ expectedMapping.put(56, new int[] { 56, 65 });
+ expectedMapping.put(57, new int[] { 57, 72 });
+ expectedMapping.put(58, new int[] { 58, 79 });
+ expectedMapping.put(59, new int[] { 59, 87 });
+ expectedMapping.put(60, new int[] { -1, -1 });
+ expectedMapping.put(61, new int[] { -1, -1 });
+ // two gaps in PDB sequence
+ expectedMapping.put(62, new int[] { 60, -1 });
+ expectedMapping.put(63, new int[] { 61, -1 });
+ expectedMapping.put(64, new int[] { 62, 91 });
+ expectedMapping.put(65, new int[] { 63, 100 });
+ expectedMapping.put(66, new int[] { 64, 111 });
+ expectedMapping.put(67, new int[] { 65, 119 });
+ expectedMapping.put(68, new int[] { 66, 125 });
+ expectedMapping.put(69, new int[] { 67, 132 });
+ expectedMapping.put(70, new int[] { 68, 140 });
+ expectedMapping.put(71, new int[] { 69, 148 });
+ expectedMapping.put(72, new int[] { 70, 155 });
+ expectedMapping.put(73, new int[] { 71, 167 });
+ expectedMapping.put(74, new int[] { 72, 175 });
+ expectedMapping.put(75, new int[] { 73, 183 });
+ expectedMapping.put(76, new int[] { 74, 191 });
+ expectedMapping.put(77, new int[] { 75, 200 });
+ expectedMapping.put(78, new int[] { 76, 205 });
+ expectedMapping.put(79, new int[] { 77, 214 });
+ expectedMapping.put(80, new int[] { 78, 223 });
+ expectedMapping.put(81, new int[] { 79, 228 });
+ expectedMapping.put(82, new int[] { 80, 232 });
+ expectedMapping.put(83, new int[] { 81, 242 });
+ expectedMapping.put(84, new int[] { 82, 250 });
+ expectedMapping.put(85, new int[] { 83, 258 });
+ expectedMapping.put(86, new int[] { 84, 265 });
+ expectedMapping.put(87, new int[] { 85, 277 });
+ expectedMapping.put(88, new int[] { 86, 283 });
+ expectedMapping.put(89, new int[] { 87, 289 });
+ expectedMapping.put(90, new int[] { 88, 300 });
+ expectedMapping.put(91, new int[] { 89, 305 });
+ expectedMapping.put(92, new int[] { 90, 309 });
+ expectedMapping.put(93, new int[] { 91, 315 });
+ expectedMapping.put(94, new int[] { 92, 321 });
+ expectedMapping.put(95, new int[] { 93, 327 });
+ expectedMapping.put(96, new int[] { 94, 333 });
+ expectedMapping.put(97, new int[] { 95, 339 });
+ expectedMapping.put(98, new int[] { 96, 344 });
+ expectedMapping.put(99, new int[] { 97, 348 });
+ expectedMapping.put(100, new int[] { 98, 357 });
+ expectedMapping.put(101, new int[] { 99, 365 });
+ expectedMapping.put(102, new int[] { 100, 370 });
+ expectedMapping.put(103, new int[] { 101, 374 });
+ expectedMapping.put(104, new int[] { 102, 378 });
+ expectedMapping.put(105, new int[] { 103, 383 });
+ expectedMapping.put(106, new int[] { 104, 390 });
+ expectedMapping.put(107, new int[] { 105, 398 });
+ expectedMapping.put(108, new int[] { 106, 407 });
+ expectedMapping.put(109, new int[] { 107, 414 });
+ expectedMapping.put(110, new int[] { 108, 422 });
+ expectedMapping.put(111, new int[] { 109, 426 });
+ expectedMapping.put(112, new int[] { 110, 434 });
+ expectedMapping.put(113, new int[] { 111, 445 });
+ expectedMapping.put(114, new int[] { 112, 453 });
+ expectedMapping.put(115, new int[] { 113, 461 });
+ // one gap in PDB sequence
+ expectedMapping.put(116, new int[] { -1, -1 });
+ expectedMapping.put(117, new int[] { 114, 469 });
+ expectedMapping.put(118, new int[] { 115, 477 });
+ expectedMapping.put(119, new int[] { 116, -1 });
+ expectedMapping.put(120, new int[] { 117, 486 });
+ expectedMapping.put(121, new int[] { 118, 495 });
+ expectedMapping.put(122, new int[] { 119, 504 });
+ expectedMapping.put(123, new int[] { 120, 508 });
+ expectedMapping.put(124, new int[] { 121, 522 });
+ expectedMapping.put(125, new int[] { 122, 529 });
+ expectedMapping.put(126, new int[] { 123, 537 });
+ expectedMapping.put(127, new int[] { 124, 544 });
+ expectedMapping.put(128, new int[] { 125, 550 });
+ expectedMapping.put(129, new int[] { 126, 557 });
+ expectedMapping.put(130, new int[] { 127, 562 });
+ expectedMapping.put(131, new int[] { 128, 574 });
+ expectedMapping.put(132, new int[] { 129, 581 });
+ expectedMapping.put(133, new int[] { 130, 590 });
+ expectedMapping.put(134, new int[] { 131, 596 });
+ expectedMapping.put(135, new int[] { 132, 604 });
+ expectedMapping.put(136, new int[] { 133, 611 });
+ expectedMapping.put(137, new int[] { 134, 618 });
+ expectedMapping.put(138, new int[] { 135, 626 });
+ expectedMapping.put(139, new int[] { 136, 635 });
+ expectedMapping.put(140, new int[] { 137, 642 });
+ expectedMapping.put(141, new int[] { 138, 652 });
+ expectedMapping.put(142, new int[] { 139, 661 });
+ expectedMapping.put(143, new int[] { 140, 670 });
+ expectedMapping.put(144, new int[] { -1, -1 });
+
+ StructureFile structureFile;
+ try
+ {
+ structureFile = new JmolParser(phyre2ModelFile, DataSourceType.FILE);
+ phyre2Client = new Phyre2Client(structureFile);
+ } catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ Assert.assertNotNull(phyre2Client);
+ Assert.assertNotNull(testSeq);
+ Assert.assertNotNull(expectedMapping);
+ try
+ {
+ HashMap<Integer, int[]> actualMapping = phyre2Client
+ .getPhyre2FastaMapping(testSeq, null);
+
+ Assert.assertEquals(testSeq.getStart(), 1);
+ Assert.assertEquals(testSeq.getEnd(), 144);
+ testMappings(actualMapping, expectedMapping);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ Assert.fail("Exception thrown while performing Phyre2 model mapping...");
+ }
+ }
+
+ @Test(groups = { "Functional" })
+ public void getPhyre2FastaMappingTest2()
+ {
+ String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/d1a70a_.pdb";
+
+ SequenceI testSeq = new Sequence(
+ "FER_CAPAN",
+ "APPPCFSSPLRLRVAVAKPLAAPMRRQLLRAQATYNVKLITPEGEVELQVPDDVYILDFAEEEGIDLPFSCRAGSCSSCAGKVVSGSVDQSDQSFLNDNQVADGWVLTCAAYPTSDVVIETHKEDDL",
+ 13, 139);
+
+ HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
+
+ expectedMapping.put(13, new int[] { -1, -1 });
+ expectedMapping.put(14, new int[] { -1, -1 });
+ expectedMapping.put(15, new int[] { -1, -1 });
+ expectedMapping.put(16, new int[] { -1, -1 });
+ expectedMapping.put(17, new int[] { -1, -1 });
+ expectedMapping.put(18, new int[] { -1, -1 });
+ expectedMapping.put(19, new int[] { -1, -1 });
+ expectedMapping.put(20, new int[] { -1, -1 });
+ expectedMapping.put(21, new int[] { -1, -1 });
+ expectedMapping.put(22, new int[] { -1, -1 });
+ expectedMapping.put(23, new int[] { -1, -1 });
+ expectedMapping.put(24, new int[] { -1, -1 });
+ expectedMapping.put(25, new int[] { -1, -1 });
+ expectedMapping.put(26, new int[] { -1, -1 });
+ expectedMapping.put(27, new int[] { -1, -1 });
+ expectedMapping.put(28, new int[] { -1, -1 });
+ expectedMapping.put(29, new int[] { -1, -1 });
+ expectedMapping.put(30, new int[] { -1, -1 });
+ expectedMapping.put(31, new int[] { -1, -1 });
+ expectedMapping.put(32, new int[] { -1, -1 });
+ expectedMapping.put(33, new int[] { -1, -1 });
+ expectedMapping.put(34, new int[] { -1, -1 });
+ expectedMapping.put(35, new int[] { -1, -1 });
+ expectedMapping.put(36, new int[] { -1, -1 });
+ expectedMapping.put(37, new int[] { -1, -1 });
+ expectedMapping.put(38, new int[] { -1, -1 });
+ expectedMapping.put(39, new int[] { -1, -1 });
+ expectedMapping.put(40, new int[] { -1, -1 });
+ expectedMapping.put(41, new int[] { -1, -1 });
+ expectedMapping.put(42, new int[] { -1, -1 });
+ expectedMapping.put(43, new int[] { -1, -1 });
+ expectedMapping.put(44, new int[] { -1, -1 });
+ // thirty two gaps in PDB sequence
+ expectedMapping.put(45, new int[] { 33, 1 });
+ expectedMapping.put(46, new int[] { 34, 6 });
+ expectedMapping.put(47, new int[] { 35, 13 });
+ expectedMapping.put(48, new int[] { 36, 25 });
+ expectedMapping.put(49, new int[] { 37, 33 });
+ expectedMapping.put(50, new int[] { 38, 40 });
+ expectedMapping.put(51, new int[] { 39, 49 });
+ expectedMapping.put(52, new int[] { 40, 57 });
+ expectedMapping.put(53, new int[] { 41, 65 });
+ expectedMapping.put(54, new int[] { 42, 72 });
+ expectedMapping.put(55, new int[] { 43, 79 });
+ expectedMapping.put(56, new int[] { 44, 88 });
+ expectedMapping.put(57, new int[] { 45, 92 });
+ expectedMapping.put(58, new int[] { 46, 101 });
+ expectedMapping.put(59, new int[] { 47, 108 });
+ expectedMapping.put(60, new int[] { 48, 117 });
+ expectedMapping.put(61, new int[] { 49, 125 });
+ expectedMapping.put(62, new int[] { 50, 134 });
+ expectedMapping.put(63, new int[] { 51, 141 });
+ expectedMapping.put(64, new int[] { 52, 148 });
+ expectedMapping.put(65, new int[] { 53, 156 });
+ expectedMapping.put(66, new int[] { 54, 164 });
+ expectedMapping.put(67, new int[] { 55, 171 });
+ expectedMapping.put(68, new int[] { 56, 183 });
+ expectedMapping.put(69, new int[] { 57, 191 });
+ expectedMapping.put(70, new int[] { 58, 199 });
+ expectedMapping.put(71, new int[] { 59, 207 });
+ expectedMapping.put(72, new int[] { 60, 218 });
+ expectedMapping.put(73, new int[] { 61, 223 });
+ expectedMapping.put(74, new int[] { 62, 232 });
+ expectedMapping.put(75, new int[] { 63, 241 });
+ expectedMapping.put(76, new int[] { 64, 250 });
+ expectedMapping.put(77, new int[] { 65, 254 });
+ expectedMapping.put(78, new int[] { 66, 262 });
+ expectedMapping.put(79, new int[] { 67, 270 });
+ expectedMapping.put(80, new int[] { 68, 278 });
+ expectedMapping.put(81, new int[] { 69, 285 });
+ expectedMapping.put(82, new int[] { 70, 296 });
+ expectedMapping.put(83, new int[] { 71, 302 });
+ expectedMapping.put(84, new int[] { 72, 308 });
+ expectedMapping.put(85, new int[] { 73, 319 });
+ expectedMapping.put(86, new int[] { 74, 324 });
+ expectedMapping.put(87, new int[] { 75, 328 });
+ expectedMapping.put(88, new int[] { 76, 334 });
+ expectedMapping.put(89, new int[] { 77, 340 });
+ expectedMapping.put(90, new int[] { 78, 346 });
+ expectedMapping.put(91, new int[] { 79, 352 });
+ expectedMapping.put(92, new int[] { 80, 358 });
+ expectedMapping.put(93, new int[] { 81, 363 });
+ expectedMapping.put(94, new int[] { 82, 367 });
+ expectedMapping.put(95, new int[] { 83, 376 });
+ expectedMapping.put(96, new int[] { 84, 383 });
+ expectedMapping.put(97, new int[] { 85, 390 });
+ expectedMapping.put(98, new int[] { 86, 396 });
+ expectedMapping.put(99, new int[] { 87, 400 });
+ expectedMapping.put(100, new int[] { 88, 406 });
+ expectedMapping.put(101, new int[] { 89, 413 });
+ expectedMapping.put(102, new int[] { 90, 421 });
+ expectedMapping.put(103, new int[] { 91, 430 });
+ expectedMapping.put(104, new int[] { 92, 436 });
+ expectedMapping.put(105, new int[] { 93, 444 });
+ expectedMapping.put(106, new int[] { 94, 453 });
+ expectedMapping.put(107, new int[] { 95, 459 });
+ expectedMapping.put(108, new int[] { 96, 470 });
+ expectedMapping.put(109, new int[] { 97, 478 });
+ expectedMapping.put(110, new int[] { 98, 486 });
+ expectedMapping.put(111, new int[] { 99, 494 });
+ expectedMapping.put(112, new int[] { 100, 502 });
+ expectedMapping.put(113, new int[] { 101, 511 });
+ expectedMapping.put(114, new int[] { 102, 518 });
+ expectedMapping.put(115, new int[] { 103, 523 });
+ expectedMapping.put(116, new int[] { 104, 531 });
+ expectedMapping.put(117, new int[] { 105, 535 });
+ expectedMapping.put(118, new int[] { 106, 549 });
+ expectedMapping.put(119, new int[] { 107, 556 });
+ expectedMapping.put(120, new int[] { 108, 564 });
+ expectedMapping.put(121, new int[] { 109, 571 });
+ expectedMapping.put(122, new int[] { 110, 577 });
+ expectedMapping.put(123, new int[] { 111, 582 });
+ expectedMapping.put(124, new int[] { 112, 587 });
+ expectedMapping.put(125, new int[] { 113, 599 });
+ expectedMapping.put(126, new int[] { 114, 606 });
+ expectedMapping.put(127, new int[] { 115, 613 });
+ expectedMapping.put(128, new int[] { 116, 619 });
+ expectedMapping.put(129, new int[] { 117, 627 });
+ expectedMapping.put(130, new int[] { 118, 634 });
+ expectedMapping.put(131, new int[] { 119, 641 });
+ expectedMapping.put(132, new int[] { 120, 649 });
+ expectedMapping.put(133, new int[] { 121, 658 });
+ expectedMapping.put(134, new int[] { 122, 665 });
+ expectedMapping.put(135, new int[] { 123, 675 });
+ expectedMapping.put(136, new int[] { 124, 684 });
+ expectedMapping.put(137, new int[] { 125, 693 });
+ expectedMapping.put(138, new int[] { 126, 701 });
+ expectedMapping.put(139, new int[] { 127, 709 });
+
+ StructureFile structureFile;
+ try
+ {
+ structureFile = new JmolParser(phyre2ModelFile, DataSourceType.FILE);
+ phyre2Client = new Phyre2Client(structureFile);
+ } catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ Assert.assertNotNull(phyre2Client);
+ Assert.assertNotNull(testSeq);
+ Assert.assertNotNull(expectedMapping);
+ try
+ {
+ HashMap<Integer, int[]> actualMapping = phyre2Client
+ .getPhyre2FastaMapping(testSeq, null);
+
+ Assert.assertEquals(testSeq.getStart(), 13);
+ Assert.assertEquals(testSeq.getEnd(), 139);
+ testMappings(actualMapping, expectedMapping);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ Assert.fail("Exception thrown while performing Phyre2 model mapping...");
+ }
+ }
+
+ public void testMappings(HashMap<Integer, int[]> actualMapping,
+ HashMap<Integer, int[]> expectedMapping)
+ {
+ System.out.println("Expected Mapping size: " + expectedMapping.size());
+ System.out.println("Actual Mapping size: " + actualMapping.size());
+ // Test size
+ Assert.assertEquals(actualMapping.size(), expectedMapping.size());
+ // Test key set
+ Assert.assertEquals(actualMapping.keySet(), expectedMapping.keySet());
+ // Test entry set
+ for (int key : expectedMapping.keySet())
+ {
+ Assert.assertTrue(Arrays.equals(expectedMapping.get(key),
+ actualMapping.get(key)));
+ }
+ }
+
+ @Test(groups = { "Functional" })
+ public void readPhyre2SummaryTableTest()
+ {
+ String summaryhtml = "examples/testdata/phyre2results/56da5616b4559c93/summary.html";
+ Phyre2Client.parsePhyre2ResultSummaryTable(summaryhtml);
+ }
+}