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