Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:38:20 GMT
  2. Package jalview.datamodel

File CigarArrayTest.java

 

Code metrics

0
59
2
1
141
77
2
0.03
29.5
2
1

Classes

Class Line # Actions
CigarArrayTest 30 59 2
0.00%
 

Contributing tests

No tests hitting this source file were found.

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