2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import java.awt.event.*;
26 import jalview.analysis.*;
27 import jalview.datamodel.*;
28 import jalview.jbgui.*;
29 import jalview.util.MessageManager;
37 public class PairwiseAlignPanel extends GPairwiseAlignPanel
45 * Creates a new PairwiseAlignPanel object.
50 public PairwiseAlignPanel(AlignViewport av)
55 sequences = new Vector();
58 String[] seqStrings = av.getViewAsString(true);
60 if (av.getSelectionGroup() == null)
62 seqs = av.getAlignment().getSequencesArray();
66 seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
69 String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
72 float[][] scores = new float[seqs.length][seqs.length];
74 int count = seqs.length;
78 for (int i = 1; i < count; i++)
80 for (int j = 0; j < i; j++)
83 AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
86 if (as.s1str.length() == 0 || as.s2str.length() == 0)
94 as.printAlignment(System.out);
95 scores[i][j] = (float) as.getMaxScore()
96 / (float) as.getASeq1().length;
97 totscore = totscore + scores[i][j];
99 textarea.append(as.getOutput());
100 seq = new Sequence(as.getS1().getName(), as.getAStr1(), as.getS1()
101 .getStart(), as.getS1().getEnd());
104 seq = new Sequence(as.getS2().getName(), as.getAStr2(), as.getS2()
105 .getStart(), as.getS2().getEnd());
113 .println("Pairwise alignment scaled similarity score matrix\n");
115 for (int i = 0; i < count; i++)
117 jalview.util.Format.print(System.out, "%s \n", ("" + i) + " "
118 + seqs[i].getName());
121 System.out.println("\n");
123 for (int i = 0; i < count; i++)
125 for (int j = 0; j < i; j++)
127 jalview.util.Format.print(System.out, "%7.3f", scores[i][j]
132 System.out.println("\n");
142 protected void viewInEditorButton_actionPerformed(ActionEvent e)
144 Sequence[] seq = new Sequence[sequences.size()];
146 for (int i = 0; i < sequences.size(); i++)
148 seq[i] = (Sequence) sequences.elementAt(i);
151 AlignFrame af = new AlignFrame(new Alignment(seq),
152 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
154 Desktop.addInternalFrame(af,
155 MessageManager.getString("label.pairwise_aligned_sequences"),
156 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);