2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 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 extends GPairwiseAlignPanel
43 * Creates a new PairwiseAlignPanel object.
48 public PairwiseAlignPanel(AlignViewport av)
53 sequences = new Vector();
56 String[] seqStrings = av.getViewAsString(true);
58 if (av.getSelectionGroup() == null)
60 seqs = av.alignment.getSequencesArray();
64 seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
67 String type = (av.alignment.isNucleotide()) ? AlignSeq.DNA
70 float[][] scores = new float[seqs.length][seqs.length];
72 int count = seqs.length;
76 for (int i = 1; i < count; i++)
78 for (int j = 0; j < i; j++)
81 AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
84 if (as.s1str.length() == 0 || as.s2str.length() == 0)
92 as.printAlignment(System.out);
93 scores[i][j] = (float) as.getMaxScore()
94 / (float) as.getASeq1().length;
95 totscore = totscore + scores[i][j];
97 textarea.append(as.getOutput());
98 seq = new Sequence(as.getS1().getName(), as.getAStr1(), as.getS1()
99 .getStart(), as.getS1().getEnd());
102 seq = new Sequence(as.getS2().getName(), as.getAStr2(), as.getS2()
103 .getStart(), as.getS2().getEnd());
111 .println("Pairwise alignment scaled similarity score matrix\n");
113 for (int i = 0; i < count; i++)
115 jalview.util.Format.print(System.out, "%s \n", ("" + i) + " "
116 + seqs[i].getName());
119 System.out.println("\n");
121 for (int i = 0; i < count; i++)
123 for (int j = 0; j < i; j++)
125 jalview.util.Format.print(System.out, "%7.3f", scores[i][j]
130 System.out.println("\n");
140 protected void viewInEditorButton_actionPerformed(ActionEvent e)
142 Sequence[] seq = new Sequence[sequences.size()];
144 for (int i = 0; i < sequences.size(); i++)
146 seq[i] = (Sequence) sequences.elementAt(i);
149 AlignFrame af = new AlignFrame(new Alignment(seq),
150 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
152 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
153 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);