JAL-3400 include sequence name in View | Show Chain menu
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index ff88bb7..e1045c0 100644 (file)
@@ -859,13 +859,14 @@ public class StructureSelectionManager
    * @param pdbResNum
    * @param chain
    * @param pdbfile
+   * @return
    */
-  public void mouseOverStructure(int pdbResNum, String chain,
+  public String mouseOverStructure(int pdbResNum, String chain,
           String pdbfile)
   {
     AtomSpec atomSpec = new AtomSpec(pdbfile, chain, pdbResNum, 0);
     List<AtomSpec> atoms = Collections.singletonList(atomSpec);
-    mouseOverStructure(atoms);
+    return mouseOverStructure(atoms);
   }
 
   /**
@@ -873,12 +874,12 @@ public class StructureSelectionManager
    * 
    * @param atoms
    */
-  public void mouseOverStructure(List<AtomSpec> atoms)
+  public String mouseOverStructure(List<AtomSpec> atoms)
   {
     if (listeners == null)
     {
       // old or prematurely sent event
-      return;
+      return null;
     }
     boolean hasSequenceListener = false;
     for (int i = 0; i < listeners.size(); i++)
@@ -890,18 +891,24 @@ public class StructureSelectionManager
     }
     if (!hasSequenceListener)
     {
-      return;
+      return null;
     }
 
     SearchResultsI results = findAlignmentPositionsForStructurePositions(
             atoms);
+    String result = null;
     for (Object li : listeners)
     {
       if (li instanceof SequenceListener)
       {
-        ((SequenceListener) li).highlightSequence(results);
+        String s = ((SequenceListener) li).highlightSequence(results);
+        if (s != null)
+        {
+          result = s;
+        }
       }
     }
+    return result;
   }
 
   /**
@@ -1154,6 +1161,28 @@ public class StructureSelectionManager
   }
 
   /**
+   * Answers a (possibly empty) list of structure to sequence mappings matching
+   * the given pdb and chain ids
+   * 
+   * @param pdbId
+   * @param chain
+   * @return
+   */
+  public List<StructureMapping> getMappingForChain(String pdbId,
+          String chain)
+  {
+    List<StructureMapping> result = new ArrayList<>();
+    for (StructureMapping sm : mappings)
+    {
+      if (sm.pdbid.equals(pdbId) && sm.pdbchain.equals(chain))
+      {
+        result.add(sm);
+      }
+    }
+    return result;
+  }
+
+  /**
    * Returns a readable description of all mappings for the given pdbfile to any
    * of the given sequences
    *