From 136f41377900e9e70d9d083664e898a255af74dd Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 30 Mar 2023 12:09:01 +0100 Subject: [PATCH] JAL-3481 Added preference keys for the Conservation THRESHOLD_PERCENT and CONSERVATION_GAP_PERCENT --- src/jalview/analysis/Conservation.java | 32 +++++++++++++++----------- src/jalview/viewmodel/AlignmentViewport.java | 4 +++- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index cbc4dca..158624d 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -20,10 +20,18 @@ */ 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 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) diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index a42a2a4..9756442 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -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 -- 1.7.10.2