JAL-1743 new Chimera menu option to 'fit to window'
[jalview.git] / src / jalview / ext / rbvi / chimera / JalviewChimeraBinding.java
index 3c751e7..95ece8a 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
@@ -288,8 +291,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
       cmd.setLength(cmd.length() - 4);
     }
     String cmdstring = cmd.toString();
-    evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring
-            + ";focus " + cmdstring, false);
+    evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring, false);
   }
 
   /**
@@ -624,9 +626,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 +1022,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 + ";");