X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FResidueShader.java;h=73a5efdc71835e7e983a41b9674dbdb7efba2d8b;hb=3d4ead4880755ec949de0300c232544ba965e60d;hp=aa84816a83108d0c89aa859acd7ae8e3a214c944;hpb=991d2210e8e086bde29a90bdf21979261442d889;p=jalview.git diff --git a/src/jalview/renderer/ResidueShader.java b/src/jalview/renderer/ResidueShader.java index aa84816..73a5efd 100644 --- a/src/jalview/renderer/ResidueShader.java +++ b/src/jalview/renderer/ResidueShader.java @@ -235,6 +235,11 @@ public class ResidueShader implements ResidueShaderI @Override public Color findColour(char symbol, int position, SequenceI seq) { + if (colourScheme == null) + { + return Color.white; // Colour is 'None' + } + /* * get 'base' colour */ @@ -243,9 +248,8 @@ public class ResidueShader implements ResidueShaderI : profile.getModalResidue(); float pid = profile == null ? 0f : profile.getPercentageIdentity(ignoreGaps); - Color colour = colourScheme == null ? Color.white - : colourScheme.findColour(symbol, position, seq, modalResidue, - pid); + Color colour = colourScheme.findColour(symbol, position, seq, + modalResidue, pid); /* * apply PID threshold and consensus fading if in force @@ -258,6 +262,36 @@ public class ResidueShader implements ResidueShaderI return colour; } + @Override + public int findColourInt(char symbol, int position, SequenceI seq) + { + if (colourScheme == null) + { + return -1;// Color.white; // Colour is 'None' + } + + /* + * get 'base' colour + */ + ProfileI profile = consensus == null ? null : consensus.get(position); + String modalResidue = profile == null ? null + : profile.getModalResidue(); + float pid = profile == null ? 0f + : profile.getPercentageIdentity(ignoreGaps); + int colour = colourScheme + .findColour(symbol, position, seq, modalResidue, pid).getRGB(); + + /* + * apply PID threshold and consensus fading if in force + */ + if (!Comparison.isGap(symbol)) + { + colour = adjustColourInt(symbol, position, colour); + } + + return colour; + } + /** * Adjusts colour by applying thresholding or conservation shading, if in * force. That is @@ -289,6 +323,20 @@ public class ResidueShader implements ResidueShaderI return colour; } + protected int adjustColourInt(char symbol, int column, int colour) + { + if (!aboveThreshold(symbol, column)) + { + colour = -1;// Color.white; + } + + if (conservationColouring) + { + colour = applyConservationInt(colour, column); + } + return colour; + } + /** * Answers true if there is a consensus profile for the specified column, and * the given residue matches the consensus (or joint consensus) residue for @@ -394,6 +442,45 @@ public class ResidueShader implements ResidueShaderI return ColorUtils.bleachColour(currentColour, bleachFactor); } + protected int applyConservationInt(int currentColour, int column) + { + if (conservation == null || conservation.length <= column) + { + return currentColour; + } + char conservationScore = conservation[column]; + + /* + * if residues are fully conserved (* or 11), or all properties + * are conserved (+ or 10), leave colour unchanged + */ + if (conservationScore == '*' || conservationScore == '+' + || conservationScore == (char) 10 + || conservationScore == (char) 11) + { + return currentColour; + } + + if (Comparison.isGap(conservationScore)) + { + return -1;// Color.white; + } + + /* + * convert score 0-9 to a bleaching factor 1.1 - 0.2 + */ + float bleachFactor = (11 - (conservationScore - '0')) / 10f; + + /* + * scale this up by 0-5 (percentage slider / 20) + * as a result, scores of: 0 1 2 3 4 5 6 7 8 9 + * fade to white at slider value: 18 20 22 25 29 33 40 50 67 100% + */ + bleachFactor *= (conservationIncrement / 20f); + + return ColorUtils.bleachColourInt(currentColour, bleachFactor); + } + /** * @see jalview.renderer.ResidueShaderI#getColourScheme() */