JAL-2434 omit unmapped positions from mapping
[jalview.git] / test / jalview / ws / phyre2 / Phyre2ClientTest.java
index 811ddd0..394ea69 100644 (file)
@@ -23,7 +23,8 @@ public class Phyre2ClientTest
   @Test(groups = { "Functional" })
   public void getPhyre2FastaMappingTest()
   {
-    String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/c4n58A_.pdb";
+    String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/c4n58A_.1.pdb";
+    String fastaMappingFile = "examples/testdata/phyre2results/56da5616b4559c93/c4n58A_.1.fasta";
 
     SequenceI testSeq = new Sequence(
             "FER_CAPAN",
@@ -32,55 +33,7 @@ public class Phyre2ClientTest
                     + "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
+    // PDB sequence starts with residue 48
     expectedMapping.put(48, new int[] { 48, 1 });
     expectedMapping.put(49, new int[] { 49, 6 });
     expectedMapping.put(50, new int[] { 50, 12 });
@@ -93,11 +46,8 @@ public class Phyre2ClientTest
     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 });
+    // residues 60, 61 absent in PDB file
+    // residues 62, 63 also skipped in map (is this right?)
     expectedMapping.put(64, new int[] { 62, 91 });
     expectedMapping.put(65, new int[] { 63, 100 });
     expectedMapping.put(66, new int[] { 64, 111 });
@@ -150,11 +100,10 @@ public class Phyre2ClientTest
     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 });
+    // residue 116 absent in PDB file
     expectedMapping.put(117, new int[] { 114, 469 });
     expectedMapping.put(118, new int[] { 115, 477 });
-    expectedMapping.put(119, new int[] { 116, -1 });
+    // residue 119 gets removed as mapped to 116 - is this right?
     expectedMapping.put(120, new int[] { 117, 486 });
     expectedMapping.put(121, new int[] { 118, 495 });
     expectedMapping.put(122, new int[] { 119, 504 });
@@ -179,13 +128,14 @@ public class Phyre2ClientTest
     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 });
+    // residue 144 absent in PDB file
 
     StructureFile structureFile;
     try
     {
       structureFile = new JmolParser(phyre2ModelFile, DataSourceType.FILE);
       phyre2Client = new Phyre2Client(structureFile);
+      phyre2Client.setFastaMappingFile(fastaMappingFile);
     } catch (IOException e1)
     {
       e1.printStackTrace();
@@ -212,6 +162,7 @@ public class Phyre2ClientTest
   public void getPhyre2FastaMappingTest2()
   {
     String phyre2ModelFile = "examples/testdata/phyre2results/56da5616b4559c93/d1a70a_.pdb";
+    String fastaMappingFile = "examples/testdata/phyre2results/56da5616b4559c93/d1a70a_.fasta";
 
     SequenceI testSeq = new Sequence(
             "FER_CAPAN",
@@ -219,40 +170,7 @@ public class Phyre2ClientTest
             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
+    // PDB sequence starts with residue 33
     expectedMapping.put(45, new int[] { 33, 1 });
     expectedMapping.put(46, new int[] { 34, 6 });
     expectedMapping.put(47, new int[] { 35, 13 });
@@ -354,6 +272,7 @@ public class Phyre2ClientTest
     {
       structureFile = new JmolParser(phyre2ModelFile, DataSourceType.FILE);
       phyre2Client = new Phyre2Client(structureFile);
+      phyre2Client.setFastaMappingFile(fastaMappingFile);
     } catch (IOException e1)
     {
       e1.printStackTrace();
@@ -368,6 +287,7 @@ public class Phyre2ClientTest
 
       Assert.assertEquals(testSeq.getStart(), 13);
       Assert.assertEquals(testSeq.getEnd(), 139);
+      Assert.assertEquals(actualMapping, expectedMapping);
       testMappings(actualMapping, expectedMapping);
     } catch (Exception e)
     {
@@ -388,6 +308,10 @@ public class Phyre2ClientTest
     // Test entry set
     for (int key : expectedMapping.keySet())
     {
+      System.out.println(key + " ---> [" + expectedMapping.get(key)[0]
+              + ", " + expectedMapping.get(key)[1] + "] = ["
+              + actualMapping.get(key)[0] + ", "
+              + actualMapping.get(key)[1] + "]");
       Assert.assertTrue(Arrays.equals(expectedMapping.get(key),
               actualMapping.get(key)));
     }