JAL-1757 match only first altloc CA in PDB structure for superposition
[jalview.git] / src / jalview / ext / rbvi / chimera / JalviewChimeraBinding.java
index 3c751e7..98f2e1a 100644 (file)
@@ -40,6 +40,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.httpserver.AbstractRequestHandler;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ResidueProperties;
 import jalview.structure.AtomSpec;
@@ -52,6 +53,8 @@ import jalview.util.MessageManager;
 
 public abstract class JalviewChimeraBinding extends AAStructureBindingModel
 {
+  // Chimera clause to exclude alternate locations in atom selection
+  private static final String NO_ALTLOCS = "&~@.B-Z&~@.2-9";
 
   private static final boolean debug = false;
 
@@ -69,7 +72,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
   /*
    * Object which listens to Chimera notifications
    */
-  private ChimeraListener chimeraListener;
+  private AbstractRequestHandler chimeraListener;
 
   /*
    * set if chimera state is being restored from some source - instructs binding
@@ -624,9 +627,12 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
         // TODO: handle sub-models
         command.append(selcom[pdbfnum]);
         command.append("@" + atomSpec[pdbfnum]);
+        // JAL-1757 exclude alternative CA locations
+        command.append(NO_ALTLOCS);
         command.append(" #" + refStructure /* +".1" */);
         command.append(selcom[refStructure]);
         command.append("@" + atomSpec[refStructure]);
+        command.append(NO_ALTLOCS);
       }
       if (selectioncom.length() > 0)
       {
@@ -1017,23 +1023,16 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
       return;
     }
 
-    int index;
-    Color col;
     // Chimera expects RBG values in the range 0-1
     final double normalise = 255D;
     viewerCommandHistory(false);
-    // TODO: Switch between nucleotide or aa selection expressions
     StringBuilder command = new StringBuilder(128);
-    command.append("color white;");
-    for (String res : ResidueProperties.aa3Hash.keySet())
-    {
-      index = ResidueProperties.aa3Hash.get(res).intValue();
-      if (index > 20)
-      {
-        continue;
-      }
 
-      col = cs.findColour(ResidueProperties.aa[index].charAt(0));
+    List<String> residueSet = ResidueProperties.getResidues(isNucleotide(),
+            false);
+    for (String res : residueSet)
+    {
+      Color col = cs.findColour(res.charAt(0));
       command.append("color " + col.getRed() / normalise + ","
               + col.getGreen() / normalise + "," + col.getBlue()
               / normalise + " ::" + res + ";");