From 39ef2c483d62e04129703d6acff8a594cc7e9b16 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 7 Aug 2024 15:07:51 +0100 Subject: [PATCH] JAL-4446 better reporting of ETA estimation - particularly for large alignments --- src/jalview/gui/PaSiMapPanel.java | 27 +++++++++++++++++++++------ src/jalview/gui/PairwiseAlignPanel.java | 31 +++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/jalview/gui/PaSiMapPanel.java b/src/jalview/gui/PaSiMapPanel.java index edf7deb..bc6e477 100644 --- a/src/jalview/gui/PaSiMapPanel.java +++ b/src/jalview/gui/PaSiMapPanel.java @@ -687,15 +687,27 @@ public class PaSiMapPanel extends GPaSiMapPanel return; } int max=pBar.getMaximum(); + updateProgressBarEta(minutes); + pBar.setMaximum(max); + pBar.setValue(progress); + } + + public void updateProgressBarEta(double minutes) + { + JProgressBar pBar = progressBar.getProgressBar(progId); + + if (pBar == null) + { + return; + } progressBar.setProgressBarMessage(progId, progressBar.getMessage(progId) + " (" + (Double.isNaN(minutes) ? " .. working ..)" : (minutes < 1.0 ? "Less than a minute)" - : ((int) Math.ceil(minutes)) + " mins. to go)"))); - pBar.setMaximum(max); - pBar.setValue(progress); - + : ((int) Math.ceil(minutes)) + + " mins. to go)"))); } + public void updateProgressBar(int progress) { JProgressBar pBar = progressBar.getProgressBar(progId); @@ -724,13 +736,16 @@ public class PaSiMapPanel extends GPaSiMapPanel { if (PairwiseAlignPanel.PROGRESS.equals(pcEvent.getPropertyName())) { - updateProgressBarWithEta((int) pcEvent.getNewValue(), pap.getEta()); - + updateProgressBar((int) pcEvent.getNewValue()); } else if (PairwiseAlignPanel.TOTAL.equals(pcEvent.getPropertyName())) { updateProgressBar((int) pcEvent.getNewValue(), 0); } + else if (PairwiseAlignPanel.ETA.equals(pcEvent.getPropertyName())) + { + updateProgressBarEta((double) pcEvent.getNewValue()); + } } }); } diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index ca97aaf..9071c31 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -70,11 +70,13 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel public static final String PROGRESS = "progress"; + protected static final String ETA = "eta_in_minutes"; + private volatile boolean cancelled; - private int total; + private long total; - private int progress; + private long progress; private SequenceGroup selection; @@ -138,7 +140,8 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel this.GAP_EXTEND_COST = gapExtendCost; this.endGaps = endGaps; this.selection = selection; - this.total = MiscMath.combinations(av.getAlignment().getHeight(), 2); + this.total = av.getAlignment().getHeight(); + total = (total*total-total)/2; this.scoreMatrix = scoreMatrix; if (run) { @@ -196,11 +199,11 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel float[][] alignmentScores = new float[seqs.length][seqs.length]; double totscore = 0D; int count = seqs.length; - + int fracprogress=0; boolean first = true; long time=System.currentTimeMillis(); - progress = 0; - firePropertyChange(TOTAL, 0, total); + long fprogress = 0; + firePropertyChange(TOTAL, 0, 500); for (int i = 1; i < count; i++) { @@ -261,12 +264,20 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel sequences.add(as.getAlignedSeq1()); sequences.add(as.getAlignedSeq2()); } - firePropertyChange(PROGRESS, progress, ++progress); + ++fprogress; } if (i0; } public double getEta() { -- 1.7.10.2