From: Jim Procter Date: Mon, 2 Jun 2014 15:45:40 +0000 (+0100) Subject: JAL-1512 rejig buggy conservation-basesd score matrix calculation X-Git-Tag: Release_2_8_1~4^2~5^2~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7b4ec47748c8785073981750de8a4f9d716395bb;p=jalview.git JAL-1512 rejig buggy conservation-basesd score matrix calculation --- diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 2050147..7dd6520 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -1420,41 +1420,49 @@ public class ResidueProperties } static { - int[][][] propMatrix = new int[3][maxProteinIndex][maxProteinIndex]; + int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], + propMatrixPos = new int[maxProteinIndex][maxProteinIndex], + propMatrixEpos = new int[maxProteinIndex][maxProteinIndex]; for (int i=0;ii) { ic+=aa[i]; } else {ic = "-";} - propMatrix[0][i][i]=propHash.size(); - propMatrix[1][i][i]=propHash.size(); - propMatrix[2][i][i]=propHash.size(); + propMatrixF[i][i]=propHash.size(); + propMatrixPos[i][i]=propHash.size(); + propMatrixEpos[i][i]=propHash.size(); for (int j=i+1;jj) { jc+=aa[j]; } else {jc = "-";} - propMatrix[0][i][j]=0; - propMatrix[1][i][j]=0; - propMatrix[2][i][j]=0; + propMatrixF[i][j]=0; + propMatrixPos[i][j]=0; + propMatrixEpos[i][j]=0; for (Enumeration en= (Enumeration)propHash.keys(); en.hasMoreElements(); ) { String ph = en.nextElement(); Map pph=(Map)propHash.get(ph); - propMatrix[0][i][j]+= pph.get(ic).equals(pph.get(jc)) ? pph.get(ic) : -1; - propMatrix[1][i][j]+= pph.get(ic).equals(pph.get(jc)) ? 1 : -1; - propMatrix[2][i][j]+= pph.get(ic).equals(pph.get(jc)) ? pph.get(ic)*2 : 0; - } + if (pph.get(ic)!=null && pph.get(jc)!=null) { + int icp=pph.get(ic).intValue(),jcp=pph.get(jc).intValue(); + + propMatrixPos[i][j] += icp == jcp ? icp : -1; + propMatrixPos[j][i] += icp == jcp ? icp : -1; + propMatrixF[i][j] += icp == jcp ? 2 : -1; + propMatrixF[j][i] += icp == jcp ? 2 : -1; + propMatrixEpos[i][j] += icp == jcp ? (1+icp * 2) : -1; + propMatrixEpos[j][i] += icp == jcp ? (1+icp * 2) : -1; + }} } } - scoreMatrices.put("Conservation Pos", new ScoreMatrix("Conservation Pos",propMatrix[0],0)); - scoreMatrices.put("Conservation Both", new ScoreMatrix("Conservation Both",propMatrix[1],0)); - scoreMatrices.put("Conservation EnhPos", new ScoreMatrix("Conservation EnhPos",propMatrix[2],0)); + scoreMatrices.put("Conservation Pos", new ScoreMatrix("Conservation Pos",propMatrixF,0)); + scoreMatrices.put("Conservation Both", new ScoreMatrix("Conservation Both",propMatrixPos,0)); + scoreMatrices.put("Conservation EnhPos", new ScoreMatrix("Conservation EnhPos",propMatrixEpos,0)); scoreMatrices.put("PID", new PIDScoreModel()); }