From: James Procter Date: Sat, 16 Dec 2023 08:43:06 +0000 (+0000) Subject: JAL-789 pairwise alignment via calculations dialog, allowing score model to be changed X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=95600b03ceeaf7162219dfa9b0a6bed432228b60;p=jalview.git JAL-789 pairwise alignment via calculations dialog, allowing score model to be changed --- diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 75ccdfc..edf19ec 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -26,6 +26,7 @@ import jalview.analysis.scoremodels.PIDModel; import jalview.analysis.scoremodels.ScoreMatrix; import jalview.analysis.scoremodels.ScoreModels; import jalview.analysis.scoremodels.SimilarityParams; +import jalview.api.analysis.SimilarityParamsI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Mapping; @@ -1163,4 +1164,12 @@ public class AlignSeq } return redundancy; } + + public void setScoreMatrix(ScoreMatrix params) + { + if (params!=null) + { + scoreMatrix = params; + } + } } diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index af41e58..daab62b 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -53,6 +53,7 @@ import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; import jalview.analysis.TreeBuilder; +import jalview.analysis.scoremodels.ScoreMatrix; import jalview.analysis.scoremodels.ScoreModels; import jalview.analysis.scoremodels.SimilarityParams; import jalview.api.analysis.ScoreModelI; @@ -76,12 +77,17 @@ public class CalculationChooser extends JPanel private static final Font VERDANA_11PT = new Font("Verdana", 0, 11); + + private static final int MIN_PAIRWISE_SELECTION = 2; + private static final int MIN_TREE_SELECTION = 3; private static final int MIN_PCA_SELECTION = 4; AlignFrame af; + JRadioButton pairwise; + JRadioButton pca; JRadioButton neighbourJoining; @@ -166,6 +172,9 @@ public class CalculationChooser extends JPanel averageDistance = new JRadioButton( MessageManager.getString("label.tree_calc_av")); averageDistance.setOpaque(false); + + pairwise = new JRadioButton(MessageManager.getString("label.pairwise_alignment")); + pairwise.setOpaque(false); JPanel calcChoicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); calcChoicePanel.setOpaque(false); @@ -191,11 +200,13 @@ public class CalculationChooser extends JPanel treePanel.add(averageDistance); calcChoicePanel.add(treePanel); + calcChoicePanel.add(pairwise,FlowLayout.CENTER); ButtonGroup calcTypes = new ButtonGroup(); calcTypes.add(pca); calcTypes.add(neighbourJoining); calcTypes.add(averageDistance); + calcTypes.add(pairwise); ActionListener calcChanged = new ActionListener() { @@ -208,7 +219,7 @@ public class CalculationChooser extends JPanel pca.addActionListener(calcChanged); neighbourJoining.addActionListener(calcChanged); averageDistance.addActionListener(calcChanged); - + pairwise.addActionListener(calcChanged); /* * score models drop-down - with added tooltips! */ @@ -319,8 +330,10 @@ public class CalculationChooser extends JPanel MIN_TREE_SELECTION); boolean checkAverageDistance = checkEnabled(averageDistance, size, MIN_TREE_SELECTION); + boolean checkPairwise = checkEnabled(pairwise, size, + MIN_PAIRWISE_SELECTION); - if (checkPca || checkNeighbourJoining || checkAverageDistance) + if (checkPca || checkNeighbourJoining || checkAverageDistance || checkPairwise) { calculate.setToolTipText(null); calculate.setEnabled(true); @@ -521,15 +534,33 @@ public class CalculationChooser extends JPanel if (doPCA) { openPcaPanel(modelName, params); - } - else + } else { + if (pairwise.isSelected()) + { + openPairwisePanel(modelName,params); + } else { openTreePanel(modelName, params); - } + }} // closeFrame(); } + private void openPairwisePanel(String modelName, SimilarityParamsI params) + { + ScoreModelI sm = ScoreModels.getInstance().getScoreModel(modelName, af.alignPanel); + if (sm==null || !(sm instanceof ScoreMatrix)) + { + return; + } + JInternalFrame frame = new JInternalFrame(); + frame.setFrameIcon(null); + frame.setContentPane(new PairwiseAlignPanel(af.getViewport(),(ScoreMatrix)sm)); + Desktop.addInternalFrame(frame, + MessageManager.getString("action.pairwise_alignment"), 600, + 500); + } + /** * Open a new Tree panel on the desktop * @@ -597,6 +628,7 @@ public class CalculationChooser extends JPanel new Thread(pcaPanel).start(); } + /** * diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index b5b6ffc..2c65bcc 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -21,6 +21,9 @@ package jalview.gui; import jalview.analysis.AlignSeq; +import jalview.analysis.scoremodels.ScoreMatrix; +import jalview.api.analysis.ScoreModelI; +import jalview.api.analysis.SimilarityParamsI; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentView; import jalview.datamodel.SequenceGroup; @@ -51,10 +54,22 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel * Creates a new PairwiseAlignPanel object. * * @param viewport - * DOCUMENT ME! + * contains selected sequences to align */ public PairwiseAlignPanel(AlignmentViewport viewport) { + this(viewport,null); + } + + /** + * Creates a new PairwiseAlignPanel object. + * + * @param viewport + * contains selected sequences to align + */ + + public PairwiseAlignPanel(AlignmentViewport viewport, ScoreMatrix params) + { super(); this.av = viewport; @@ -98,7 +113,10 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel { continue; } - + if (params!=null) + { + as.setScoreMatrix(params); + } as.calcScoreMatrix(); as.traceAlignment();