JAL-2434 use a constant for StructureMapping.NO_CHAIN (space)
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 28 Apr 2017 09:06:58 +0000 (10:06 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 28 Apr 2017 09:06:58 +0000 (10:06 +0100)
examples/testdata/phyre2results/56da5616b4559c93/c1krhA_.16.fasta [moved from examples/testdata/phyre2results/56da5616b4559c93/c1krhA_.1.fasta with 100% similarity]
src/jalview/structure/AtomSpec.java
src/jalview/structure/StructureMapping.java
src/jalview/structure/StructureSelectionManager.java
test/jalview/structure/AtomSpecTest.java
test/jalview/ws/sifts/SiftsClientTest.java

index f20cd31..54e2261 100644 (file)
@@ -88,8 +88,12 @@ public class AtomSpec
       throw new IllegalArgumentException(spec);
     }
 
-    String chainId = dotPos == -1 ? "" : residueChain.substring(dotPos + 1);
-
+    String chainId = dotPos == -1 ? " " : residueChain
+            .substring(dotPos + 1);
+    if (chainId.length() == 0)
+    {
+      chainId = " ";
+    }
     return new AtomSpec(modelId, chainId, resNum, 0);
   }
 
index 40789ed..d6eb1eb 100644 (file)
@@ -29,6 +29,12 @@ import java.util.List;
 
 public class StructureMapping
 {
+  /**
+   * Space character constant, recommended for consistent representation when no
+   * chain specified
+   */
+  public static String NO_CHAIN = " ";
+
   String mappingDetails;
 
   SequenceI sequence;
@@ -243,8 +249,4 @@ public class StructureMapping
     return mappingDetails;
   }
 
-  public HashMap<Integer, int[]> getMapping()
-  {
-    return mapping;
-  }
 }
index c91317e..d1593df 100644 (file)
@@ -454,7 +454,7 @@ public class StructureSelectionManager
         {
           if (targetChainId.trim().length() == 0)
           {
-            targetChainId = " ";
+            targetChainId = StructureMapping.NO_CHAIN;
           }
           else
           {
@@ -474,7 +474,7 @@ public class StructureSelectionManager
        */
       int max = -10;
       AlignSeq maxAlignseq = null;
-      String maxChainId = " ";
+      String maxChainId = StructureMapping.NO_CHAIN; // space
       PDBChain maxChain = null;
       boolean first = true;
       for (PDBChain chain : pdb.getChains())
@@ -602,7 +602,8 @@ public class StructureSelectionManager
                 .getString("status.obtaining_mapping_with_phyre2_template_alignment"));
         String fastaFile = getPhyre2FastaFileFor(pdbFile);
         StructureMapping phyre2ModelMapping = new Phyre2Client(pdb)
-                .getStructureMapping(seq, pdbFile, fastaFile, " ");
+                .getStructureMapping(seq, pdbFile, fastaFile,
+                        StructureMapping.NO_CHAIN);
         seqToStrucMapping.add(phyre2ModelMapping);
         maxChain.makeExactMapping(maxAlignseq, seq);
         maxChain.transferRESNUMFeatures(seq, null);
index ea53131..2494555 100644 (file)
@@ -28,7 +28,7 @@ public class AtomSpecTest
     as = AtomSpec.fromChimeraAtomspec("#3.2:15");
     assertEquals(as.getModelNumber(), 3);
     assertEquals(as.getPdbResNum(), 15);
-    assertEquals(as.getChain(), "");
+    assertEquals(as.getChain(), StructureMapping.NO_CHAIN); // space
     assertNull(as.getPdbFile());
 
     String spec = "3:12.B";
index fc07749..fc59241 100644 (file)
@@ -42,6 +42,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import junit.extensions.PA;
+
 import org.testng.Assert;
 import org.testng.FileAssert;
 import org.testng.annotations.AfterTest;
@@ -417,16 +419,19 @@ groups = { "Network" },
 
     // Can't do Assert.assertEquals(strucMapping.getMapping(), expectedMapping);
     // because this fails in our version of TestNG
-    Assert.assertEquals(strucMapping.getMapping().size(),
+    Map<Integer, int[]> mapping = (Map<Integer, int[]>) PA.getValue(
+            strucMapping, "mapping");
+    Assert.assertEquals(
+            mapping.size(),
             expectedMapping.size());
     Iterator<Map.Entry<Integer, int[]>> it = expectedMapping.entrySet()
             .iterator();
     while (it.hasNext())
     {
       Map.Entry<Integer, int[]> pair = it.next();
-      Assert.assertTrue(strucMapping.getMapping()
+      Assert.assertTrue(mapping
               .containsKey(pair.getKey()));
-      Assert.assertEquals(strucMapping.getMapping().get(pair.getKey()),
+      Assert.assertEquals(mapping.get(pair.getKey()),
               pair.getValue());
     }
   }