From d4505fe7ead8da6d4fdf7e0b4680f66b3a408e87 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 15 Dec 2004 17:26:47 +0000 Subject: [PATCH 1/1] isGap method implemented in utils, and optimized --- src/jalview/schemes/PIDColourScheme.java | 8 ++-- src/jalview/schemes/ResidueColourScheme.java | 59 ++++++++------------------ 2 files changed, 20 insertions(+), 47 deletions(-) diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index e587fee..cc050d5 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -16,7 +16,7 @@ public class PIDColourScheme extends ResidueColourScheme { } - public Color findColour(SequenceI seq,String s, int j,Vector aa) { + public Color findColour(String s, int j,Vector aa) { Color c = Color.white; Hashtable hash = null; @@ -31,10 +31,9 @@ public class PIDColourScheme extends ResidueColourScheme { double sc = 0; if ( Integer.parseInt( hash.get("maxCount").toString() ) != -1 && hash.contains(s)) { - sc = ( (Integer) hash.get(s)).intValue() * 100.0 / ((Integer)hash.get("size")).intValue() ; // MC Should be isGap - if (!s.equals("-") && !s.equals(".") && !s.equals(" ")) + if (!jalview.util.Comparison.isGap((s.charAt(0)))) { for (int i = 0; i < thresholds.length; i++) { @@ -45,8 +44,7 @@ public class PIDColourScheme extends ResidueColourScheme { } } } - else - c = Color.white; + } return c; } diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index f16bcca..b0a5caa 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -6,7 +6,7 @@ import java.awt.*; public class ResidueColourScheme implements ColourSchemeI{ Color [] colors; - int threshold = 90; + int threshold = 0; public ResidueColourScheme(Color[] colors, int threshold) { this.colors = colors; @@ -21,31 +21,14 @@ public class ResidueColourScheme implements ColourSchemeI{ return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()]; } - public Color findColour(SequenceI seq,String s, int j, Vector aa) { - try { - return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()]; - } catch (Exception e) { - return Color.white; - } - } - - // aa should maybe be a class - /* public Color getColour(SequenceI seq, int j,Vector aa) { - - Color c = Color.white; - String s = seq.getSequence(j,j+1); - - if (threshold > 0 && aa != null) - { - if (aboveThreshold(aa,seq,j,threshold)) - c = findColour(seq,s,j,aa); - } - else - c = findColour(seq,s,j,aa); + public Color findColour(String s, int j, Vector aa) { + if( threshold==0 || aboveThreshold(aa,s,j)) + return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()]; + else + return Color.white; - return c; - }*/ + } public int getThreshold() { return threshold; @@ -55,29 +38,21 @@ public class ResidueColourScheme implements ColourSchemeI{ threshold = ct; } - public boolean aboveThreshold(Vector aa,SequenceI seq, int j, int threshold) { - String s = seq.getSequence(j,j+1); - Hashtable hash = (Hashtable)aa.elementAt(j); + public boolean aboveThreshold(Vector aa,String s, int j) + { - if (j < aa.size()) { - String maxRes = (String)hash.get("maxResidue"); + Hashtable hash = (Hashtable)aa.elementAt(j); - double sc = 0; + if ( ( (Integer) hash.get("maxCount")).intValue() != -1 && hash.contains(s)) + { + //// resCount//////////////////// ///////////////seq count//////////// + double sc = ( (Integer) hash.get(s)).intValue() * 100.0 / ( (Integer) hash.get("size")).intValue(); - if (((Integer)hash.get("maxCount")).intValue() != -1 && hash.contains(s)) { - int maxCount = ((Integer)hash.get("maxCount")).intValue(); - int resCount = ((Integer)hash.get(s)).intValue(); + if (sc >= threshold) + return true; - sc = resCount * 100.0 / resCount; + } - // This should be isGap somewhere - if ( !s.equals("-") && !s.equals(".") && !s.equals(" ")) { - if (sc >= (double)threshold) { - return true; - } - } - } - } return false; } -- 1.7.10.2