JAL-4390 don't output alignment to text panel and stdout when lots of sequences proce...
authorJames Procter <j.procter@dundee.ac.uk>
Tue, 9 Apr 2024 07:00:04 +0000 (08:00 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Tue, 9 Apr 2024 07:00:04 +0000 (08:00 +0100)
src/jalview/gui/PairwiseAlignPanel.java

index a84c449..2d86827 100755 (executable)
@@ -57,6 +57,10 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
 
   private String alignmentOutput;
 
+  private boolean suppressTextbox;
+
+  private boolean discardAlignments;
+
   /**
    * Creates a new PairwiseAlignPanel object.
    * 
@@ -103,12 +107,14 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
     float[][] alignmentScores = new float[seqs.length][seqs.length];
     double totscore = 0D;
     int count = seqs.length;
+    suppressTextbox = count<10;
+    discardAlignments = count<15;
     boolean first = true;
 
     for (int i = 1; i < count; i++)
     {
       // fill diagonal alignmentScores with Float.NaN
-      alignmentScores[i-1][i-1] = Float.NaN;
+      alignmentScores[i - 1][i - 1] = Float.NaN;
       for (int j = 0; j < i; j++)
       {
         AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
@@ -120,33 +126,42 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
         }
 
         as.calcScoreMatrix();
-       if (endGaps)
-       {
+        if (endGaps)
+        {
           as.traceAlignmentWithEndGaps();
-       } else {
-         as.traceAlignment();
-       }
-       as.scoreAlignment();
+        }
+        else
+        {
+          as.traceAlignment();
+        }
+        as.scoreAlignment();
 
         if (!first)
         {
           System.out.println(DASHES);
           textarea.append(DASHES);
-         sb.append(DASHES);
+          sb.append(DASHES);
         }
         first = false;
-        as.printAlignment(System.out);
+        if (discardAlignments) {
+          as.printAlignment(System.out);
+        }
         scores[i][j] = as.getMaxScore() / as.getASeq1().length;
         alignmentScores[i][j] = as.getAlignmentScore();
         totscore = totscore + scores[i][j];
-
-        textarea.append(as.getOutput());
-       sb.append(as.getOutput());
-        sequences.add(as.getAlignedSeq1());
-        sequences.add(as.getAlignedSeq2());
+        if (suppressTextbox)
+        {
+          textarea.append(as.getOutput());
+          sb.append(as.getOutput());
+        }
+        if (discardAlignments)
+        {
+          sequences.add(as.getAlignedSeq1());
+          sequences.add(as.getAlignedSeq2());
+        }
       }
     }
-    alignmentScores[count-1][count-1] = Float.NaN;
+    alignmentScores[count - 1][count - 1] = Float.NaN;
 
     this.scores = scores;
     this.alignmentScores = alignmentScores;