- if ('a' <= residue && residue <= 'z')
- {
- // TO UPPERCASE !!!
- // Faster than toUpperCase
- residue -= ('a' - 'A');
- }
-
- if (consensus == null)
- {
- return false;
- }
-
- ProfileI profile = consensus.get(column);
-
- /*
- * test whether this is the consensus (or joint consensus) residue
- */
- if (profile != null
- && profile.getModalResidue().contains(String.valueOf(residue)))
- {
- if (profile.getPercentageIdentity(ignoreGaps) >= threshold)
- {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean conservationApplied()
- {
- return conservationColouring;
- }
-
- @Override
- public void setConservationApplied(boolean conservationApplied)
- {
- conservationColouring = conservationApplied;
- }
-
- @Override
- public void setConservationInc(int i)
- {
- inc = i;
- }
-
- @Override
- public int getConservationInc()
- {
- return inc;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param consensus
- * DOCUMENT ME!
- */
- @Override
- public void setConsensus(ProfilesI consensus)
- {
- if (consensus == null)
- {
- return;
- }
-
- this.consensus = consensus;
- }
-
- @Override
- public void setConservation(Conservation cons)
- {
- if (cons == null)
- {
- conservationColouring = false;
- conservation = null;
- }
- else
- {
- conservationColouring = true;
- int iSize = cons.getConsSequence().getLength();
- conservation = new char[iSize];
- for (int i = 0; i < iSize; i++)
- {
- conservation[i] = cons.getConsSequence().getCharAt(i);
- }
- }
-
- }
-
- /**
- * Applies a combination of column conservation score, and conservation
- * percentage slider, to 'bleach' out the residue colours towards white.
- * <p>
- * If a column is fully conserved (identical residues, conservation score 11,
- * shown as *), or all 10 physico-chemical properties are conserved
- * (conservation score 10, shown as +), then the colour is left unchanged.
- * <p>
- * Otherwise a 'bleaching' factor is computed and applied to the colour. This
- * is designed to fade colours for scores of 0-9 completely to white at slider
- * positions ranging from 18% - 100% respectively.
- *
- * @param currentColour
- * @param column
- *
- * @return bleached (or unmodified) colour
- */
- Color applyConservation(Color 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 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 *= (inc / 20f);
-
- return ColorUtils.bleachColour(currentColour, bleachFactor);