JAL-2742 uncomment test
[jalview.git] / test / jalview / datamodel / CigarArrayTest.java
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.JvOptionPane;
26
27 import org.testng.annotations.BeforeClass;
28 import org.testng.annotations.Test;
29
30 public class CigarArrayTest
31 {
32   @BeforeClass(alwaysRun = true)
33   public void setUpJvOptionPane()
34   {
35     JvOptionPane.setInteractiveMode(false);
36     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
37   }
38
39   @Test(groups = "Functional")
40   public void TestConstructor()
41   {
42     SequenceI seq1 = new Sequence("sq1",
43             "ASFDDABACBACBACBACBACBACBABCABCBACBABCAB");
44     Sequence seq2 = new Sequence("sq2",
45             "TTTTTTACBCBABCABCABCABCBACBACBABCABCABCBA");
46
47     // construct alignment
48     AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
49
50     // hide columns
51     HiddenColumns hc = new HiddenColumns();
52     hc.hideColumns(3, 6);
53     hc.hideColumns(16, 20);
54
55     // select group
56     SequenceGroup sg1 = new SequenceGroup();
57     sg1.addSequence(seq1, false);
58     sg1.setStartRes(2);
59     sg1.setEndRes(23);
60
61     CigarArray cig = new CigarArray(al, hc, sg1);
62     String result = cig.getCigarstring();
63     assertEquals(result, "1M4D9M5D3M");
64
65     // group starts at hidden cols
66     sg1.setStartRes(3);
67     cig = new CigarArray(al, hc, sg1);
68     result = cig.getCigarstring();
69     assertEquals(result, "4D9M5D3M");
70
71     // group starts at last but 1 hidden col
72     sg1.setStartRes(5);
73     cig = new CigarArray(al, hc, sg1);
74     result = cig.getCigarstring();
75     assertEquals(result, "2D9M5D3M");
76
77     // group starts at last hidden col
78     sg1.setStartRes(6);
79     cig = new CigarArray(al, hc, sg1);
80     result = cig.getCigarstring();
81     assertEquals(result, "1D9M5D3M");
82
83     // group starts just after hidden region
84     sg1.setStartRes(7);
85     cig = new CigarArray(al, hc, sg1);
86     result = cig.getCigarstring();
87     assertEquals(result, "9M5D3M");
88
89     // group ends just before start of hidden region
90     sg1.setStartRes(5);
91     sg1.setEndRes(15);
92     cig = new CigarArray(al, hc, sg1);
93     result = cig.getCigarstring();
94     assertEquals(result, "2D9M");
95
96     // group ends at start of hidden region
97     sg1.setEndRes(16);
98     cig = new CigarArray(al, hc, sg1);
99     result = cig.getCigarstring();
100     assertEquals(result, "2D9M1D");
101
102     // group ends 1 after start of hidden region
103     sg1.setEndRes(17);
104     cig = new CigarArray(al, hc, sg1);
105     result = cig.getCigarstring();
106     assertEquals(result, "2D9M2D");
107
108     // group ends at end of hidden region
109     sg1.setEndRes(20);
110     cig = new CigarArray(al, hc, sg1);
111     result = cig.getCigarstring();
112     assertEquals(result, "2D9M5D");
113
114     // group ends just after end of hidden region
115     sg1.setEndRes(21);
116     cig = new CigarArray(al, hc, sg1);
117     result = cig.getCigarstring();
118     assertEquals(result, "2D9M5D1M");
119
120     // group ends 2 after end of hidden region
121     sg1.setEndRes(22);
122     cig = new CigarArray(al, hc, sg1);
123     result = cig.getCigarstring();
124     assertEquals(result, "2D9M5D2M");
125   }
126 }