Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.gui

File PairwiseAlignmentPanelTest.java

 

Code metrics

0
20
2
1
73
50
2
0.1
10
2
1

Classes

Class Line # Actions
PairwiseAlignmentPanelTest 16 20 2 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    package jalview.gui;
2   
3    import static org.testng.Assert.assertEquals;
4   
5    import jalview.datamodel.AlignmentI;
6    import jalview.datamodel.SequenceGroup;
7    import jalview.io.DataSourceType;
8    import jalview.io.FileLoader;
9   
10    import javax.swing.JTextArea;
11   
12    import junit.extensions.PA;
13   
14    import org.testng.annotations.Test;
15   
 
16    public class PairwiseAlignmentPanelTest
17    {
 
18  1 toggle @Test(groups = "Functional")
19    public void testConstructor_withSelectionGroup()
20    {
21  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
22    "examples/uniref50.fa", DataSourceType.FILE);
23  1 AlignViewport viewport = af.getViewport();
24  1 AlignmentI al = viewport.getAlignment();
25   
26    /*
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
30    */
31  1 SequenceGroup sg = new SequenceGroup();
32  1 sg.addSequence(al.getSequenceAt(3), false);
33  1 sg.addSequence(al.getSequenceAt(4), false);
34  1 sg.setStartRes(28);
35  1 sg.setEndRes(35);
36  1 viewport.setSelectionGroup(sg);
37   
38  1 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
39   
40  1 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
41  1 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  1 assertEquals(text, expected);
47    }
48   
49    /**
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.
54    */
 
55  1 toggle @Test(groups = "Functional")
56    public void testConstructor_noSelectionGroup()
57    {
58  1 String seqs = ">Q93XJ9_SOLTU/23-29\nL-KAISNV\n>FER1_PEA/26-32\nV-TTTKAF\n";
59  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqs,
60    DataSourceType.PASTE);
61  1 AlignViewport viewport = af.getViewport();
62   
63  1 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
64   
65  1 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
66  1 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  1 assertEquals(text, expected);
72    }
73    }