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
24 import java.awt.event.*;
\r
26 import jalview.analysis.*;
\r
27 import jalview.datamodel.*;
\r
30 public class PairwiseAlignPanel
\r
31 extends Panel implements ActionListener
\r
33 Vector sequences = new Vector();
\r
36 public PairwiseAlignPanel(AlignmentPanel ap)
\r
44 e.printStackTrace();
\r
47 float scores[][] = new float[ap.av.alignment.getHeight()][ap.av.alignment.
\r
49 double totscore = 0;
\r
50 int count = ap.av.getSelectionGroup().getSize(false);
\r
53 for (int i = 1; i < count; i++)
\r
55 for (int j = 0; j < i; j++)
\r
57 AlignSeq as = new AlignSeq(ap.av.getSelectionGroup().getSequenceAt(i),
\r
58 ap.av.getSelectionGroup().getSequenceAt(j),
\r
61 if (as.s1str.length() == 0 || as.s2str.length() == 0)
\r
66 as.calcScoreMatrix();
\r
67 as.traceAlignment();
\r
68 as.printAlignment(System.out);
\r
69 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
\r
70 totscore = totscore + scores[i][j];
\r
72 textarea.append(as.getOutput());
\r
74 seq = new Sequence(as.getS1().getName(),
\r
76 as.getS1().getStart(), as.getS1().getEnd()
\r
78 sequences.addElement(seq);
\r
80 seq = new Sequence(as.getS2().getName(),
\r
82 as.getS2().getStart(), as.getS2().getEnd()
\r
85 sequences.addElement(seq);
\r
91 for (int i = 0; i < count; i++)
\r
93 for (int j = 0; j < i; j++)
\r
95 jalview.util.Format.print(System.out, "%7.3f",
\r
96 scores[i][j] / totscore);
\r
102 public void actionPerformed(ActionEvent evt)
\r
104 if(evt.getSource()==viewInEditorButton)
\r
105 viewInEditorButton_actionPerformed();
\r
108 protected void viewInEditorButton_actionPerformed()
\r
111 Sequence[] seq = new Sequence[sequences.size()];
\r
113 for (int i = 0; i < sequences.size(); i++)
\r
115 seq[i] = (Sequence) sequences.elementAt(i);
\r
118 new AlignFrame(new Alignment(seq),
\r
119 ap.alignFrame.applet,
\r
120 "Pairwise Aligned Sequences",
\r
124 protected ScrollPane scrollPane = new ScrollPane();
\r
125 protected TextArea textarea = new TextArea();
\r
126 protected Button viewInEditorButton = new Button();
\r
127 Panel jPanel1 = new Panel();
\r
128 BorderLayout borderLayout1 = new BorderLayout();
\r
130 private void jbInit() throws Exception {
\r
131 this.setLayout(borderLayout1);
\r
132 textarea.setFont(new java.awt.Font("Monospaced", 0, 12));
\r
133 textarea.setText("");
\r
134 viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12));
\r
135 viewInEditorButton.setLabel("View in alignment editor");
\r
136 viewInEditorButton.addActionListener(this);
\r
137 this.add(scrollPane, BorderLayout.CENTER);
\r
138 scrollPane.add(textarea);
\r
139 this.add(jPanel1, BorderLayout.SOUTH);
\r
140 jPanel1.add(viewInEditorButton, null);
\r