JAL-2939 pull up set/IsNormalise[HMM]SequenceLogo
[jalview.git] / test / jalview / gui / PairwiseAlignmentPanelTest.java
1 package jalview.gui;
2
3 import static org.testng.Assert.assertEquals;
4
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;
11
12 import javax.swing.JTextArea;
13
14 import org.testng.annotations.Test;
15
16 import junit.extensions.PA;
17
18 public class PairwiseAlignmentPanelTest
19 {
20   @Test(groups = "Functional")
21   public void testConstructor_withSelectionGroup()
22   {
23     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
24             "examples/uniref50.fa", DataSourceType.FILE);
25     AlignViewportI viewport = af.getViewport();
26     AlignmentI al = viewport.getAlignment();
27
28     /*
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
32      */
33     SequenceGroup sg = new SequenceGroup();
34     sg.addSequence(al.getSequenceAt(3), false);
35     sg.addSequence(al.getSequenceAt(4), false);
36     sg.setStartRes(28);
37     sg.setEndRes(35);
38     viewport.setSelectionGroup(sg);
39
40     PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
41
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);
49   }
50
51   /**
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.
56    */
57   @Test(groups = "Functional")
58   public void testConstructor_noSelectionGroup()
59   {
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();
64
65     PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
66
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);
74   }
75 }