JAL-1743 View Chain sub-menu now being populated
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 4 Jun 2015 13:01:27 +0000 (14:01 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 4 Jun 2015 13:01:27 +0000 (14:01 +0100)
src/jalview/gui/ChimeraViewFrame.java

index fdc7d0b..a803c40 100644 (file)
@@ -328,8 +328,10 @@ public class ChimeraViewFrame extends StructureViewerBase
   {
     createProgressBar();
 
+    String[][] chains = extractChains(seqs);
     jmb = new JalviewChimeraBindingModel(this,
-            ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
+            ap.getStructureSelectionManager(), pdbentrys, seqs, chains,
+            null);
     addAlignmentPanel(ap);
     useAlignmentPanelForColourbyseq(ap);
     if (pdbentrys.length > 1)
@@ -356,6 +358,38 @@ public class ChimeraViewFrame extends StructureViewerBase
   }
 
   /**
+   * Retrieve chains for sequences by inspecting their PDB refs. The hope is
+   * that the first will be to the sequence's own chain. Really need a more
+   * managed way of doing this.
+   * 
+   * @param seqs
+   * @return
+   */
+  protected String[][] extractChains(SequenceI[][] seqs)
+  {
+    String[][] chains = new String[seqs.length][];
+    for (int i = 0; i < seqs.length; i++)
+    {
+      chains[i] = new String[seqs[i].length];
+      int seqno = 0;
+      for (SequenceI seq : seqs[i])
+      {
+        String chain = null;
+        if (seq.getDatasetSequence() != null)
+        {
+          Vector<PDBEntry> pdbrefs = seq.getDatasetSequence().getPDBId();
+          if (pdbrefs != null && pdbrefs.size() > 0)
+          {
+            chain = pdbrefs.get(0).getChainCode();
+          }
+        }
+        chains[i][seqno++] = chain;
+      }
+    }
+    return chains;
+  }
+
+  /**
    * create a new viewer containing several structures superimposed using the
    * given alignPanel.
    *