2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AlignSeq;
24 import jalview.datamodel.Alignment;
25 import jalview.datamodel.Sequence;
26 import jalview.datamodel.SequenceI;
27 import jalview.jbgui.GPairwiseAlignPanel;
28 import jalview.util.Format;
29 import jalview.util.MessageManager;
30 import jalview.viewmodel.AlignmentViewport;
32 import java.awt.event.ActionEvent;
33 import java.util.Vector;
41 public class PairwiseAlignPanel extends GPairwiseAlignPanel
49 * Creates a new PairwiseAlignPanel object.
54 public PairwiseAlignPanel(AlignmentViewport av)
59 sequences = new Vector();
62 String[] seqStrings = av.getViewAsString(true);
64 if (av.getSelectionGroup() == null)
66 seqs = av.getAlignment().getSequencesArray();
70 seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
73 String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
76 float[][] scores = new float[seqs.length][seqs.length];
78 int count = seqs.length;
82 for (int i = 1; i < count; i++)
84 for (int j = 0; j < i; j++)
87 AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
90 if (as.s1str.length() == 0 || as.s2str.length() == 0)
98 as.printAlignment(System.out);
99 scores[i][j] = (float) as.getMaxScore()
100 / (float) as.getASeq1().length;
101 totscore = totscore + scores[i][j];
103 textarea.append(as.getOutput());
104 sequences.add(as.getAlignedSeq1());
105 sequences.add(as.getAlignedSeq2());
112 .println("Pairwise alignment scaled similarity score matrix\n");
114 for (int i = 0; i < count; i++)
116 Format.print(System.out, "%s \n",
117 ("" + i) + " " + seqs[i].getName());
120 System.out.println("\n");
122 for (int i = 0; i < count; i++)
124 for (int j = 0; j < i; j++)
126 Format.printDouble(System.out, "%7.3f", scores[i][j] / totscore);
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,
153 MessageManager.getString("label.pairwise_aligned_sequences"),
154 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);