From 1774759f889464551c244c070b7771dabbb4bad2 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Mar 2006 15:12:26 +0000 Subject: [PATCH] Out of bounds check --- src/jalview/schemes/ClustalxColourScheme.java | 15 ++++++++++----- src/jalview/schemes/PIDColourScheme.java | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 353accf..1e38a6d 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -248,6 +248,11 @@ public class ClustalxColourScheme public Color findColour(String s, int j) { + + if(cons2.length<=j) + return currentColour; + + if ( (threshold != 0) && !aboveThreshold(s, j)) { return Color.white; @@ -262,13 +267,13 @@ public class ClustalxColourScheme return currentColour; } - for (int k = 0; k < ResidueColour[i].conses.length; k++) + for (int k = 0; k < ResidueColour[i].conses.length; k++) + { + if (ResidueColour[i].conses[k].isConserved(cons2, j, size)) { - if (ResidueColour[i].conses[k].isConserved(cons2, j, size)) - { - currentColour = ResidueColour[i].c; - } + currentColour = ResidueColour[i].c; } + } if (i == 4) { diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index 66f180b..1575a6a 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -53,24 +53,27 @@ public class PIDColourScheme double sc = 0; - if ( (Integer.parseInt(consensus[j].get("maxCount").toString()) != -1) && - consensus[j].contains(s)) - { - sc = ((Float)consensus[j].get(ignoreGaps)).floatValue(); + if(consensus.length<=j) + return Color.white; - if (!jalview.util.Comparison.isGap( res )) + if ( (Integer.parseInt(consensus[j].get("maxCount").toString()) != -1) && + consensus[j].contains(s)) { - for (int i = 0; i < thresholds.length; i++) + sc = ( (Float) consensus[j].get(ignoreGaps)).floatValue(); + + if (!jalview.util.Comparison.isGap(res)) { - if (sc > thresholds[i]) + for (int i = 0; i < thresholds.length; i++) { - currentColour = pidColours[i]; + if (sc > thresholds[i]) + { + currentColour = pidColours[i]; - break; + break; + } } } } - } if(conservationColouring) applyConservation(j); -- 1.7.10.2