JAL-1065 JAL-1066 allow different lookup tables for nucleotide or amino acid coloursc...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 29 Jun 2012 15:18:41 +0000 (16:18 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 29 Jun 2012 15:18:41 +0000 (16:18 +0100)
src/jalview/schemes/BuriedColourScheme.java
src/jalview/schemes/HelixColourScheme.java
src/jalview/schemes/HydrophobicColourScheme.java
src/jalview/schemes/NucleotideColourScheme.java
src/jalview/schemes/PurinePyrimidineColourScheme.java
src/jalview/schemes/ResidueColourScheme.java
src/jalview/schemes/ScoreColourScheme.java
src/jalview/schemes/StrandColourScheme.java
src/jalview/schemes/TaylorColourScheme.java
src/jalview/schemes/TurnColourScheme.java
src/jalview/schemes/ZappoColourScheme.java

index 6ccdef5..7ac6546 100755 (executable)
@@ -32,7 +32,7 @@ public class BuriedColourScheme extends ScoreColourScheme
    */
   public BuriedColourScheme()
   {
-    super(ResidueProperties.buried, ResidueProperties.buriedmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.buried, ResidueProperties.buriedmin,
             ResidueProperties.buriedmax);
   }
 
index ca2bb61..3683b80 100755 (executable)
@@ -23,7 +23,7 @@ public class HelixColourScheme extends ScoreColourScheme
 {
   public HelixColourScheme()
   {
-    super(ResidueProperties.helix, ResidueProperties.helixmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.helix, ResidueProperties.helixmin,
             ResidueProperties.helixmax);
   }
 
index 4dd05c1..0cb365f 100755 (executable)
@@ -32,7 +32,7 @@ public class HydrophobicColourScheme extends ScoreColourScheme
    */
   public HydrophobicColourScheme()
   {
-    super(ResidueProperties.hyd, ResidueProperties.hydmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.hyd, ResidueProperties.hydmin,
             ResidueProperties.hydmax);
   }
 
index 2c63ddb..78d34e2 100755 (executable)
@@ -34,7 +34,7 @@ public class NucleotideColourScheme extends ResidueColourScheme
    */
   public NucleotideColourScheme()
   {
-    super(ResidueProperties.nucleotide, 0);
+    super(ResidueProperties.nucleotideIndex, ResidueProperties.nucleotide, 0);
   }
 
   /**
index 0498536..7720220 100644 (file)
@@ -31,7 +31,7 @@ public class PurinePyrimidineColourScheme extends ResidueColourScheme
    */
   public PurinePyrimidineColourScheme()
   {
-    super(ResidueProperties.purinepyrimidine, 0);
+    super(ResidueProperties.purinepyrimidineIndex, ResidueProperties.purinepyrimidine, 0);
   }
 
   /**
index bbba865..666834e 100755 (executable)
@@ -35,7 +35,7 @@ import java.util.Map;
  */
 public class ResidueColourScheme implements ColourSchemeI
 {
-
+  final int[] symbolIndex;
   boolean conservationColouring = false;
 
   Color[] colors = null;
@@ -58,23 +58,32 @@ public class ResidueColourScheme implements ColourSchemeI
 
   /**
    * Creates a new ResidueColourScheme object.
-   * 
+   * @param final int[] index table into colors (ResidueProperties.naIndex or ResidueProperties.aaIndex)
    * @param colors
-   *          DOCUMENT ME!
+   *          colours for symbols in sequences
    * @param threshold
-   *          DOCUMENT ME!
+   *          threshold for conservation shading
    */
-  public ResidueColourScheme(Color[] colours, int threshold)
+  public ResidueColourScheme(int[] aaOrnaIndex, Color[] colours, int threshold)
   {
+    symbolIndex = aaOrnaIndex;
     this.colors = colours;
     this.threshold = threshold;
   }
 
   /**
-   * Creates a new ResidueColourScheme object.
+   * Creates a new ResidueColourScheme object with a lookup table for indexing the colour map
+   */
+  public ResidueColourScheme(int[] aaOrNaIndex)
+  {
+    symbolIndex = aaOrNaIndex;
+  }
+  /**
+   * Creates a new ResidueColourScheme object - default constructor for non-sequence dependent colourschemes
    */
   public ResidueColourScheme()
   {
+    symbolIndex = null;
   }
 
   /**
@@ -83,7 +92,7 @@ public class ResidueColourScheme implements ColourSchemeI
   public Color findColour(char c)
   {
     return colors == null ? Color.white
-            : colors[ResidueProperties.aaIndex[c]];
+            : colors[symbolIndex[c]];
   }
 
   @Override
@@ -91,9 +100,9 @@ public class ResidueColourScheme implements ColourSchemeI
   {
     Color currentColour;
 
-    if ((threshold == 0) || aboveThreshold(c, j))
+    if (colors!=null && symbolIndex!=null && (threshold == 0) || aboveThreshold(c, j))
     {
-      currentColour = colors[ResidueProperties.aaIndex[c]];
+      currentColour = colors[symbolIndex[c]];
     }
     else
     {
index 116bbd8..d11a2e8 100755 (executable)
@@ -48,9 +48,9 @@ public class ScoreColourScheme extends ResidueColourScheme
    * @param max
    *          DOCUMENT ME!
    */
-  public ScoreColourScheme(double[] scores, double min, double max)
+  public ScoreColourScheme(int symbolIndex[], double[] scores, double min, double max)
   {
-    super();
+    super(symbolIndex);
 
     this.scores = scores;
     this.min = min;
index ef88c38..69c2f1c 100755 (executable)
@@ -32,7 +32,7 @@ public class StrandColourScheme extends ScoreColourScheme
    */
   public StrandColourScheme()
   {
-    super(ResidueProperties.strand, ResidueProperties.strandmin,
+    super(ResidueProperties.aaIndex, ResidueProperties.strand, ResidueProperties.strandmin,
             ResidueProperties.strandmax);
   }
 
index ceee169..316c828 100755 (executable)
@@ -21,6 +21,6 @@ public class TaylorColourScheme extends ResidueColourScheme
 {
   public TaylorColourScheme()
   {
-    super(ResidueProperties.taylor, 0);
+    super(ResidueProperties.aaIndex, ResidueProperties.taylor, 0);
   }
 }
index a2c1eda..cd5cd3f 100755 (executable)
@@ -32,7 +32,7 @@ public class TurnColourScheme extends ScoreColourScheme
    */
   public TurnColourScheme()
   {
-    super(ResidueProperties.turn, ResidueProperties.turnmin,
+    super(ResidueProperties.aaIndex,ResidueProperties.turn, ResidueProperties.turnmin,
             ResidueProperties.turnmax);
   }
 
index c6dffe5..c578fe3 100755 (executable)
@@ -30,6 +30,6 @@ public class ZappoColourScheme extends ResidueColourScheme
    */
   public ZappoColourScheme()
   {
-    super(ResidueProperties.zappo, 0);
+    super(ResidueProperties.aaIndex,  ResidueProperties.zappo, 0);
   }
 }