X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=ac003894fc10a681ccc2d2d2fba6b8432452a68a;hb=67fe33692d163752fd467468b18ace4a9b4eac7d;hp=f90f47589dbfa715e43d21a257478fc0dc1c32e6;hpb=1ecf6419aba86993b3c223bf5ec0fa79427baf85;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index f90f475..ac00389 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -1,21 +1,24 @@ package jalview.schemes; -import jalview.datamodel.*; -import jalview.jbgui.*; - import java.util.*; import java.awt.*; -public class ResidueColourScheme implements ColourSchemeI { +public class ResidueColourScheme implements ColourSchemeI{ Color [] colors; - int threshold = 90; + 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) @@ -23,31 +26,15 @@ 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) { + public Color findColour(String s, int j) { - Color c = Color.white; - String s = seq.getSequence(j,j+1); + if( threshold==0 || aboveThreshold(s,j)) + return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()]; + else + return Color.white; - if (threshold > 0 && aa != null) - { - if (aboveThreshold(aa,seq,j,threshold)) - c = findColour(seq,s,j,aa); - } - else - c = findColour(seq,s,j,aa); - - - return c; } + public int getThreshold() { return threshold; } @@ -56,51 +43,20 @@ public class ResidueColourScheme implements ColourSchemeI { threshold = ct; } - public Vector getColours(SequenceI s, Vector aa) { - Vector colours = new Vector(); - - for (int j = 0; j < s.getLength(); j++) - colours.addElement(getColour(s,j,aa)); - - return colours; - } - - public Vector getColours(SequenceGroup sg, Vector aa) { - Vector colours = new Vector(); - - for (int j = 0; j < sg.getSize(); j++) { - SequenceI s = sg.getSequenceAt(j); - - for (int i = 0; i < s.getLength();i++) { - colours.addElement(getColour(s,i,aa)); - } - } - return colours; - } - - public boolean aboveThreshold(Vector aa,SequenceI seq, int j, int threshold) { - String s = seq.getSequence(j,j+1); - Hashtable hash = (Hashtable)aa.elementAt(j); - - if (j < aa.size()) { - String maxRes = (String)hash.get("maxResidue"); + public boolean aboveThreshold(String s, int j) + { + Hashtable hash = (Hashtable)consensus.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; }