From: Jim Procter Date: Mon, 19 Aug 2024 16:39:09 +0000 (+0100) Subject: Merge branch 'develop' into feature/JAL-4159_pasimap_JAL-4423_alt_msa_source X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=adfc6a43209b833b6c4fa7c68fbebbf6d0ba0834;p=jalview.git Merge branch 'develop' into feature/JAL-4159_pasimap_JAL-4423_alt_msa_source Conflicts: src/jalview/analysis/AlignSeq.java src/jalview/analysis/PaSiMap.java src/jalview/gui/CalculationChooser.java src/jalview/gui/PaSiMapPanel.java src/jalview/viewmodel/PaSiMapModel.java --- adfc6a43209b833b6c4fa7c68fbebbf6d0ba0834 diff --cc src/jalview/analysis/PaSiMap.java index 8e7d7de,5be8c7b..3636731 --- a/src/jalview/analysis/PaSiMap.java +++ b/src/jalview/analysis/PaSiMap.java @@@ -20,14 -20,11 +20,15 @@@ */ 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.analysis.scoremodels.ScoreMatrix; -import jalview.analysis.scoremodels.ScoreModels; 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; @@@ -210,37 -229,10 +225,37 @@@ public class PaSiMap implements Runnabl try { // alignment = new PairwiseAlignPanel(seqs, true, 100, 5); - alignment.calculate(scoreMatrix); - float[][] scores = alignment.getAlignmentScores(); // bigger index first - // -- eg scores[14][13] - SequenceI[] iseqs = alignment.getInputSequences(); + float[][] scores; + SequenceI[] iseqs; - if (!dontRealign) ++ if (!dontRealign && scoreModel instanceof ScoreMatrix) + { - alignment.calculate(); ++ alignment.calculate((ScoreMatrix)scoreModel); + 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); diff --cc src/jalview/gui/CalculationChooser.java index c22c4ba,711cac8..ecf0a16 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@@ -308,17 -353,8 +355,17 @@@ public class CalculationChooser extend paramsPanel.add(matchGaps); paramsPanel.add(includeGappedColumns); paramsPanel.add(shorterSequence); - + /* + * pasimap parameters + */ + reuseAlignment = new JCheckBox("Use aligned similarity"); + reuseAlignment.setSelected(false); + reuseAlignment.setVisible(false); + scoreModelPanel.add(reuseAlignment); + + + /* * OK / Cancel buttons */ calculate = new JButton(MessageManager.getString("action.calculate")); @@@ -405,9 -443,11 +454,12 @@@ MIN_TREE_SELECTION); boolean checkAverageDistance = checkEnabled(averageDistance, size, MIN_TREE_SELECTION); + boolean checkPairwise = checkEnabled(pairwise, size, + MIN_PAIRWISE_SELECTION); + reuseAlignment.setVisible(checkPasimap); - if (checkPca || checkPasimap || checkNeighbourJoining || checkAverageDistance) + if (checkPca || checkPasimap || checkPca || checkNeighbourJoining + || checkAverageDistance || checkPairwise) { calculate.setToolTipText(null); calculate.setEnabled(true); diff --cc src/jalview/gui/PaSiMapPanel.java index 2b6bc14,7926efc..c607d63 --- a/src/jalview/gui/PaSiMapPanel.java +++ b/src/jalview/gui/PaSiMapPanel.java @@@ -201,23 -198,27 +201,28 @@@ public class PaSiMapPanel extends GPaSi { selGroup = new SequenceGroup(av.getAlignment().getSequences()); selGroup.setStartRes(0); - selGroup.setEndRes(av.getAlignment().getWidth()-1); + selGroup.setEndRes(av.getAlignment().getWidth() - 1); } - - if (selGroup.getSize()>MAX_PASIMAP_SEQ) + + if (selGroup.getSize() > MAX_PASIMAP_SEQ) { - int start = selGroup.getStartRes(),end=selGroup.getEndRes(); - selGroup = new SequenceGroup(selGroup.getSequences().subList(0, MAX_PASIMAP_SEQ)); - selGroup.setStartRes(start); - selGroup.setEndRes(end); - Console.warn("Truncated input sequences for PASIMAP analysis to "+MAX_PASIMAP_SEQ); + int start = selGroup.getStartRes(), end = selGroup.getEndRes(); + selGroup = new SequenceGroup( + selGroup.getSequences().subList(0, MAX_PASIMAP_SEQ)); + selGroup.setStartRes(start); + selGroup.setEndRes(end); + Console.warn("Truncated input sequences for PASIMAP analysis to " + + MAX_PASIMAP_SEQ); } - + PairwiseAlignPanel pap = new PairwiseAlignPanel(av, selGroup, true, - GAP_OPEN_COST, GAP_EXTEND_COST, false); + GAP_OPEN_COST, GAP_EXTEND_COST, false, null); + pap.setDiscardAlignments(true); + pap.setQuiet(true); + System.out.println(pap != null); setPairwiseAlignPanel(pap); + getPasimapModel().setUseObservedAlignment(useObservedAlignment); getPasimapModel().calculate(pap); xCombobox.setSelectedIndex(0);