From ac4bbf6dd2bfccdaae9067fb4765c73600dea729 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 15 Apr 2005 15:06:50 +0000 Subject: [PATCH] consensus held in residueColour --- src/jalview/schemes/Blosum62ColourScheme.java | 17 ++------ src/jalview/schemes/ClustalxColourScheme.java | 6 ++- src/jalview/schemes/ColourSchemeI.java | 3 +- src/jalview/schemes/ConservationColourScheme.java | 44 ++++++++++----------- src/jalview/schemes/NucleotideColourScheme.java | 4 +- src/jalview/schemes/PIDColourScheme.java | 12 +----- src/jalview/schemes/ResidueColourScheme.java | 19 +++++---- src/jalview/schemes/ScoreColourScheme.java | 4 +- 8 files changed, 49 insertions(+), 60 deletions(-) diff --git a/src/jalview/schemes/Blosum62ColourScheme.java b/src/jalview/schemes/Blosum62ColourScheme.java index 6c83920..2e18c6a 100755 --- a/src/jalview/schemes/Blosum62ColourScheme.java +++ b/src/jalview/schemes/Blosum62ColourScheme.java @@ -27,23 +27,14 @@ import jalview.datamodel.*; public class Blosum62ColourScheme extends ResidueColourScheme { - // need to keep an eye on the changing visible consensus sequence - AlignViewport av; - - public Blosum62ColourScheme(AlignViewport av) + public Blosum62ColourScheme() { super(); - this.av = av; } - public Color findColour(String s, int j, Vector aa) + public Color findColour(String s, int j) { - Hashtable hash; - - if (aa != null) - hash = (Hashtable)aa.elementAt(j); - else - return Color.white; + Hashtable hash = (Hashtable)consensus.elementAt(j); if (!jalview.util.Comparison.isGap((s.charAt(0)))) { @@ -73,7 +64,7 @@ public class Blosum62ColourScheme extends ResidueColourScheme public boolean canThreshold() { - return false; + return true; } } diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 2e4678e..06b62c6 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -225,7 +225,7 @@ public class ClustalxColourScheme implements ColourSchemeI size = i; } - public Color findColour(String s, int j, Vector seqs) + public Color findColour(String s, int j) { int i = ((Integer)ResidueProperties.aaHash.get(s)).intValue(); @@ -249,6 +249,10 @@ public class ClustalxColourScheme implements ColourSchemeI } + public void setConsensus(Vector consensus) + { + // Clustal colouring cannot be coloured by PID + } public boolean canThreshold() { diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index d82e5f5..fcdaa45 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -7,7 +7,8 @@ import java.util.*; public interface ColourSchemeI { public Color findColour(String aa); - public Color findColour(String s,int j, Vector aa); + public Color findColour(String s,int j); public boolean canThreshold(); public boolean isUserDefinable(); + public void setConsensus(Vector v); } diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java index cef65c2..d418b4f 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -26,48 +26,44 @@ public class ConservationColourScheme extends ResidueColourScheme { public Conservation conserve; public ColourSchemeI cs; public int inc = 30; - int colourThreshold = 7; public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) { super(); conserve = cons; cs = oldcs; - } - public Color findColour(String s, int i, java.util.Vector v) + public Color findColour(String s, int i) { Color c = Color.white; - if(cs == null) + if (cs == null) return c; - if (colourThreshold > 0 && conserve.getConsSequence() != null) + char ch = conserve.getConsSequence().getSequence().charAt(i); + if (ch == '*' || ch == '+') + { + c = cs.findColour(s, i); + } + else { - if (conserve.getConsSequence().getSequence().charAt(i) == '*' - || conserve.getConsSequence().getSequence().charAt(i) == '+') + int tmp = 10; + int t = 0; + if (!jalview.util.Comparison.isGap(ch)) + t = Integer.parseInt(ch + ""); + + c = cs.findColour(s, i); + + while (tmp >= t) { - c = cs.findColour(s, i, v); + c = lighter(c, inc); + tmp--; } - else - { - int tmp = 10; - int t = 0; - if (!jalview.util.Comparison.isGap(conserve.getConsSequence(). - getSequence().charAt(i))) - t = Integer.parseInt(conserve.getConsSequence().getSequence(). - substring(i, i + 1)); - c = cs.findColour(s, i, v); - while (tmp >= t) - { - c = lighter(c, inc); - tmp--; - } - } } - return c; + + return c; } diff --git a/src/jalview/schemes/NucleotideColourScheme.java b/src/jalview/schemes/NucleotideColourScheme.java index caa6998..26aea21 100755 --- a/src/jalview/schemes/NucleotideColourScheme.java +++ b/src/jalview/schemes/NucleotideColourScheme.java @@ -18,9 +18,9 @@ public class NucleotideColourScheme extends ResidueColourScheme } - public Color findColour(String n, int j, Vector aa) { + public Color findColour(String n, int j) { - if (threshold == 0 || aboveThreshold(aa, n, j)) + if (threshold == 0 || aboveThreshold( n, j)) try { return colors[ ( (Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()]; diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index cc050d5..916887e 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -16,17 +16,9 @@ public class PIDColourScheme extends ResidueColourScheme { } - public Color findColour(String s, int j,Vector aa) { + public Color findColour(String s, int j) { Color c = Color.white; - Hashtable hash = null; - - - if (aa != null) - hash = (Hashtable)aa.elementAt(j); - else - return c; - - String max = (String)hash.get("maxResidue"); + Hashtable hash = (Hashtable)consensus.elementAt(j); double sc = 0; if ( Integer.parseInt( hash.get("maxCount").toString() ) != -1 && hash.contains(s)) diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index b0a5caa..7eab3dd 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -7,13 +7,19 @@ import java.awt.*; public class ResidueColourScheme implements ColourSchemeI{ Color [] colors; int threshold = 0; + public Vector consensus; public ResidueColourScheme(Color[] colors, int threshold) { - this.colors = colors; + this.colors = colors; this.threshold = threshold; } - public ResidueColourScheme() { + public ResidueColourScheme() + { } + + public void setConsensus(Vector consensus) + { + this.consensus = consensus; } public Color findColour(String aa) @@ -21,9 +27,9 @@ public class ResidueColourScheme implements ColourSchemeI{ return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()]; } - public Color findColour(String s, int j, Vector aa) { + public Color findColour(String s, int j) { - if( threshold==0 || aboveThreshold(aa,s,j)) + if( threshold==0 || aboveThreshold(s,j)) return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()]; else return Color.white; @@ -38,10 +44,9 @@ public class ResidueColourScheme implements ColourSchemeI{ threshold = ct; } - public boolean aboveThreshold(Vector aa,String s, int j) + public boolean aboveThreshold(String s, int j) { - - Hashtable hash = (Hashtable)aa.elementAt(j); + Hashtable hash = (Hashtable)consensus.elementAt(j); if ( ( (Integer) hash.get("maxCount")).intValue() != -1 && hash.contains(s)) { diff --git a/src/jalview/schemes/ScoreColourScheme.java b/src/jalview/schemes/ScoreColourScheme.java index 225f8dd..b62ca18 100755 --- a/src/jalview/schemes/ScoreColourScheme.java +++ b/src/jalview/schemes/ScoreColourScheme.java @@ -23,12 +23,12 @@ public class ScoreColourScheme extends ResidueColourScheme { } - public Color findColour(String s,int j,Vector aa) + public Color findColour(String s,int j) { if (threshold > 0) { - if (!aboveThreshold(aa,s,j)) + if (!aboveThreshold(s,j)) return Color.white; } -- 1.7.10.2