JAL-4159 first stab at injecting blosum62 similarity scores rather than alignment...
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 23 May 2024 19:33:23 +0000 (20:33 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 23 May 2024 19:33:23 +0000 (20:33 +0100)
src/jalview/analysis/AlignSeq.java
src/jalview/analysis/PaSiMap.java

index 22cffb1..d0f0c94 100755 (executable)
@@ -1419,7 +1419,7 @@ public class AlignSeq
   */
   public void scoreAlignment()
   {
-
+    // TODO JAL-4423 - review and optimise - make it possible to score any pair of aligned sequences in the same way
     getIndelfreeAstr();
     meanScore();
     hypotheticMaxScore();
index 2d015ce..8e7d7de 100755 (executable)
  */
 package jalview.analysis;
 
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.analysis.scoremodels.SimilarityParams;
 import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
 import jalview.bin.Console;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
 import jalview.datamodel.Point;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequenceGroup;
@@ -204,10 +209,38 @@ public class PaSiMap implements Runnable
   {
     try
     {
-      //alignment = new PairwiseAlignPanel(seqs, true, 100, 5);
-      alignment.calculate();
-      float[][] scores = alignment.getAlignmentScores();       //bigger index first -- eg scores[14][13]
-      SequenceI[] iseqs = alignment.getInputSequences();
+      // alignment = new PairwiseAlignPanel(seqs, true, 100, 5);
+      float[][] scores;
+      SequenceI[] iseqs;
+      if (!dontRealign)
+      {
+        alignment.calculate();
+        iseqs = alignment.getInputSequences();
+        scores = alignment.getAlignmentScores(); // bigger index first -- eg
+                                                 // scores[14][13]
+      }
+      else
+      {
+        AlignmentView alignview = seqs.getAlignmentView(true);
+        iseqs = alignview.getEditedSequences(seqs.getGapCharacter(), false);
+        ScoreModelI sm = scoreModel;
+        if (sm== null)
+        {
+          sm = ScoreModels.getInstance().getDefaultModel(!seqs.isNucleotide());
+        }
+        MatrixI similarities = sm.findSimilarities(alignview,
+                SimilarityParams.Jalview);
+        scores = new float[similarities.height()][similarities.width()];
+        for (int i = 0; i < scores.length; i++)
+        {
+          double[] row = similarities.getRow(i);
+          for (int j = 0; j < scores[i].length; j++)
+          {
+            scores[i][j] = (float) row[j];
+          }
+        }
+      }
+
       Connectivity.getConnectivity(iseqs, scores, dim);
 
       pairwiseScores = new Matrix(scores);