X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2Fscoremodels%2FSimilarityScoreModel.java;h=e702340e1ff94cc8f93374b429795dcdbfb3b374;hb=8d0d4cb4f21a2f15d61b90b0eb764041c664c81d;hp=d41e0ba44f5536e5b309ceb9fea12f03763d0386;hpb=aba253e57b22ce7d1f4fe376935e42aeb4f6d591;p=jalview.git diff --git a/src/jalview/analysis/scoremodels/SimilarityScoreModel.java b/src/jalview/analysis/scoremodels/SimilarityScoreModel.java index d41e0ba..e702340 100644 --- a/src/jalview/analysis/scoremodels/SimilarityScoreModel.java +++ b/src/jalview/analysis/scoremodels/SimilarityScoreModel.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.analysis.scoremodels; import jalview.api.analysis.ScoreModelI; @@ -17,14 +37,27 @@ public abstract class SimilarityScoreModel implements ScoreModelI 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; } }