From: gmungoc Date: Thu, 23 Mar 2017 15:01:29 +0000 (+0000) Subject: JAL-2393 code tidy and comments, PIDDistanceModel deprecated X-Git-Tag: Release_2_10_2~3^2~105^2~2^2~67 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=582493a5b56d3e01d901c6da9906685c31a32abb JAL-2393 code tidy and comments, PIDDistanceModel deprecated --- diff --git a/src/jalview/analysis/PCA.java b/src/jalview/analysis/PCA.java index 43f2161..b481e89 100755 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@ -223,8 +223,7 @@ public class PCA implements Runnable * Computes a pairwise similarity matrix for the given sequence regions using * the configured score model. If the score model is a similarity model, then * it computes the result directly. If it is a distance model, then use it to - * compute pairwise distances, and convert these to similarity scores by - * substracting from the maximum value. + * compute pairwise distances, and convert these to similarity scores. * * @param av * @return @@ -239,6 +238,10 @@ public class PCA implements Runnable } else if (scoreModel instanceof DistanceScoreModelI) { + /* + * find distances and convert to similarity scores + * reverseRange(false) preserves but reverses the min-max range + */ result = ((DistanceScoreModelI) scoreModel).findDistances(av, similarityParams); result.reverseRange(false); diff --git a/src/jalview/analysis/TreeBuilder.java b/src/jalview/analysis/TreeBuilder.java index f28c6bc..6d5b0fe 100644 --- a/src/jalview/analysis/TreeBuilder.java +++ b/src/jalview/analysis/TreeBuilder.java @@ -277,6 +277,7 @@ public abstract class TreeBuilder { /* * compute similarity and invert it to give a distance measure + * reverseRange(true) converts maximum similarity to zero distance */ MatrixI result = ((SimilarityScoreModelI) sm).findSimilarities( seqData, scoreOptions); diff --git a/src/jalview/analysis/scoremodels/PIDDistanceModel.java b/src/jalview/analysis/scoremodels/PIDDistanceModel.java index 9688037..bb9d834 100644 --- a/src/jalview/analysis/scoremodels/PIDDistanceModel.java +++ b/src/jalview/analysis/scoremodels/PIDDistanceModel.java @@ -27,6 +27,10 @@ import jalview.math.Matrix; import jalview.math.MatrixI; import jalview.util.Comparison; +/** + * @deprecated superseded by PIDModel + */ +@Deprecated public class PIDDistanceModel implements DistanceScoreModelI { diff --git a/src/jalview/analysis/scoremodels/ScoreMatrix.java b/src/jalview/analysis/scoremodels/ScoreMatrix.java index 8b7fc42..a4b8343 100644 --- a/src/jalview/analysis/scoremodels/ScoreMatrix.java +++ b/src/jalview/analysis/scoremodels/ScoreMatrix.java @@ -79,21 +79,21 @@ public class ScoreMatrix implements SimilarityScoreModelI, * of symbols. The matrix should be square and of the same size as the * alphabet, for example 20x20 for a 20 symbol alphabet. * - * @param name + * @param theName * Unique, human readable name for the matrix * @param alphabet * the symbols to which scores apply - * @param matrix + * @param values * Pairwise scores indexed according to the symbol alphabet */ - public ScoreMatrix(String name, char[] alphabet, float[][] matrix) + public ScoreMatrix(String theName, char[] alphabet, float[][] values) { - if (alphabet.length != matrix.length) + if (alphabet.length != values.length) { throw new IllegalArgumentException( "score matrix size must match alphabet size"); } - for (float[] row : matrix) + for (float[] row : values) { if (row.length != alphabet.length) { @@ -102,8 +102,8 @@ public class ScoreMatrix implements SimilarityScoreModelI, } } - this.matrix = matrix; - this.name = name; + this.matrix = values; + this.name = theName; this.symbols = alphabet; symbolIndex = buildSymbolIndex(alphabet); diff --git a/src/jalview/analysis/scoremodels/ScoreModels.java b/src/jalview/analysis/scoremodels/ScoreModels.java index 193d5f4..494d09f 100644 --- a/src/jalview/analysis/scoremodels/ScoreModels.java +++ b/src/jalview/analysis/scoremodels/ScoreModels.java @@ -35,10 +35,9 @@ public class ScoreModels * */ private ScoreModels() @@ -52,7 +51,6 @@ public class ScoreModels registerScoreModel(new PIDModel()); DNA = loadScoreMatrix("scoreModel/dna.scm"); registerScoreModel(new FeatureDistanceModel()); - // registerScoreModel(new PIDDistanceModel()); // superseded by PIDModel } /** diff --git a/src/jalview/api/analysis/ScoreModelI.java b/src/jalview/api/analysis/ScoreModelI.java index 42f978c..9a633f0 100644 --- a/src/jalview/api/analysis/ScoreModelI.java +++ b/src/jalview/api/analysis/ScoreModelI.java @@ -1,8 +1,5 @@ package jalview.api.analysis; -import jalview.datamodel.AlignmentView; -import jalview.math.MatrixI; - public interface ScoreModelI { /** diff --git a/src/jalview/math/MatrixI.java b/src/jalview/math/MatrixI.java index d7a1b70..f0603dd 100644 --- a/src/jalview/math/MatrixI.java +++ b/src/jalview/math/MatrixI.java @@ -72,13 +72,13 @@ public interface MatrixI *

* If parameter maxToZero is true, then the maximum value becomes * zero, i.e. all values are subtracted from the maximum. This is consistent - * with converting a similarity score to a distance score - the most similar - * (identity) corresponds to zero distance. However note that the operation is - * not reversible (unless the original minimum value is zero). For example a - * range of 10-40 would become 30-0, which would reverse a second time to - * 0-30. Also note that a similarity measure (such as BLOSUM) may give - * different identity scores for different sequences, so they cannot all - * convert to zero distance. + * with converting an identity similarity score to a distance score - the most + * similar (identity) corresponds to zero distance. However note that the + * operation is not reversible (unless the original minimum value is zero). + * For example a range of 10-40 would become 30-0, which would reverse a + * second time to 0-30. Also note that a general similarity measure (such as + * BLOSUM) may give different 'identity' scores for different sequences, so + * they cannot all convert to zero distance. *

* If parameter maxToZero is false, then the values are reflected * about the average of {min, max} (effectively swapping min and max). This