JAL-1741 nucleotide-aware colour schemes applied to structures
[jalview.git] / src / jalview / structures / models / AAStructureBindingModel.java
index 12be239..3602056 100644 (file)
@@ -1,17 +1,19 @@
 package jalview.structures.models;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import jalview.api.StructureSelectionManagerProvider;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.structure.AtomSpec;
 import jalview.structure.StructureListener;
 import jalview.structure.StructureSelectionManager;
+import jalview.util.Comparison;
 import jalview.util.MessageManager;
 
-import java.awt.event.ComponentEvent;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
+ * 
  * A base class to hold common function for protein structure model binding.
  * Initial version created by refactoring JMol and Chimera binding models, but
  * other structure viewers could in principle be accommodated in future.
@@ -45,6 +47,8 @@ public abstract class AAStructureBindingModel extends
 
   protected boolean colourBySequence = true;
 
+  private boolean nucleotide;
+
   /**
    * Constructor
    * 
@@ -73,6 +77,7 @@ public abstract class AAStructureBindingModel extends
   {
     this.ssm = ssm;
     this.sequence = sequenceIs;
+    this.nucleotide = Comparison.isNucleotide(sequenceIs);
     this.chains = chains;
     this.pdbEntry = pdbentry;
     this.protocol = protocol;
@@ -342,4 +347,43 @@ public abstract class AAStructureBindingModel extends
     addSequenceAndChain(pe, seq, null);
   }
 
+  /**
+   * add the given sequences to the mapping scope for the given pdb file handle
+   * 
+   * @param pdbFile
+   *          - pdbFile identifier
+   * @param seq
+   *          - set of sequences it can be mapped to
+   */
+  public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)
+  {
+    for (int pe = 0; pe < getPdbCount(); pe++)
+    {
+      if (getPdbEntry(pe).getFile().equals(pdbFile))
+      {
+        addSequence(pe, seq);
+      }
+    }
+  }
+
+  @Override
+  public void highlightAtoms(List<AtomSpec> atoms)
+  {
+    if (atoms != null)
+    {
+      for (AtomSpec atom : atoms)
+      {
+        highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(),
+                atom.getChain(), atom.getPdbFile());
+      }
+    }
+  }
+
+  protected abstract void highlightAtom(int atomIndex, int pdbResNum,
+          String chain, String pdbFile);
+
+  protected boolean isNucleotide()
+  {
+    return this.nucleotide;
+  }
 }
\ No newline at end of file