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
45 * Creates a new PairwiseAlignPanel object.
\r
47 * @param av DOCUMENT ME!
\r
49 public PairwiseAlignPanel(AlignViewport av)
\r
54 sequences = new Vector();
\r
57 String [] seqStrings = av.getSelectionAsString();
\r
59 if(av.getSelectionGroup()==null)
\r
61 seqs = av.alignment.getSequencesArray();
\r
65 seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
\r
69 float[][] scores = new float[seqs.length][seqs.length];
\r
70 double totscore = 0;
\r
71 int count = seqs.length;
\r
75 for (int i = 1; i < count; i++)
\r
77 for (int j = 0; j < i; j++)
\r
80 AlignSeq as = new AlignSeq(seqs[i], seqStrings[i],
\r
81 seqs[j], seqStrings[j], "pep");
\r
83 if(as.s1str.length()==0 || as.s2str.length()==0)
\r
88 as.calcScoreMatrix();
\r
89 as.traceAlignment();
\r
92 as.printAlignment(System.out);
\r
93 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
\r
94 totscore = totscore + scores[i][j];
\r
96 textarea.append(as.getOutput());
\r
97 seq = new Sequence(as.getS1().getName(),
\r
99 as.getS1().getStart(),
\r
100 as.getS1().getEnd()
\r
102 sequences.add(seq);
\r
104 seq = new Sequence(as.getS2().getName(),
\r
106 as.getS2().getStart(),
\r
107 as.getS2().getEnd() );
\r
108 sequences.add(seq);
\r
114 System.out.println(
\r
115 "Pairwise alignment scaled similarity score matrix\n");
\r
117 for (int i = 0; i < count; i++)
\r
119 jalview.util.Format.print(System.out, "%s \n",
\r
121 seqs[i].getName());
\r
124 System.out.println("\n");
\r
126 for (int i = 0; i < count; i++)
\r
128 for (int j = 0; j < i; j++)
\r
130 jalview.util.Format.print(System.out, "%7.3f",
\r
131 scores[i][j] / totscore);
\r
135 System.out.println("\n");
\r
142 * @param e DOCUMENT ME!
\r
144 protected void viewInEditorButton_actionPerformed(ActionEvent e)
\r
146 Sequence[] seq = new Sequence[sequences.size()];
\r
148 for (int i = 0; i < sequences.size(); i++)
\r
150 seq[i] = (Sequence) sequences.elementAt(i);
\r
153 AlignFrame af = new AlignFrame(new Alignment(seq));
\r
154 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
\r
155 AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);
\r