3 import static org.testng.Assert.assertEquals;
5 import jalview.api.AlignViewportI;
6 import jalview.datamodel.AlignmentI;
7 import jalview.datamodel.SequenceGroup;
8 import jalview.io.DataSourceType;
9 import jalview.io.FileLoader;
10 import jalview.viewmodel.AlignmentViewport;
12 import javax.swing.JTextArea;
14 import org.testng.annotations.Test;
16 import junit.extensions.PA;
18 public class PairwiseAlignmentPanelTest
20 @Test(groups = "Functional")
21 public void testConstructor_withSelectionGroup()
23 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
24 "examples/uniref50.fa", DataSourceType.FILE);
25 AlignViewportI viewport = af.getViewport();
26 AlignmentI al = viewport.getAlignment();
29 * select columns 29-36 of sequences 4 and 5 for alignment
30 * Q93XJ9_SOLTU/23-29 L-KAISNV
31 * FER1_PEA/26-32 V-TTTKAF
33 SequenceGroup sg = new SequenceGroup();
34 sg.addSequence(al.getSequenceAt(3), false);
35 sg.addSequence(al.getSequenceAt(4), false);
38 viewport.setSelectionGroup(sg);
40 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
42 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
43 String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
44 + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
45 + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
46 + " FER1_PEA/29-32 TKAF\n" + " ||.\n"
47 + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n";
48 assertEquals(text, expected);
52 * This test aligns the same sequences as testConstructor_withSelectionGroup
53 * but as a complete alignment (no selection). Note that in fact the user is
54 * currently required to make a selection in order to calculate pairwise
55 * alignments, so this case does not arise.
57 @Test(groups = "Functional")
58 public void testConstructor_noSelectionGroup()
60 String seqs = ">Q93XJ9_SOLTU/23-29\nL-KAISNV\n>FER1_PEA/26-32\nV-TTTKAF\n";
61 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqs,
62 DataSourceType.PASTE);
63 AlignViewportI viewport = af.getViewport();
65 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
67 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
68 String expected = "Score = 80.0\n" + "Length of alignment = 4\n"
69 + "Sequence FER1_PEA/29-32 (Sequence length = 7)\n"
70 + "Sequence Q93XJ9_SOLTU/23-26 (Sequence length = 7)\n\n"
71 + " FER1_PEA/29-32 TKAF\n" + " ||.\n"
72 + "Q93XJ9_SOLTU/23-26 LKAI\n\n" + "Percentage ID = 50.00\n\n";
73 assertEquals(text, expected);