getColour added to structures
authoramwaterhouse <Andrew Waterhouse>
Mon, 23 Apr 2007 11:50:12 +0000 (11:50 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 23 Apr 2007 11:50:12 +0000 (11:50 +0000)
src/jalview/structure/StructureListener.java
src/jalview/structure/StructureSelectionManager.java

index 0d7819e..5436eae 100644 (file)
@@ -27,4 +27,6 @@ public interface StructureListener
   public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbId);\r
 \r
   public void updateColours(Object source);\r
+\r
+  public java.awt.Color getColour(int atomIndex, int pdbResNum, String chain, String pdbId);\r
 }\r
index 0a3db6d..c0ab6f9 100644 (file)
@@ -69,7 +69,7 @@ public class StructureSelectionManager
      There will be better ways of doing this in the future, for now we'll use
      the tried and tested MCview pdb mapping
    */
-  public MCview.PDBfile setMapping(SequenceI[] sequence,
+  synchronized public MCview.PDBfile setMapping(SequenceI[] sequence,
                            String pdbFile,
                            String protocol)
   {
@@ -283,6 +283,59 @@ public class StructureSelectionManager
     }
   }
 
+  public Annotation[] colourSequenceFromStructure(SequenceI seq, String pdbid)
+  {
+    Annotation [] annotations = new Annotation[seq.getLength()];
+
+    StructureListener sl;
+    int atomNo = 0;
+    for (int i = 0; i < listeners.size(); i++)
+    {
+      if (listeners.elementAt(i) instanceof StructureListener)
+      {
+        sl = (StructureListener) listeners.elementAt(i);
+
+        for (int j = 0; j < mappings.length; j++)
+        {
+
+          if (mappings[j].sequence == seq
+              && mappings[j].getPdbId().equals(pdbid)
+              && mappings[j].pdbfile.equals(sl.getPdbFile()))
+          {
+            System.out.println(pdbid+" "+mappings[j].getPdbId()
+                +" "+mappings[j].pdbfile);
+
+            java.awt.Color col;
+            for(int index=0; index<seq.getLength(); index++)
+            {
+              if(jalview.util.Comparison.isGap(seq.getCharAt(index)))
+                continue;
+
+              atomNo = mappings[j].getAtomNum(seq.findPosition(index));
+              col = java.awt.Color.white;
+              if (atomNo > 0)
+              {
+                col = sl.getColour(atomNo,
+                                 mappings[j].getPDBResNum(index),
+                                 mappings[j].pdbchain,
+                                 mappings[j].pdbfile);
+
+            //    System.out.println(atomNo+" "+mappings[j].getPDBResNum(index)
+            //                     +" "+index+" "+col);
+              }
+
+              annotations[index] = new Annotation("X",null,' ',0,col);
+            }
+            return annotations;
+          }
+        }
+      }
+    }
+
+    return annotations;
+  }
+
+
   public void structureSelectionChanged()
   {
     StructureListener svl;