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);
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],
81 seqs[j], seqStrings[j], "pep");
83 if(as.s1str.length()==0 || as.s2str.length()==0)
92 as.printAlignment(System.out);
93 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;
94 totscore = totscore + scores[i][j];
96 textarea.append(as.getOutput());
97 seq = new Sequence(as.getS1().getName(),
99 as.getS1().getStart(),
104 seq = new Sequence(as.getS2().getName(),
106 as.getS2().getStart(),
107 as.getS2().getEnd() );
115 "Pairwise alignment scaled similarity score matrix\n");
117 for (int i = 0; i < count; i++)
119 jalview.util.Format.print(System.out, "%s \n",
124 System.out.println("\n");
126 for (int i = 0; i < count; i++)
128 for (int j = 0; j < i; j++)
130 jalview.util.Format.print(System.out, "%7.3f",
131 scores[i][j] / totscore);
135 System.out.println("\n");
142 * @param e DOCUMENT ME!
144 protected void viewInEditorButton_actionPerformed(ActionEvent e)
146 Sequence[] seq = new Sequence[sequences.size()];
148 for (int i = 0; i < sequences.size(); i++)
150 seq[i] = (Sequence) sequences.elementAt(i);
153 AlignFrame af = new AlignFrame(new Alignment(seq));
154 Desktop.addInternalFrame(af, "Pairwise Aligned Sequences",
155 AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);