2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
22 import java.awt.event.*;
24 import jalview.analysis.*;
25 import jalview.datamodel.*;
26 import jalview.jbgui.*;
34 public class PairwiseAlignPanel extends GPairwiseAlignPanel
42 * Creates a new PairwiseAlignPanel object.
47 public PairwiseAlignPanel(AlignViewport av)
52 sequences = new Vector();
55 String[] seqStrings = av.getViewAsString(true);
57 if (av.getSelectionGroup() == null)
59 seqs = av.getAlignment().getSequencesArray();
63 seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
66 String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
69 float[][] scores = new float[seqs.length][seqs.length];
71 int count = seqs.length;
75 for (int i = 1; i < count; i++)
77 for (int j = 0; j < i; j++)
80 AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
83 if (as.s1str.length() == 0 || as.s2str.length() == 0)
91 as.printAlignment(System.out);
92 scores[i][j] = (float) as.getMaxScore()
93 / (float) as.getASeq1().length;
94 totscore = totscore + scores[i][j];
96 textarea.append(as.getOutput());
97 seq = new Sequence(as.getS1().getName(), as.getAStr1(), as.getS1()
98 .getStart(), as.getS1().getEnd());
101 seq = new Sequence(as.getS2().getName(), as.getAStr2(), as.getS2()
102 .getStart(), as.getS2().getEnd());
110 .println("Pairwise alignment scaled similarity score matrix\n");
112 for (int i = 0; i < count; i++)
114 jalview.util.Format.print(System.out, "%s \n", ("" + i) + " "
115 + seqs[i].getName());
118 System.out.println("\n");
120 for (int i = 0; i < count; i++)
122 for (int j = 0; j < i; j++)
124 jalview.util.Format.print(System.out, "%7.3f", scores[i][j]
129 System.out.println("\n");
139 protected void viewInEditorButton_actionPerformed(ActionEvent e)
141 Sequence[] seq = new Sequence[sequences.size()];
143 for (int i = 0; i < sequences.size(); i++)
145 seq[i] = (Sequence) sequences.elementAt(i);
148 AlignFrame af = new AlignFrame(new Alignment(seq),
149 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
151 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
152 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);