Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 20:42:03 GMT
  2. Package jalview.gui

File PairwiseAlignmentPanelTest.java

 

Code metrics

0
20
2
1
93
50
2
0.1
10
2
1

Classes

Class Line # Actions
PairwiseAlignmentPanelTest 36 20 2
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.gui;
22   
23    import static org.testng.Assert.assertEquals;
24   
25    import jalview.datamodel.AlignmentI;
26    import jalview.datamodel.SequenceGroup;
27    import jalview.io.DataSourceType;
28    import jalview.io.FileLoader;
29   
30    import javax.swing.JTextArea;
31   
32    import junit.extensions.PA;
33   
34    import org.testng.annotations.Test;
35   
 
36    public class PairwiseAlignmentPanelTest
37    {
 
38  1 toggle @Test(groups = "Functional")
39    public void testConstructor_withSelectionGroup()
40    {
41  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
42    "examples/uniref50.fa", DataSourceType.FILE);
43  1 AlignViewport viewport = af.getViewport();
44  1 AlignmentI al = viewport.getAlignment();
45   
46    /*
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
50    */
51  1 SequenceGroup sg = new SequenceGroup();
52  1 sg.addSequence(al.getSequenceAt(3), false);
53  1 sg.addSequence(al.getSequenceAt(4), false);
54  1 sg.setStartRes(28);
55  1 sg.setEndRes(35);
56  1 viewport.setSelectionGroup(sg);
57   
58  1 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
59   
60  1 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
61  1 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  1 assertEquals(text, expected);
67    }
68   
69    /**
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.
74    */
 
75  1 toggle @Test(groups = "Functional")
76    public void testConstructor_noSelectionGroup()
77    {
78  1 String seqs = ">Q93XJ9_SOLTU/23-29\nL-KAISNV\n>FER1_PEA/26-32\nV-TTTKAF\n";
79  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqs,
80    DataSourceType.PASTE);
81  1 AlignViewport viewport = af.getViewport();
82   
83  1 PairwiseAlignPanel testee = new PairwiseAlignPanel(viewport);
84   
85  1 String text = ((JTextArea) PA.getValue(testee, "textarea")).getText();
86  1 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  1 assertEquals(text, expected);
92    }
93    }