1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
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 |
|
|
|
|
| 13% |
Uncovered Elements: 47 (54) |
Complexity: 18 |
Complexity Density: 0.62 |
|
29 |
|
public class ContactMatrixTest |
30 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
31 |
1 |
@BeforeClass(alwaysRun = true)... |
32 |
|
public void setUpJvOptionPane() |
33 |
|
{ |
34 |
1 |
JvOptionPane.setInteractiveMode(false); |
35 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
36 |
|
} |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
41 |
0 |
public static void testContactMatrixI(ContactMatrixI cm,... |
42 |
|
boolean symmetric) |
43 |
|
{ |
44 |
|
|
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 |
|
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
79 |
0 |
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
97 |
1 |
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
104 |
0 |
@Override... |
105 |
|
public int getPosition() |
106 |
|
{ |
107 |
0 |
return 0; |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0 |
@Override... |
111 |
|
public int getContactHeight() |
112 |
|
{ |
113 |
0 |
return val.length; |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
116 |
0 |
@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 |
|
|
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
133 |
1 |
@Test(groups = { "Functional" })... |
134 |
|
public void testAsymmetricContactMatrix() |
135 |
|
{ |
136 |
|
|
137 |
|
|
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
143 |
1 |
@Test(groups = { "Functional" })... |
144 |
|
public void testSymmetricContactMatrix() |
145 |
|
{ |
146 |
|
|
147 |
|
|
148 |
|
} |
149 |
|
|
150 |
|
} |