2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 import java.awt.event.*;
25 import jalview.analysis.*;
26 import jalview.datamodel.*;
27 import jalview.jbgui.*;
35 public class PairwiseAlignPanel
36 extends GPairwiseAlignPanel
43 * Creates a new PairwiseAlignPanel object.
45 * @param av DOCUMENT ME!
47 public PairwiseAlignPanel(AlignViewport av)
52 sequences = new Vector();
55 String[] seqStrings = av.getViewAsString(true);
57 if (av.getSelectionGroup() == null)
59 seqs = av.alignment.getSequencesArray();
63 seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
66 String type = (av.alignment.isNucleotide()) ? AlignSeq.DNA : AlignSeq.PEP;
68 float[][] scores = new float[seqs.length][seqs.length];
70 int count = seqs.length;
74 for (int i = 1; i < count; i++)
76 for (int j = 0; j < i; j++)
79 AlignSeq as = new AlignSeq(seqs[i], seqStrings[i],
80 seqs[j], seqStrings[j], type);
82 if (as.s1str.length() == 0 || as.s2str.length() == 0)
90 as.printAlignment(System.out);
91 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
92 totscore = totscore + scores[i][j];
94 textarea.append(as.getOutput());
95 seq = new Sequence(as.getS1().getName(),
97 as.getS1().getStart(),
102 seq = new Sequence(as.getS2().getName(),
104 as.getS2().getStart(),
105 as.getS2().getEnd());
113 "Pairwise alignment scaled similarity score matrix\n");
115 for (int i = 0; i < count; i++)
117 jalview.util.Format.print(System.out, "%s \n",
122 System.out.println("\n");
124 for (int i = 0; i < count; i++)
126 for (int j = 0; j < i; j++)
128 jalview.util.Format.print(System.out, "%7.3f",
129 scores[i][j] / totscore);
133 System.out.println("\n");
140 * @param e DOCUMENT ME!
142 protected void viewInEditorButton_actionPerformed(ActionEvent e)
144 Sequence[] seq = new Sequence[sequences.size()];
146 for (int i = 0; i < sequences.size(); i++)
148 seq[i] = (Sequence) sequences.elementAt(i);
151 AlignFrame af = new AlignFrame(new Alignment(seq),
152 AlignFrame.DEFAULT_WIDTH,
153 AlignFrame.DEFAULT_HEIGHT);
155 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
156 AlignFrame.DEFAULT_WIDTH,
157 AlignFrame.DEFAULT_HEIGHT);