X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fschemes%2FPIDColourScheme.java;h=e1dbf4696706b9cd4b8c96bb4a6cf7f76d8a04cf;hb=1a0f6886ffdb431de180af2089db4910a1dfb564;hp=cfc9f9472139dde27c2e9e215d87208813234b17;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index cfc9f94..e1dbf46 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,10 +18,9 @@ */ package jalview.schemes; -import java.util.*; - import java.awt.*; +import jalview.analysis.*; import jalview.datamodel.*; public class PIDColourScheme @@ -37,33 +36,47 @@ public class PIDColourScheme this.thresholds = ResidueProperties.pidThresholds; } - public Color findColour(String s, int j) + public Color findColour(char c, int j) { - if ( (threshold != 0) && !aboveThreshold(s, j)) + if ('a' <= c && c <= 'z') + { + c -= ('a' - 'A'); + } + + if (consensus == null + || j >= consensus.length + || consensus[j] == null) + { + return Color.white; + } + + if ( (threshold != 0) && !aboveThreshold(c, j)) { return Color.white; } - Color c = Color.white; - Hashtable hash = (Hashtable) consensus.elementAt(j); + Color currentColour = Color.white; double sc = 0; - if ( (Integer.parseInt(hash.get("maxCount").toString()) != -1) && - hash.contains(s)) + if (consensus.length <= j) { - sc = ( ( (Integer) hash.get(s)).intValue() * 100.0) / - ( (Integer) hash.get( - "size")).intValue(); + return Color.white; + } + + if ( (Integer.parseInt(consensus[j].get(AAFrequency.MAXCOUNT).toString()) != + -1) && + consensus[j].contains(String.valueOf(c))) + { + sc = ( (Float) consensus[j].get(ignoreGaps)).floatValue(); - // MC Should be isGap - if (!jalview.util.Comparison.isGap( (s.charAt(0)))) + if (!jalview.util.Comparison.isGap(c)) { for (int i = 0; i < thresholds.length; i++) { if (sc > thresholds[i]) { - c = pidColours[i]; + currentColour = pidColours[i]; break; } @@ -71,6 +84,11 @@ public class PIDColourScheme } } - return c; + if (conservationColouring) + { + currentColour = applyConservation(currentColour, j); + } + + return currentColour; } }