From d9abea6c0e981191b8481ec27686ab3b85687039 Mon Sep 17 00:00:00 2001 From: MorellThomas Date: Mon, 4 Dec 2023 16:34:40 +0100 Subject: [PATCH] New GPCAPanel button : output pairwise alignments (pasimap only) --- resources/lang/Messages.properties | 2 ++ resources/lang/Messages_es.properties | 2 ++ src/jalview/analysis/PaSiMap.java | 14 +++++++++++++- src/jalview/gui/PaSiMapPanel.java | 23 +++++++++++++++++++++++ src/jalview/gui/PairwiseAlignPanel.java | 13 +++++++++++++ src/jalview/jbgui/GPCAPanel.java | 16 ++++++++++++++++ src/jalview/viewmodel/PaSiMapModel.java | 5 +++++ 7 files changed, 74 insertions(+), 1 deletion(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 614af46..56a0476 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -315,6 +315,8 @@ label.labels = Labels label.output_values = Output Values... label.output_points = Output points... label.output_transformed_points = Output transformed points +label.output_alignment = Output pairwise alignments +label.pairwise_alignment_for_params = Pairwise alignments for {0} label.input_data = Input Data... label.nucleotide_matrix = Nucleotide matrix label.protein_matrix = Protein matrix diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 269d581..ab382bc 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -278,6 +278,8 @@ label.labels = Etiquetas label.output_values = Valores de salida... label.output_points = Puntos de salida... label.output_transformed_points = Puntos de salida transformados +label.output_alignment = Alineaciones de pares de salida +label.pairwise_alignment_for_params = Alineaciiones por pares para {0} label.input_data = Datos de entrada... label.nucleotide_matrix = Matriz nucleotídica label.protein_matrix = Matriz proteica diff --git a/src/jalview/analysis/PaSiMap.java b/src/jalview/analysis/PaSiMap.java index ca49dc8..fae7e2a 100755 --- a/src/jalview/analysis/PaSiMap.java +++ b/src/jalview/analysis/PaSiMap.java @@ -57,6 +57,8 @@ public class PaSiMap implements Runnable /* * outputs */ + private PairwiseAlignPanel alignment; + private MatrixI pairwiseScores; private MatrixI eigenMatrix; @@ -202,7 +204,7 @@ public class PaSiMap implements Runnable { try { - PairwiseAlignPanel alignment = new PairwiseAlignPanel(seqs, true, 100, 5); + alignment = new PairwiseAlignPanel(seqs, true, 100, 5); float[][] scores = alignment.getAlignmentScores(); //bigger index first -- eg scores[14][13] Hashtable connectivity = seqs.calculateConnectivity(scores, dim); @@ -297,4 +299,14 @@ public class PaSiMap implements Runnable { eigenMatrix = m; } + + public PairwiseAlignPanel getAlignments() + { + return alignment; + } + + public String getAlignmentOutput() + { + return alignment.getAlignmentOutput(); + } } diff --git a/src/jalview/gui/PaSiMapPanel.java b/src/jalview/gui/PaSiMapPanel.java index cd1dd5a..f2445dc 100644 --- a/src/jalview/gui/PaSiMapPanel.java +++ b/src/jalview/gui/PaSiMapPanel.java @@ -564,6 +564,29 @@ public class PaSiMapPanel extends GPCAPanel /* * (non-Javadoc) * + * @see + * jalview.jbgui.GPCAPanel#outputAlignment_actionPerformed(java.awt.event + * .ActionEvent) + */ + @Override + protected void outputAlignment_actionPerformed() + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(); + try + { + cap.setText(getPasimapModel().getAlignmentOutput()); + Desktop.addInternalFrame(cap, MessageManager.formatMessage( + "label.pairwise_alignment_for_params", new String[] { this.getTitle() }), 500, 500); + } catch (OutOfMemoryError oom) + { + new OOMWarning("exporting pairwise alignments", oom); + cap.dispose(); + } + } + + /* + * (non-Javadoc) + * * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long) */ @Override diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index a499365..a84c449 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -55,6 +55,8 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel Vector sequences; + private String alignmentOutput; + /** * Creates a new PairwiseAlignPanel object. * @@ -71,6 +73,8 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel super(); this.av = viewport; + StringBuilder sb = new StringBuilder(1024); + sequences = new Vector(); SequenceGroup selectionGroup = viewport.getSelectionGroup(); @@ -128,6 +132,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel { System.out.println(DASHES); textarea.append(DASHES); + sb.append(DASHES); } first = false; as.printAlignment(System.out); @@ -136,6 +141,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel totscore = totscore + scores[i][j]; textarea.append(as.getOutput()); + sb.append(as.getOutput()); sequences.add(as.getAlignedSeq1()); sequences.add(as.getAlignedSeq2()); } @@ -149,6 +155,8 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel { printScoreMatrix(seqs, scores, totscore); } + + alignmentOutput = sb.toString(); } public float[][] getScores() @@ -161,6 +169,11 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel return this.alignmentScores; } + public String getAlignmentOutput() + { + return this.alignmentOutput; + } + /** * Prints a matrix of seqi-seqj pairwise alignment scores to sysout * diff --git a/src/jalview/jbgui/GPCAPanel.java b/src/jalview/jbgui/GPCAPanel.java index ec5b209..db260be 100755 --- a/src/jalview/jbgui/GPCAPanel.java +++ b/src/jalview/jbgui/GPCAPanel.java @@ -222,6 +222,17 @@ public class GPCAPanel extends JInternalFrame print_actionPerformed(); } }); + JMenuItem outputAlignment = new JMenuItem(); + outputAlignment.setText( + MessageManager.getString("label.output_alignment")); + outputAlignment.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + outputAlignment_actionPerformed(); + } + }); viewMenu.setText(MessageManager.getString("action.view")); viewMenu.addMenuListener(new MenuListener() { @@ -300,6 +311,7 @@ public class GPCAPanel extends JInternalFrame fileMenu.add(originalSeqData); fileMenu.add(outputPoints); fileMenu.add(outputProjPoints); + fileMenu.add(outputAlignment); saveMenu.add(eps); saveMenu.add(png); viewMenu.add(showLabels); @@ -319,6 +331,10 @@ public class GPCAPanel extends JInternalFrame { } + protected void outputAlignment_actionPerformed() + { + } + public void makePCAImage(TYPE imageType) { } diff --git a/src/jalview/viewmodel/PaSiMapModel.java b/src/jalview/viewmodel/PaSiMapModel.java index 4cc831a..84cc366 100644 --- a/src/jalview/viewmodel/PaSiMapModel.java +++ b/src/jalview/viewmodel/PaSiMapModel.java @@ -167,6 +167,11 @@ public class PaSiMapModel return pasimap.getDetails(); } + public String getAlignmentOutput() + { + return pasimap.getAlignmentOutput(); + } + public AlignmentViewport getInputData() { return inputData; -- 1.7.10.2