JAL-3481 Added preference keys for the Conservation THRESHOLD_PERCENT and CONSERVATIO... feature/JAL-3481_conservation_gap_threshold_preferences
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 30 Mar 2023 11:09:01 +0000 (12:09 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Thu, 30 Mar 2023 11:09:01 +0000 (12:09 +0100)
src/jalview/analysis/Conservation.java
src/jalview/viewmodel/AlignmentViewport.java

index cbc4dca..158624d 100755 (executable)
  */
 package jalview.analysis;
 
+import java.awt.Color;
+import java.util.List;
 import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Vector;
 
 import jalview.analysis.scoremodels.ScoreMatrix;
 import jalview.analysis.scoremodels.ScoreModels;
+import jalview.bin.Cache;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ResidueCount;
@@ -34,14 +42,6 @@ import jalview.schemes.ResidueProperties;
 import jalview.util.Comparison;
 import jalview.util.Format;
 
-import java.awt.Color;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.Vector;
-
 /**
  * Calculates conservation values for a given set of sequences
  */
@@ -53,6 +53,10 @@ public class Conservation
    */
   private static final int THRESHOLD_PERCENT = 3;
 
+  public static final String THRESHOLD_PERCENT_PREFERENCE = "CONSERVATION_THRESHOLD_PERCENT";
+
+  public static final String CONSERVATION_GAP_PERCENT_PREFERENCE = "CONSERVATION_GAP_PERCENT";
+
   private static final int TOUPPERCASE = 'a' - 'A';
 
   private static final int GAP_INDEX = -1;
@@ -130,7 +134,8 @@ public class Conservation
   public Conservation(String name, List<SequenceI> sequences, int start,
           int end)
   {
-    this(name, THRESHOLD_PERCENT, sequences, start, end);
+    this(name, Cache.getDefault(THRESHOLD_PERCENT_PREFERENCE,
+            THRESHOLD_PERCENT), sequences, start, end);
   }
 
   /**
@@ -263,16 +268,15 @@ public class Conservation
 
     total = new Map[maxLength];
 
+    /*
+     * percentage count at or below which we ignore residues
+     */
+    int thresh = (threshold * height) / 100;
     for (int column = start; column <= end; column++)
     {
       ResidueCount values = countResidues(column);
 
       /*
-       * percentage count at or below which we ignore residues
-       */
-      int thresh = (threshold * height) / 100;
-
-      /*
        * check observed residues in column and record whether each 
        * physico-chemical property is conserved (+1), absence conserved (0),
        * or not conserved (-1)
index a42a2a4..9756442 100644 (file)
@@ -41,6 +41,7 @@ import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeaturesDisplayedI;
 import jalview.api.ViewStyleI;
+import jalview.bin.Cache;
 import jalview.bin.Console;
 import jalview.commands.CommandI;
 import jalview.datamodel.AlignedCodonFrame;
@@ -744,7 +745,8 @@ public abstract class AlignmentViewport
   @Override
   public int getConsPercGaps()
   {
-    return ConsPercGaps;
+    return Cache.getDefault(
+            Conservation.CONSERVATION_GAP_PERCENT_PREFERENCE, ConsPercGaps);
   }
 
   @Override