From: Jim Procter Date: Mon, 19 Aug 2024 16:49:32 +0000 (+0100) Subject: Merge branch 'feature/JAL-4446_cancellable_pasimap_etal' into feature/JAL-4159_pasima... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1a2a4ce555a75c3c0cf2929ee346ff13e883c3c6;p=jalview.git Merge branch 'feature/JAL-4446_cancellable_pasimap_etal' into feature/JAL-4159_pasimap_JAL-4423_alt_msa_source Conflicts: src/jalview/analysis/PaSiMap.java src/jalview/gui/PaSiMapPanel.java src/jalview/viewmodel/PaSiMapModel.java --- 1a2a4ce555a75c3c0cf2929ee346ff13e883c3c6 diff --cc src/jalview/analysis/PaSiMap.java index 3636731,b2a17ac..6deddf8 --- a/src/jalview/analysis/PaSiMap.java +++ b/src/jalview/analysis/PaSiMap.java @@@ -225,37 -231,15 +227,47 @@@ public class PaSiMap implements Runnabl try { // alignment = new PairwiseAlignPanel(seqs, true, 100, 5); - alignment.calculate(scoreMatrix); - if (alignment.isCancelled()) + float[][] scores; + SequenceI[] iseqs; + if (!dontRealign && scoreModel instanceof ScoreMatrix) + { + alignment.calculate((ScoreMatrix)scoreModel); ++ if (alignment.isCancelled()) ++ { ++ cancel(); ++ return; ++ } + iseqs = alignment.getInputSequences(); + scores = alignment.getAlignmentScores(); // bigger index first -- eg + // scores[14][13] + } + else { - cancel(); - return; + 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]; + } ++ if (alignment.isCancelled()) ++ { ++ cancel(); ++ return; ++ } + } } - float[][] scores = alignment.getAlignmentScores(); // bigger index first - // -- eg scores[14][13] - SequenceI[] iseqs = alignment.getInputSequences(); + Connectivity.getConnectivity(iseqs, scores, dim); pairwiseScores = new Matrix(scores); diff --cc src/jalview/gui/PaSiMapPanel.java index c607d63,8f45410..b172da0 --- a/src/jalview/gui/PaSiMapPanel.java +++ b/src/jalview/gui/PaSiMapPanel.java @@@ -92,8 -92,8 +92,10 @@@ public class PaSiMapPanel extends GPaSi private boolean working; + private boolean useObservedAlignment; + + private String newPasimapTitle; + /** * Constructor given sequence data, a similarity (or distance) score model * name, and score calculation parameters @@@ -133,8 -133,13 +135,14 @@@ ScoreModelI scoreModel = ScoreModels.getInstance() .getScoreModel(modelName, ap); - setPasimapModel(new PaSiMapModel(av, seqs, nucleotide, scoreModel)); + setPasimapModel( + new PaSiMapModel(av, seqs, nucleotide, useObservedAlignment, scoreModel)); + + newPasimapTitle = alignPanel.alignFrame.formCalculationTitle( + MessageManager.formatMessage("label.calc_title", "PaSiMap", - scoreModel.getName()), ++ scoreModel.getName()+(useObservedAlignment ? " (from alignment)":"")), + selected, ap.alignFrame.getTitle()); + PaintRefresher.Register(this, av.getSequenceSetId()); setRotatableCanvas(new RotatableCanvas(alignPanel)); @@@ -222,17 -227,36 +230,39 @@@ System.out.println(pap != null); setPairwiseAlignPanel(pap); - getPasimapModel().setUseObservedAlignment(useObservedAlignment); - getPasimapModel().calculate(pap); + - xCombobox.setSelectedIndex(0); - yCombobox.setSelectedIndex(1); - zCombobox.setSelectedIndex(2); ++ getPasimapModel().setUseObservedAlignment(useObservedAlignment); + - getPasimapModel().updateRc(getRotatableCanvas()); - // rc.invalidate(); - setTop(getPasimapModel().getTop()); + progressBar.registerHandler(progId, new IProgressIndicatorHandler() + { + + @Override + public boolean cancelActivity(long id) + { + getPasimapModel().cancel(); + return true; + } + + @Override + public boolean canCancel() + { + return true; + } + }); + getPasimapModel().calculate(pap); + if (!getPasimapModel().isCancelled()) + { + // TODO: fix outputAlignment so it uses the compact form if no text report is available + outputAlignment.setVisible(!pap.isDiscardAlignments() && !pap.isQuiet()); + xCombobox.setSelectedIndex(0); + yCombobox.setSelectedIndex(1); + zCombobox.setSelectedIndex(2); + + getPasimapModel().updateRc(getRotatableCanvas()); + // rc.invalidate(); + setTop(getPasimapModel().getTop()); + } } catch (OutOfMemoryError er) { new OOMWarning("calculating PaSiMap", er); diff --cc src/jalview/viewmodel/PaSiMapModel.java index 5230884,ac070e8..ffded3f --- a/src/jalview/viewmodel/PaSiMapModel.java +++ b/src/jalview/viewmodel/PaSiMapModel.java @@@ -88,8 -85,12 +88,13 @@@ public class PaSiMapMode public void calculate(PairwiseAlignPanel pap) { pasimap = new PaSiMap(inputData, scoreModel, pap); + pasimap.setDontRealign(dontRealign); pasimap.run(); // executes in same thread, wait for completion + if (pasimap.isCancelled()) + { + // no more work to do + return; + } // Now find the component coordinates int ii = 0; @@@ -267,8 -268,17 +272,22 @@@ pasimap = data; } + public void setUseObservedAlignment(boolean useObservedAlignment) + { + dontRealign = useObservedAlignment; + } ++ + public boolean isCancelled() + { + if (pasimap==null || pasimap.isCancelled()) + { + return true; + } + return false; + } + + public void cancel() + { + pasimap.cancel(); + } }