Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 16:01:40 GMT
  2. Package jalview.datamodel

File AlignmentViewTest.java

 

Code metrics

0
45
3
1
122
71
3
0.07
15
3
1

Classes

Class Line # Actions
AlignmentViewTest 34 45 3
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.datamodel;
22   
23    import static org.testng.Assert.assertEquals;
24   
25    import jalview.gui.AlignFrame;
26    import jalview.gui.AlignViewport;
27    import jalview.gui.JvOptionPane;
28    import jalview.io.DataSourceType;
29    import jalview.io.FileLoader;
30   
31    import org.testng.annotations.BeforeClass;
32    import org.testng.annotations.Test;
33   
 
34    public class AlignmentViewTest
35    {
36   
 
37  1 toggle @BeforeClass(alwaysRun = true)
38    public void setUpJvOptionPane()
39    {
40  1 JvOptionPane.setInteractiveMode(false);
41  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
42    }
43   
 
44  1 toggle @Test(groups = { "Functional" })
45    public void testGetVisibleAlignmentGapChar()
46    {
47  1 SeqCigar ss = new SeqCigar(new Sequence("One", "A..CDE"));
48  1 CigarArray ca = new CigarArray(new CigarSimple[] { ss });
49  1 AlignmentView av = new AlignmentView(ca);
50  1 String dots = av.getSequenceStrings('.')[0];
51  1 assertEquals(dots, "A..CDE");
52  1 String dollars = av.getSequenceStrings('$')[0];
53  1 assertEquals(dollars, "A$$CDE");
54  1 assertEquals(av.getVisibleAlignment('$').getSequenceAt(0)
55    .getSequenceAsString(), "A$$CDE");
56    }
57   
 
58  1 toggle @Test(groups = { "Functional" })
59    public void testGetVisibleContigs()
60    {
61  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
62    ">s1\n0123456789\n", DataSourceType.PASTE);
63  1 AlignViewport av = af.getViewport();
64  1 AlignmentView view = av.getAlignmentView(true);
65   
66    /*
67    * verify getVisibleContigs returns inclusive [start, end] ranges
68    *
69    * no columns hidden
70    */
71  1 int[] contigs = view.getVisibleContigs();
72  1 assertEquals(contigs, new int[] { 0, 9 });
73   
74    /*
75    * hide 3 internal columns
76    */
77  1 av.hideColumns(5, 7);
78    // the old AlignmentView is now stale!
79  1 contigs = view.getVisibleContigs();
80  1 assertEquals(contigs, new int[] { 0, 9 });
81    // get a fresh AlignmentView
82  1 view = av.getAlignmentView(true);
83  1 contigs = view.getVisibleContigs();
84  1 assertEquals(contigs, new int[] { 0, 4, 8, 9 });
85   
86    // hide first 2 columns
87  1 av.hideColumns(0, 1);
88  1 view = av.getAlignmentView(true);
89  1 contigs = view.getVisibleContigs();
90  1 assertEquals(contigs, new int[] { 2, 4, 8, 9 });
91   
92    // hide last column
93  1 av.hideColumns(9, 9);
94  1 view = av.getAlignmentView(true);
95  1 contigs = view.getVisibleContigs();
96  1 assertEquals(contigs, new int[] { 2, 4, 8, 8 });
97   
98    // unhide columns 5-7
99  1 av.showColumn(5);
100  1 view = av.getAlignmentView(true);
101  1 contigs = view.getVisibleContigs();
102  1 assertEquals(contigs, new int[] { 2, 8 });
103   
104    // hide columns 2-7
105  1 av.hideColumns(2, 7);
106  1 view = av.getAlignmentView(true);
107  1 contigs = view.getVisibleContigs();
108  1 assertEquals(contigs, new int[] { 8, 8 });
109   
110    // hide column 8
111  1 av.hideColumns(8, 8);
112  1 view = av.getAlignmentView(true);
113  1 contigs = view.getVisibleContigs();
114  1 assertEquals(contigs, new int[] {});
115   
116    // unhide all
117  1 av.showAllHiddenColumns();
118  1 view = av.getAlignmentView(true);
119  1 contigs = view.getVisibleContigs();
120  1 assertEquals(contigs, new int[] { 0, 9 });
121    }
122    }