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 static org.testng.Assert.assertEquals;
25 import jalview.api.AlignViewportI;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.SequenceGroup;
28 import jalview.io.DataSourceType;
29 import jalview.io.FileLoader;
30 import javax.swing.JTextArea;
32 import org.testng.annotations.Test;
34 import junit.extensions.PA;
36 public class PairwiseAlignmentPanelTest
38 @Test(groups = "Functional")
39 public void testConstructor_withSelectionGroup()
41 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
42 "examples/uniref50.fa", DataSourceType.FILE);
43 AlignViewportI viewport = af.getViewport();
44 AlignmentI al = viewport.getAlignment();
47 * select columns 29-36 of sequences 4 and 5 for alignment
48 * Q93XJ9_SOLTU/23-29 L-KAISNV
49 * FER1_PEA/26-32 V-TTTKAF
51 SequenceGroup sg = new SequenceGroup();
52 sg.addSequence(al.getSequenceAt(3), false);
53 sg.addSequence(al.getSequenceAt(4), false);
56 viewport.setSelectionGroup(sg);
58 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
60 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText().replace("\r\n", "\n");
61 String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
62 + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
63 + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
64 + " FER1_PEA/29-32 TKAF\n" + " ||.\n"
65 + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n";
66 assertEquals(text, expected);
70 * This test aligns the same sequences as testConstructor_withSelectionGroup
71 * but as a complete alignment (no selection). Note that in fact the user is
72 * currently required to make a selection in order to calculate pairwise
73 * alignments, so this case does not arise.
75 @Test(groups = "Functional")
76 public void testConstructor_noSelectionGroup()
78 String seqs = ">Q93XJ9_SOLTU/23-29\nL-KAISNV\n>FER1_PEA/26-32\nV-TTTKAF\n";
79 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqs,
80 DataSourceType.PASTE);
81 AlignViewportI viewport = af.getViewport();
83 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
85 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText().replace("\r\n", "\n");
86 String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
87 + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
88 + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
89 + " FER1_PEA/29-32 TKAF\n" + " ||.\n"
90 + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n";
91 assertEquals(text, expected);