Merge branch 'docs/2_8_1_Release' into Release_2_8_2_Branch
[jalview.git] / src / jalview / schemes / ResidueProperties.java
index aecce4b..43f45d0 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
@@ -1420,41 +1420,62 @@ 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;i<maxProteinIndex;i++)
     {
+      int maxF=0,maxP=0,maxEP=0;
       String ic="";
-      if (aa.length<i) {
+      if (aa.length>i) {
         ic+=aa[i];
       }
       else {ic = "-";}
-      propMatrix[0][i][i]=propHash.size();
-      propMatrix[1][i][i]=propHash.size();
-      propMatrix[2][i][i]=propHash.size();
       for (int j=i+1;j<maxProteinIndex; j++)
       {
         String jc="";
-        if (aa.length<j) {
+        if (aa.length>j) {
           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<String> en= (Enumeration<String>)propHash.keys(); en.hasMoreElements(); )
         {
           String ph = en.nextElement();
           Map<String,Integer> pph=(Map<String,Integer>)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();
+            // Still working on these definitions.
+            propMatrixPos[i][j] += icp == jcp && icp>0 ? 2 : 0;
+            propMatrixPos[j][i] += icp == jcp && icp>0 ? 2 : 0;
+            propMatrixF[i][j] += icp == jcp ? 2 : 0;
+            propMatrixF[j][i] += icp == jcp ? 2 : 0;
+            propMatrixEpos[i][j] += icp == jcp ? (1+icp * 2) : 0;
+            propMatrixEpos[j][i] += icp == jcp ? (1+icp * 2) : 0;
+        }}
+        if (maxF<propMatrixF[i][j])
+        {
+          maxF=propMatrixF[i][j];
+        }
+        if (maxP<propMatrixPos[i][j])
+        {
+          maxP=propMatrixPos[i][j];
+        }
+        if (maxEP<propMatrixEpos[i][j])
+        {
+          maxEP=propMatrixEpos[i][j];
         }
       }
+      propMatrixF[i][i]=maxF;
+      propMatrixPos[i][i]=maxP;
+      propMatrixEpos[i][i]=maxEP;
     }
-    
-    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));
+    // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
+    //scoreMatrices.put("Conservation Pos", new ScoreMatrix("Conservation Pos",propMatrixPos,0));
+    //scoreMatrices.put("Conservation Both", new ScoreMatrix("Conservation Both",propMatrixF,0));
+    //scoreMatrices.put("Conservation EnhPos", new ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
     scoreMatrices.put("PID", new PIDScoreModel());
   }