2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 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
21 import jalview.analysis.*;
23 import jalview.datamodel.*;
25 import jalview.jbgui.*;
27 import java.awt.event.*;
38 public class PairwiseAlignPanel extends GPairwiseAlignPanel
45 * Creates a new PairwiseAlignPanel object.
47 * @param av DOCUMENT ME!
49 public PairwiseAlignPanel(AlignViewport av)
54 sequences = new Vector();
57 String [] seqStrings = av.getViewAsString(true);
59 if(av.getSelectionGroup()==null)
61 seqs = av.alignment.getSequencesArray();
65 seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
68 String type=(av.alignment.isNucleotide()) ? AlignSeq.DNA : AlignSeq.PEP;
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],
82 seqs[j], seqStrings[j], type);
84 if(as.s1str.length()==0 || as.s2str.length()==0)
93 as.printAlignment(System.out);
94 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
95 totscore = totscore + scores[i][j];
97 textarea.append(as.getOutput());
98 seq = new Sequence(as.getS1().getName(),
100 as.getS1().getStart(),
105 seq = new Sequence(as.getS2().getName(),
107 as.getS2().getStart(),
108 as.getS2().getEnd() );
116 "Pairwise alignment scaled similarity score matrix\n");
118 for (int i = 0; i < count; i++)
120 jalview.util.Format.print(System.out, "%s \n",
125 System.out.println("\n");
127 for (int i = 0; i < count; i++)
129 for (int j = 0; j < i; j++)
131 jalview.util.Format.print(System.out, "%7.3f",
132 scores[i][j] / totscore);
136 System.out.println("\n");
143 * @param e DOCUMENT ME!
145 protected void viewInEditorButton_actionPerformed(ActionEvent e)
147 Sequence[] seq = new Sequence[sequences.size()];
149 for (int i = 0; i < sequences.size(); i++)
151 seq[i] = (Sequence) sequences.elementAt(i);
154 AlignFrame af = new AlignFrame(new Alignment(seq),
155 AlignFrame.DEFAULT_WIDTH,
156 AlignFrame.DEFAULT_HEIGHT);
158 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
159 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);