2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
21 import jalview.analysis.*;
\r
23 import jalview.datamodel.*;
\r
25 import jalview.jbgui.*;
\r
27 import java.awt.event.*;
\r
36 * @version $Revision$
\r
38 public class PairwiseAlignPanel extends GPairwiseAlignPanel
\r
40 Vector sequences = new Vector();
\r
44 * Creates a new PairwiseAlignPanel object.
\r
46 * @param av DOCUMENT ME!
\r
48 public PairwiseAlignPanel(AlignViewport av)
\r
53 Vector selsubset = new Vector();
\r
55 for (int i = 0, j = av.getSelectionGroup().getSize(); i < j; i++)
\r
57 if (av.getAlignment().getSequences().contains(av.getSelectionGroup()
\r
60 selsubset.add(av.getSelectionGroup().getSequenceAt(i));
\r
64 float[][] scores = new float[selsubset.size()][selsubset.size()];
\r
65 double totscore = 0;
\r
66 int count = selsubset.size();
\r
70 for (int i = 1; i < count; i++)
\r
72 for (int j = 0; j < i; j++)
\r
76 AlignSeq as = new AlignSeq((SequenceI) selsubset.elementAt(i),
\r
77 (SequenceI) selsubset.elementAt(j), "pep");
\r
78 as.calcScoreMatrix();
\r
79 as.traceAlignment();
\r
80 as.printAlignment();
\r
81 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
\r
82 totscore = totscore + scores[i][j];
\r
84 textarea.append(as.getOutput());
\r
85 sequences.add(new Sequence(as.getS1().getName(), as.getAStr1()));
\r
86 sequences.add(new Sequence(as.getS2().getName(), as.getAStr2()));
\r
93 "Pairwise alignment scaled similarity score matrix\n");
\r
95 for (int i = 0; i < count; i++)
\r
97 jalview.util.Format.print(System.out, "%s \n",
\r
99 ((SequenceI) selsubset.elementAt(i)).getName());
\r
102 System.out.println("\n");
\r
104 for (int i = 0; i < count; i++)
\r
106 for (int j = 0; j < i; j++)
\r
108 jalview.util.Format.print(System.out, "%7.3f",
\r
109 scores[i][j] / totscore);
\r
113 System.out.println("\n");
\r
120 * @param e DOCUMENT ME!
\r
122 protected void viewInEditorButton_actionPerformed(ActionEvent e)
\r
124 Sequence[] seq = new Sequence[sequences.size()];
\r
126 for (int i = 0; i < sequences.size(); i++)
\r
128 seq[i] = (Sequence) sequences.elementAt(i);
\r
131 AlignFrame af = new AlignFrame(new Alignment(seq));
\r
132 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
\r
133 AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);
\r