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
54 for (int i = 1; i < count; i++)
\r
56 for (int j = 0; j < i; j++)
\r
59 AlignSeq as = new AlignSeq(ap.av.getSelectionGroup().getSequenceAt(i),
\r
60 ap.av.getSelectionGroup().getSequenceAt(j),
\r
63 as.calcScoreMatrix();
\r
64 as.traceAlignment();
\r
65 as.printAlignment(System.out);
\r
66 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
\r
67 totscore = totscore + scores[i][j];
\r
69 textarea.append(as.getOutput());
\r
71 seq = new Sequence(as.getS1().getName(),
\r
73 as.getS1().getStart(), as.getS1().getEnd()
\r
75 sequences.addElement(seq);
\r
77 seq = new Sequence(as.getS2().getName(),
\r
79 as.getS2().getStart(), as.getS2().getEnd()
\r
82 sequences.addElement(seq);
\r
88 for (int i = 0; i < count; i++)
\r
90 for (int j = 0; j < i; j++)
\r
92 jalview.util.Format.print(System.out, "%7.3f",
\r
93 scores[i][j] / totscore);
\r
99 public void actionPerformed(ActionEvent evt)
\r
101 if(evt.getSource()==viewInEditorButton)
\r
102 viewInEditorButton_actionPerformed();
\r
105 protected void viewInEditorButton_actionPerformed()
\r
108 Sequence[] seq = new Sequence[sequences.size()];
\r
110 for (int i = 0; i < sequences.size(); i++)
\r
112 seq[i] = (Sequence) sequences.elementAt(i);
\r
115 new AlignFrame(new Alignment(seq),
\r
116 ap.alignFrame.applet,
\r
117 "Pairwise Aligned Sequences",
\r
121 protected ScrollPane scrollPane = new ScrollPane();
\r
122 protected TextArea textarea = new TextArea();
\r
123 protected Button viewInEditorButton = new Button();
\r
124 Panel jPanel1 = new Panel();
\r
125 BorderLayout borderLayout1 = new BorderLayout();
\r
127 private void jbInit() throws Exception {
\r
128 this.setLayout(borderLayout1);
\r
129 textarea.setFont(new java.awt.Font("Monospaced", 0, 12));
\r
130 textarea.setText("");
\r
131 viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12));
\r
132 viewInEditorButton.setLabel("View in alignment editor");
\r
133 viewInEditorButton.addActionListener(this);
\r
134 this.add(scrollPane, BorderLayout.CENTER);
\r
135 scrollPane.add(textarea);
\r
136 this.add(jPanel1, BorderLayout.SOUTH);
\r
137 jPanel1.add(viewInEditorButton, null);
\r