Merge branch 'improvement/JAL-4250_secondary_structure_annotation_antialias' into...
[jalview.git] / src / jalview / analysis / AlignSeq.java
index 1b2578e..e1d5669 100755 (executable)
@@ -20,6 +20,8 @@
  */
 package jalview.analysis;
 
+import java.util.Locale;
+
 import jalview.analysis.scoremodels.PIDModel;
 import jalview.analysis.scoremodels.ScoreMatrix;
 import jalview.analysis.scoremodels.ScoreModels;
@@ -148,7 +150,8 @@ public class AlignSeq
   public AlignSeq(SequenceI s1, String string1, SequenceI s2,
           String string2, String type)
   {
-    seqInit(s1, string1.toUpperCase(), s2, string2.toUpperCase(), type);
+    seqInit(s1, string1.toUpperCase(Locale.ROOT), s2,
+            string2.toUpperCase(Locale.ROOT), type);
   }
 
   /**
@@ -643,12 +646,14 @@ public class AlignSeq
     for (int j = 1; j < m; j++)
     {
       // What should these values be? 0 maybe
-      E[0][j] = max(score[0][j - 1] - GAP_OPEN_COST, E[0][j - 1] - GAP_EXTEND_COST);
+      E[0][j] = max(score[0][j - 1] - GAP_OPEN_COST,
+              E[0][j - 1] - GAP_EXTEND_COST);
       F[0][j] = -GAP_EXTEND_COST;
 
       float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(0),
               s2str.charAt(j));
-      score[0][j] = max(pairwiseScore * 10, -GAP_OPEN_COST, -GAP_EXTEND_COST);
+      score[0][j] = max(pairwiseScore * 10, -GAP_OPEN_COST,
+              -GAP_EXTEND_COST);
 
       traceback[0][j] = 1;
     }
@@ -657,7 +662,8 @@ public class AlignSeq
     for (int i = 1; i < n; i++)
     {
       E[i][0] = -GAP_OPEN_COST;
-      F[i][0] = max(score[i - 1][0] - GAP_OPEN_COST, F[i - 1][0] - GAP_EXTEND_COST);
+      F[i][0] = max(score[i - 1][0] - GAP_OPEN_COST,
+              F[i - 1][0] - GAP_EXTEND_COST);
 
       float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
               s2str.charAt(0));
@@ -670,8 +676,10 @@ public class AlignSeq
     {
       for (int j = 1; j < m; j++)
       {
-        E[i][j] = max(score[i][j - 1] - GAP_OPEN_COST, E[i][j - 1] - GAP_EXTEND_COST);
-        F[i][j] = max(score[i - 1][j] - GAP_OPEN_COST, F[i - 1][j] - GAP_EXTEND_COST);
+        E[i][j] = max(score[i][j - 1] - GAP_OPEN_COST,
+                E[i][j - 1] - GAP_EXTEND_COST);
+        F[i][j] = max(score[i - 1][j] - GAP_OPEN_COST,
+                F[i - 1][j] - GAP_EXTEND_COST);
 
         float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
                 s2str.charAt(j));
@@ -818,7 +826,7 @@ public class AlignSeq
       }
     }
 
-    System.out.println(max + " " + min);
+    jalview.bin.Console.outPrintln(max + " " + min);
 
     for (int i = 0; i < n; i++)
     {
@@ -827,12 +835,12 @@ public class AlignSeq
         int x = psize * i;
         int y = psize * j;
 
-        // System.out.println(mat[i][j]);
+        // jalview.bin.Console.outPrintln(mat[i][j]);
         float score = (float) (mat[i][j] - min) / (float) (max - min);
         g.setColor(new Color(score, 0, 0));
         g.fillRect(x, y, psize, psize);
 
-        // System.out.println(x + " " + y + " " + score);
+        // jalview.bin.Console.outPrintln(x + " " + y + " " + score);
       }
     }
   }
@@ -882,7 +890,8 @@ public class AlignSeq
         pdbpos++;
       }
 
-      if (allowmismatch || c1 == c2)
+      // ignore case differences
+      if (allowmismatch || (c1 == c2) || (Math.abs(c2-c1)==('a'-'A')))
       {
         // extend mapping interval
         if (lp1 + 1 != alignpos || lp2 + 1 != pdbpos)
@@ -974,7 +983,7 @@ public class AlignSeq
             bestm = msq;
           }
         }
-        // System.out.println("Best Score for " + (matches.size() + 1) + " :"
+        // jalview.bin.Console.outPrintln("Best Score for " + (matches.size() + 1) + " :"
         // + bestscore);
         matches.add(bestm);
         aligns.add(bestaseq);