From: gmungoc Date: Fri, 23 Mar 2018 12:15:49 +0000 (+0000) Subject: JAL-2938 update colour schemes enum for class name changes X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=787c729c03ee03aa76de75ccea53afb22e4c5927;p=jalview.git JAL-2938 update colour schemes enum for class name changes --- diff --git a/src/jalview/schemes/HmmerColourScheme.java b/src/jalview/schemes/HmmerColourScheme.java index 011c071..d31f0e1 100644 --- a/src/jalview/schemes/HmmerColourScheme.java +++ b/src/jalview/schemes/HmmerColourScheme.java @@ -87,7 +87,9 @@ public abstract class HmmerColourScheme extends ResidueColourScheme symbol = Character.toUpperCase(symbol); } - double prob = getHmm().getMatchEmissionProbability(column, symbol); + final double prob = getHmm().getMatchEmissionProbability(column, + symbol); + Float freq = 0f; if (!frequencies.containsKey(symbol)) @@ -104,15 +106,13 @@ public abstract class HmmerColourScheme extends ResidueColourScheme } double value = Math.log(prob / freq.floatValue()); Color colour = null; - if (value > 0) - { - colour = ColorUtils.getGraduatedColour((float) value, 0, - Color.WHITE, getMaxInformationScore(), Color.blue); - } - else if (value < 0) + if (value < 0) { return Color.ORANGE; } + + colour = ColorUtils.getGraduatedColour((float) value, 0, Color.WHITE, + getMaxInformationScore(), Color.blue); return colour; } diff --git a/src/jalview/schemes/HmmerGlobalBackground.java b/src/jalview/schemes/HmmerGlobalBackground.java index 76d77ab..e1d00bb 100644 --- a/src/jalview/schemes/HmmerGlobalBackground.java +++ b/src/jalview/schemes/HmmerGlobalBackground.java @@ -26,8 +26,10 @@ public class HmmerGlobalBackground extends HmmerColourScheme public HmmerGlobalBackground(HiddenMarkovModel markov) { super(markov); - setFrequencies(ResidueProperties.backgroundFrequencies - .get(getHmm().getAlphabetType())); + String alphabetType = markov == null ? ResidueProperties.ALPHABET_AMINO + : markov.getAlphabetType(); + setFrequencies( + ResidueProperties.backgroundFrequencies.get(alphabetType)); } /** diff --git a/src/jalview/schemes/JalviewColourScheme.java b/src/jalview/schemes/JalviewColourScheme.java index 57ff88d..357ea03 100644 --- a/src/jalview/schemes/JalviewColourScheme.java +++ b/src/jalview/schemes/JalviewColourScheme.java @@ -43,7 +43,7 @@ public enum JalviewColourScheme PurinePyrimidine("Purine/Pyrimidine", PurinePyrimidineColourScheme.class), RNAHelices("RNA Helices", RNAHelicesColour.class), TCoffee("T-Coffee Scores", TCoffeeColourScheme.class), - HMMERU("HMMER-Uniprot", HmmerColourScheme.class), + HMMERU("HMMER-Uniprot", HmmerGlobalBackground.class), HMMERA("HMMER-Alignment", HmmerLocalBackground.class); // RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class) diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 60fd25c..9b0489e 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -32,6 +32,13 @@ import java.util.Vector; public class ResidueProperties { + // alphabet names used in Hidden Markov Model files + public static final String ALPHABET_RNA = "RNA"; + + public static final String ALPHABET_DNA = "DNA"; + + public static final String ALPHABET_AMINO = "amino"; + // Stores residue codes/names and colours and other things public static final int[] aaIndex; // aaHash version 2.1.1 and below @@ -2543,7 +2550,7 @@ public class ResidueProperties amino.put('I', 0.0593f); amino.put('P', 0.0472f); amino.put('V', 0.0686f); - backgroundFrequencies.put("amino", amino); + backgroundFrequencies.put(ALPHABET_AMINO, amino); // todo: these don't match https://www.ebi.ac.uk/uniprot/TrEMBLstats - what // are they? } @@ -2557,7 +2564,7 @@ public class ResidueProperties dna.put('C', 0.25f); dna.put('T', 0.25f); dna.put('G', 0.25f); - backgroundFrequencies.put("DNA", dna); + backgroundFrequencies.put(ALPHABET_DNA, dna); } @@ -2568,7 +2575,7 @@ public class ResidueProperties rna.put('C', 0.25f); rna.put('T', 0.25f); rna.put('G', 0.25f); - backgroundFrequencies.put("RNA", rna); + backgroundFrequencies.put(ALPHABET_RNA, rna); }