X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fschemes%2FPIDColourScheme.java;h=e1dbf4696706b9cd4b8c96bb4a6cf7f76d8a04cf;hb=681588b5dfb7e3ff34ceaccdf47f2dae6bd590ce;hp=8cea5071aa04572c3a7fb34f1d1a56137cc03c08;hpb=96786b7b949dc261a9556e13a17870166915d0e9;p=jalview.git diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index 8cea507..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 @@ -20,6 +20,7 @@ package jalview.schemes; import java.awt.*; +import jalview.analysis.*; import jalview.datamodel.*; public class PIDColourScheme @@ -35,29 +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; + Color currentColour = Color.white; double sc = 0; - if ( (Integer.parseInt(consensus[j].get("maxCount").toString()) != -1) && - consensus[j].contains(s)) + if (consensus.length <= j) { - sc = ((Float)consensus[j].get(ignoreGaps)).floatValue(); + 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(); - 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; } @@ -65,6 +84,11 @@ public class PIDColourScheme } } - return c; + if (conservationColouring) + { + currentColour = applyConservation(currentColour, j); + } + + return currentColour; } }