From 7d123b6259738869c16529b8c28cfd8931da4205 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 7 Feb 2017 12:43:19 +0000 Subject: [PATCH] JAL-2397 PCA gap cost uses last column of score matrix --- src/jalview/schemes/ScoreMatrix.java | 38 +++-------------------------- test/jalview/schemes/ScoreMatrixTest.java | 17 ++++++------- 2 files changed, 11 insertions(+), 44 deletions(-) diff --git a/src/jalview/schemes/ScoreMatrix.java b/src/jalview/schemes/ScoreMatrix.java index b5e3ef1..d82f54c 100644 --- a/src/jalview/schemes/ScoreMatrix.java +++ b/src/jalview/schemes/ScoreMatrix.java @@ -93,7 +93,7 @@ public class ScoreMatrix extends PairwiseSeqScoreModel @Override public int getPairwiseScore(char c, char d) { - int pog = 0; + int score = 0; try { @@ -101,45 +101,13 @@ public class ScoreMatrix extends PairwiseSeqScoreModel : ResidueProperties.nucleotideIndex[c]; int b = (type == 0) ? ResidueProperties.aaIndex[d] : ResidueProperties.nucleotideIndex[d]; - - /* - * FIXME: 2.10.1 PCA treats gap as [22] or 'X', but Tree - * calculation treats as [23]; which is correct? - */ - /* - * hack to convert unassigned / unknown (including gap) - * to index of unknown (X for amino acids, N for nucleotide) - * TODO: statically assign gap characters to this index? - */ -// if (type == 0) -// { -// if (a == ResidueProperties.maxProteinIndex) -// { -// a = ResidueProperties.aaIndex['X']; -// } -// if (b == ResidueProperties.maxProteinIndex) -// { -// b = ResidueProperties.aaIndex['X']; -// } -// } -// if (type != 0) -// { -// if (a == ResidueProperties.maxNucleotideIndex) -// { -// a = ResidueProperties.nucleotideIndex['N']; -// } -// if (b == ResidueProperties.maxNucleotideIndex) -// { -// b = ResidueProperties.nucleotideIndex['N']; -// } -// } - pog = matrix[a][b]; + score = matrix[a][b]; } catch (Exception e) { // System.out.println("Unknown residue in " + A1 + " " + A2); } - return pog; + return score; } /** diff --git a/test/jalview/schemes/ScoreMatrixTest.java b/test/jalview/schemes/ScoreMatrixTest.java index 99af601..e15dd41 100644 --- a/test/jalview/schemes/ScoreMatrixTest.java +++ b/test/jalview/schemes/ScoreMatrixTest.java @@ -143,26 +143,25 @@ public class ScoreMatrixTest } /* * verify expected BLOSUM dot product scores - * Note: gap is treated like 'X' [22] in the matrix */ // F.F + K.K + L.L = 6 + 5 + 4 = 15 assertEquals(pairwise.getValue(0, 0), 15d); - // R.R + X.X + D.D = 5 + -1 + 6 = 10 - assertEquals(pairwise.getValue(1, 1), 10d); + // R.R + -.- + D.D = 5 + 1 + 6 = 12 + assertEquals(pairwise.getValue(1, 1), 12d); // Q.Q + I.I + A.A = 5 + 4 + 4 = 13 assertEquals(pairwise.getValue(2, 2), 13d); // G.G + W.W + C.C = 6 + 11 + 9 = 26 assertEquals(pairwise.getValue(3, 3), 26d); - // F.R + K.X + L.D = -3 + -1 + -3 = -8 - assertEquals(pairwise.getValue(0, 1), -8d); + // F.R + K.- + L.D = -3 + -4 + -4 = -11 + assertEquals(pairwise.getValue(0, 1), -11d); // F.Q + K.I + L.A = -3 + -3 + -1 = -7 assertEquals(pairwise.getValue(0, 2), -7d); // F.G + K.W + L.C = -3 + -3 + -1 = -7 assertEquals(pairwise.getValue(0, 3), -7d); - // R.Q + X.I + D.A = 1 + -1 + -2 = -2 - assertEquals(pairwise.getValue(1, 2), -2d); - // R.G + X.W + D.C = -2 + -2 + -3 = -7 - assertEquals(pairwise.getValue(1, 3), -7d); + // R.Q + -.I + D.A = 1 + -4 + -2 = -5 + assertEquals(pairwise.getValue(1, 2), -5d); + // R.G + -.W + D.C = -2 + -4 + -3 = -9 + assertEquals(pairwise.getValue(1, 3), -9d); // Q.G + I.W + A.C = -2 + -3 + 0 = -5 assertEquals(pairwise.getValue(2, 3), -5d); } -- 1.7.10.2