Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 15:05:32 GMT
  2. Package jalview.datamodel

File ContactMatrixTest.java

 

Code metrics

16
29
9
1
150
98
18
0.62
3.22
9
2

Classes

Class Line # Actions
ContactMatrixTest 29 29 18
0.1296296313%
 

Contributing tests

This file is covered by 3 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 org.testng.Assert;
24    import org.testng.annotations.BeforeClass;
25    import org.testng.annotations.Test;
26   
27    import jalview.gui.JvOptionPane;
28   
 
29    public class ContactMatrixTest
30    {
 
31  1 toggle @BeforeClass(alwaysRun = true)
32    public void setUpJvOptionPane()
33    {
34  1 JvOptionPane.setInteractiveMode(false);
35  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
36    }
37   
38    /**
39    * standard asserts for ContactMatrixI
40    */
 
41  0 toggle public static void testContactMatrixI(ContactMatrixI cm,
42    boolean symmetric)
43    {
44    // assume contact matrix is square for text
45  0 ContactListI clist = cm.getContactList(1);
46   
47  0 int width = clist.getContactHeight();
48  0 Double minValue, maxValue;
49  0 minValue = clist.getContactAt(0);
50  0 maxValue = minValue;
51   
52  0 for (int p = 0; p < width; p++)
53    {
54  0 ContactListI pList = cm.getContactList(p);
55  0 for (int q = p; q < width; q++)
56    {
57  0 if (q == p)
58    {
59    // compute minMax for pList
60  0 minMax(minValue, maxValue, pList);
61   
62    }
63  0 ContactListI qList = cm.getContactList(q);
64  0 if (symmetric)
65    {
66  0 Assert.assertEquals(qList.getContactAt(p), pList.getContactAt(q),
67    "Contact matrix not symmetric");
68    }
69    else
70    {
71  0 Assert.assertNotEquals(qList.getContactAt(p),
72    pList.getContactAt(q),
73    "Contact matrix expected to be not symmetric");
74    }
75    }
76    }
77    }
78   
 
79  0 toggle private static void minMax(Double minValue, Double maxValue,
80    ContactListI pList)
81    {
82  0 int width = pList.getContactHeight();
83  0 for (int rowcol = 0; rowcol < width; rowcol++)
84    {
85  0 double v = pList.getContactAt(rowcol);
86  0 if (minValue > v)
87    {
88  0 minValue = v;
89    }
90  0 if (maxValue < v)
91    {
92  0 maxValue = v;
93    }
94    }
95    }
96   
 
97  1 toggle @Test(groups = { "Functional" })
98    public void testminMaxCalc()
99    {
100  1 ContactListI clist = new ContactListImpl(new ContactListProviderI()
101    {
102    double[] val = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
103   
 
104  0 toggle @Override
105    public int getPosition()
106    {
107  0 return 0;
108    }
109   
 
110  0 toggle @Override
111    public int getContactHeight()
112    {
113  0 return val.length;
114    }
115   
 
116  0 toggle @Override
117    public double getContactAt(int column)
118    {
119  0 if (column < 0 || column >= val.length)
120    {
121  0 return Double.NaN;
122    }
123  0 return val[column];
124    }
125   
126    });
127    // TODO - write test !
128    }
129   
130    /**
131    * test construction and accessors for asymmetric contact matrix
132    */
 
133  1 toggle @Test(groups = { "Functional" })
134    public void testAsymmetricContactMatrix()
135    {
136    // TODO - write test !
137   
138    }
139   
140    /**
141    * test construction and accessors for symmetric contact matrix
142    */
 
143  1 toggle @Test(groups = { "Functional" })
144    public void testSymmetricContactMatrix()
145    {
146    // TODO - write test !
147   
148    }
149   
150    }