JAL-3551 copy Jalview features to Pymol 'p' (with pull refactoring)
[jalview.git] / src / jalview / ext / rbvi / chimera / JalviewChimeraBinding.java
index 98cc1ff..d1b8583 100644 (file)
@@ -38,6 +38,7 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
 import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Cache;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SearchResultMatchI;
@@ -48,6 +49,7 @@ import jalview.gui.StructureViewer.ViewerType;
 import jalview.httpserver.AbstractRequestHandler;
 import jalview.io.DataSourceType;
 import jalview.structure.AtomSpec;
+import jalview.structure.AtomSpecModel;
 import jalview.structure.StructureCommand;
 import jalview.structure.StructureCommandI;
 import jalview.structure.StructureSelectionManager;
@@ -59,15 +61,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
 
   public static final String CHIMERA_FEATURE_GROUP = "Chimera";
 
-  // 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;
-
-  private static final String PHOSPHORUS = "P";
-
-  private static final String ALPHACARBON = "CA";
-
   /*
    * Object through which we talk to Chimera
    */
@@ -367,10 +360,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
     if (getResponse)
     {
       reply = lastReply;
-      if (debug)
-      {
-        log("Response from command ('" + cmd + "') was:\n" + lastReply);
-      }
+      Cache.log.debug(
+              "Response from command ('" + cmd + "') was:\n" + lastReply);
     }
 
     return reply;
@@ -593,7 +584,11 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
 
   /**
    * Constructs and send commands to Chimera to set attributes on residues for
-   * features visible in Jalview
+   * features visible in Jalview.
+   * <p>
+   * The syntax is: setattr r &lt;attName&gt; &lt;attValue&gt; &lt;atomSpec&gt;
+   * <p>
+   * For example: setattr r jv_chain "Ferredoxin-1, Chloroplastic" #0:94.A
    * 
    * @param avp
    * @return
@@ -601,14 +596,11 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
   public int sendFeaturesToViewer(AlignmentViewPanel avp)
   {
     // TODO refactor as required to pull up to an interface
-    String[] files = getStructureFiles();
-    if (files == null)
-    {
-      return 0;
-    }
 
+    Map<String, Map<Object, AtomSpecModel>> featureValues = buildFeaturesMap(
+            avp);
     List<StructureCommandI> commands = getCommandGenerator()
-            .setAttributesForFeatures(getSsm(), files, getSequence(), avp);
+            .setAttributes(featureValues);
     if (commands.size() > 10)
     {
       sendCommandsByFile(commands);
@@ -844,6 +836,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
     return CHIMERA_SESSION_EXTENSION;
   }
 
+  @Override
   public String getHelpURL()
   {
     return "https://www.cgl.ucsf.edu/chimera/docs/UsersGuide";