JAL-891; base-pair logos can now be activated for structure
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index d1bccd8..880f72a 100644 (file)
@@ -152,16 +152,32 @@ public class StructureSelectionManager
       ex.printStackTrace();
       return null;
     }
-
+    
     String targetChain;
     for (int s = 0; s < sequence.length; s++)
     {
+      boolean infChain = true;
       if (targetChains != null && targetChains[s] != null)
+      {
+        infChain = false;
         targetChain = targetChains[s];
+      }
       else if (sequence[s].getName().indexOf("|") > -1)
       {
         targetChain = sequence[s].getName().substring(
                 sequence[s].getName().lastIndexOf("|") + 1);
+        if (targetChain.length() > 1)
+        {
+          if (targetChain.trim().length() == 0)
+          {
+            targetChain = " ";
+          }
+          else
+          {
+            // not a valid chain identifier
+            targetChain = "";
+          }
+        }
       }
       else
         targetChain = "";
@@ -173,14 +189,11 @@ public class StructureSelectionManager
       boolean first = true;
       for (int i = 0; i < pdb.chains.size(); i++)
       {
-        // TODO: re http://issues.jalview.org/browse/JAL-583 : this patch may
-        // need to be revoked
         PDBChain chain = ((PDBChain) pdb.chains.elementAt(i));
-        if (targetChain.length() > 0 && !targetChain.equals(chain.id))
+        if (targetChain.length() > 0 && !targetChain.equals(chain.id) && !infChain)
         {
           continue; // don't try to map chains don't match.
         }
-        // end of patch for limiting computed mappings
         // TODO: correctly determine sequence type for mixed na/peptide
         // structures
         AlignSeq as = new AlignSeq(sequence[s],
@@ -336,6 +349,11 @@ public class StructureSelectionManager
 
   public void mouseOverStructure(int pdbResNum, String chain, String pdbfile)
   {
+    if (listeners==null)
+    {
+      // old or prematurely sent event
+      return;
+    }
     boolean hasSequenceListeners = handlingVamsasMo || seqmappings != null;
     SearchResults results = null;
     SequenceI lastseq = null;
@@ -491,6 +509,9 @@ public class StructureSelectionManager
           ((VamsasListener) listeners.elementAt(i)).mouseOver(seq,
                   indexpos, source);
         }
+        else if(listeners.elementAt(i) instanceof SecondaryStructureListener){
+               ((SecondaryStructureListener) listeners.elementAt(i)).mouseOverSequence(seq,indexpos);
+        }
       }
     }
   }