JAL-2938 update colour schemes enum for class name changes
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 23 Mar 2018 12:15:49 +0000 (12:15 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 23 Mar 2018 12:15:49 +0000 (12:15 +0000)
src/jalview/schemes/HmmerColourScheme.java
src/jalview/schemes/HmmerGlobalBackground.java
src/jalview/schemes/JalviewColourScheme.java
src/jalview/schemes/ResidueProperties.java

index 011c071..d31f0e1 100644 (file)
@@ -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;
   }
 
index 76d77ab..e1d00bb 100644 (file)
@@ -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));
   }
 
   /**
index 57ff88d..357ea03 100644 (file)
@@ -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)
 
index 60fd25c..9b0489e 100755 (executable)
@@ -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);
 
   }