2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.datamodel;
23 import static org.testng.Assert.assertEquals;
25 import jalview.gui.JvOptionPane;
27 import org.testng.annotations.BeforeClass;
28 import org.testng.annotations.Test;
30 public class CigarArrayTest
32 @BeforeClass(alwaysRun = true)
33 public void setUpJvOptionPane()
35 JvOptionPane.setInteractiveMode(false);
36 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
39 @Test(groups = "Functional")
40 public void testConstructor()
42 SequenceI seq1 = new Sequence("sq1",
43 "ASFDDABACBACBACBACBACBACBABCABCBACBABCAB");
44 Sequence seq2 = new Sequence("sq2",
45 "TTTTTTACBCBABCABCABCABCBACBACBABCABCABCBA");
47 // construct alignment
48 AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
51 HiddenColumns hc = new HiddenColumns();
53 hc.hideColumns(16, 20);
56 SequenceGroup sg1 = new SequenceGroup();
57 sg1.addSequence(seq1, false);
61 // Cigar array meanings:
65 // number preceding M/D/I is the number of residues which
66 // match/are deleted/are inserted
67 // In the CigarArray constructor only matches or deletions are created, as
68 // we are comparing a sequence to its own subsequence (the group) + hidden
71 CigarArray cig = new CigarArray(al, hc, sg1);
72 String result = cig.getCigarstring();
73 assertEquals(result, "1M4D9M5D3M");
75 // group starts at hidden cols
77 cig = new CigarArray(al, hc, sg1);
78 result = cig.getCigarstring();
79 assertEquals(result, "4D9M5D3M");
81 // group starts at last but 1 hidden col
83 cig = new CigarArray(al, hc, sg1);
84 result = cig.getCigarstring();
85 assertEquals(result, "2D9M5D3M");
87 // group starts at last hidden col
89 cig = new CigarArray(al, hc, sg1);
90 result = cig.getCigarstring();
91 assertEquals(result, "1D9M5D3M");
93 // group starts just after hidden region
95 cig = new CigarArray(al, hc, sg1);
96 result = cig.getCigarstring();
97 assertEquals(result, "9M5D3M");
99 // group ends just before start of hidden region
102 cig = new CigarArray(al, hc, sg1);
103 result = cig.getCigarstring();
104 assertEquals(result, "2D9M");
106 // group ends at start of hidden region
108 cig = new CigarArray(al, hc, sg1);
109 result = cig.getCigarstring();
110 assertEquals(result, "2D9M1D");
112 // group ends 1 after start of hidden region
114 cig = new CigarArray(al, hc, sg1);
115 result = cig.getCigarstring();
116 assertEquals(result, "2D9M2D");
118 // group ends at end of hidden region
120 cig = new CigarArray(al, hc, sg1);
121 result = cig.getCigarstring();
122 assertEquals(result, "2D9M5D");
124 // group ends just after end of hidden region
126 cig = new CigarArray(al, hc, sg1);
127 result = cig.getCigarstring();
128 assertEquals(result, "2D9M5D1M");
130 // group ends 2 after end of hidden region
132 cig = new CigarArray(al, hc, sg1);
133 result = cig.getCigarstring();
134 assertEquals(result, "2D9M5D2M");