public MatrixI findSimilarities(AlignmentView seqData,
SimilarityParamsI options)
{
- MatrixI result = findDistances(seqData, options);
+ MatrixI distances = findDistances(seqData, options);
- /*
- * reverse the range of score values so that
- * max becomes min and vice versa
- */
- result.reverseRange(false);
+ MatrixI similarities = distanceToSimilarity(distances);
- return result;
+ return similarities;
+ }
+
+ /**
+ * Converts distance scores to similarity scores, by reversing the range of
+ * score values so that max becomes min and vice versa. The input matrix is
+ * not modified.
+ *
+ * @param distances
+ */
+ public static MatrixI distanceToSimilarity(MatrixI distances)
+ {
+ MatrixI similarities = distances.copy();
+
+ similarities.reverseRange(false);
+
+ return similarities;
}
}
public MatrixI findDistances(AlignmentView seqData,
SimilarityParamsI options)
{
- MatrixI result = findSimilarities(seqData, options);
+ MatrixI similarities = findSimilarities(seqData, options);
- /*
- * reverse the range of the scores mapping the maximum to zero
- */
- result.reverseRange(true);
+ MatrixI distances = similarityToDistance(similarities);
- return result;
+ return distances;
+ }
+
+ /**
+ * Converts a matrix of similarity scores to distance scores, by reversing the
+ * range of the scores, mapping the maximum to zero. The input matrix is not
+ * modified.
+ *
+ * @param similarities
+ */
+ public static MatrixI similarityToDistance(MatrixI similarities)
+ {
+ MatrixI distances = similarities.copy();
+
+ distances.reverseRange(true);
+
+ return distances;
}
}