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
20 package jalview.appletgui;
\r
22 import jalview.datamodel.*;
\r
23 import jalview.jbappletgui.GPairwiseAlignPanel;
\r
24 import jalview.analysis.*;
\r
25 import java.awt.event.*;
\r
29 public class PairwiseAlignPanel extends GPairwiseAlignPanel
\r
31 Vector sequences = new Vector();
\r
34 public PairwiseAlignPanel(AlignViewport av)
\r
38 float scores[][] = new float[av.getAlignment().getHeight()][av.getAlignment().getHeight()];
\r
39 double totscore = 0;
\r
40 int count = av.getSelectionGroup().getSize();
\r
43 for (int i = 1; i < count; i++)
\r
45 for (int j = 0; j < i; j++)
\r
48 AlignSeq as = new AlignSeq(av.getSelectionGroup().getSequenceAt(i),
\r
49 av.getSelectionGroup().getSequenceAt(j),"pep");
\r
51 as.calcScoreMatrix();
\r
52 as.traceAlignment();
\r
53 as.printAlignment();
\r
54 scores[i][j] = (float)as.getMaxScore()/(float)as.getASeq1().length;
\r
55 totscore = totscore + scores[i][j];
\r
57 textarea.append(as.getOutput());
\r
58 sequences.addElement( new Sequence( as.getS1().getName(), as.getAStr1()) );
\r
59 sequences.addElement( new Sequence( as.getS2().getName(), as.getAStr2()) );
\r
67 for (int i = 0; i < count;i++)
\r
68 for (int j = 0; j < i; j++)
\r
69 jalview.util.Format.print(System.out,"%7.3f",scores[i][j]/totscore);
\r
74 protected void viewInEditorButton_actionPerformed(ActionEvent e)
\r
77 Sequence [] seq = new Sequence[sequences.size()];
\r
79 for (int i=0;i<sequences.size();i++)
\r
80 seq[i] = (Sequence) sequences.elementAt(i);
\r
83 AlignFrame af = new AlignFrame(new Alignment(seq));
\r
84 jalview.bin.JalviewLite.addFrame(af, "Pairwise Aligned Sequences",
\r
85 AlignFrame.NEW_WINDOW_WIDTH,
\r
86 AlignFrame.NEW_WINDOW_HEIGHT);
\r