JAL-1742 don't offer to align another chain to the same structure
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 4 Jun 2015 11:05:55 +0000 (12:05 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 4 Jun 2015 11:05:55 +0000 (12:05 +0100)
src/jalview/gui/ChimeraViewFrame.java
src/jalview/structures/models/AAStructureBindingModel.java

index fda4afb..4372617 100644 (file)
@@ -272,6 +272,14 @@ public class ChimeraViewFrame extends StructureViewerBase
     for (ChimeraViewFrame topView : existingViews)
     {
       // TODO: highlight topView in view somehow
+      /*
+       * JAL-1742 exclude view with this structure already mapped (don't offer
+       * to align chain B to chain A of the same structure)
+       */
+      if (topView.hasPdbId(pdbentry.getId()))
+      {
+        continue;
+      }
       int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
               MessageManager.formatMessage("label.add_pdbentry_to_view",
                       new Object[]
@@ -296,6 +304,11 @@ public class ChimeraViewFrame extends StructureViewerBase
     { seq });
   }
 
+  protected boolean hasPdbId(String pdbId)
+  {
+    return jmb.hasPdbId(pdbId);
+  }
+
   private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
           SequenceI[][] seqs)
   {
index 3602056..9186024 100644 (file)
@@ -104,6 +104,27 @@ public abstract class AAStructureBindingModel extends
   }
 
   /**
+   * Answers true if this binding includes the given PDB id, else false
+   * 
+   * @param pdbId
+   * @return
+   */
+  public boolean hasPdbId(String pdbId)
+  {
+    if (pdbEntry != null)
+    {
+      for (PDBEntry pdb : pdbEntry)
+      {
+        if (pdb.getId().equals(pdbId))
+        {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  /**
    * Returns the number of modelled PDB file entries.
    * 
    * @return