1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.structure; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertFalse; |
25 |
|
import static org.testng.Assert.assertTrue; |
26 |
|
|
27 |
|
import jalview.datamodel.Mapping; |
28 |
|
import jalview.datamodel.Sequence; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.util.MapList; |
31 |
|
|
32 |
|
import java.util.HashMap; |
33 |
|
import java.util.List; |
34 |
|
|
35 |
|
import org.testng.annotations.Test; |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (62) |
Complexity: 2 |
Complexity Density: 0.03 |
|
37 |
|
public class StructureMappingTest |
38 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
39 |
1 |
@Test(groups = "Functional")... |
40 |
|
public void testGetPDBResNumRanges() |
41 |
|
{ |
42 |
1 |
HashMap<Integer, int[]> map = new HashMap<>(); |
43 |
|
|
44 |
1 |
StructureMapping mapping = new StructureMapping(null, null, null, null, |
45 |
|
map, null); |
46 |
|
|
47 |
1 |
List<int[]> ranges = mapping.getPDBResNumRanges(1, 2); |
48 |
1 |
assertTrue(ranges.isEmpty()); |
49 |
|
|
50 |
1 |
map.put(1, new int[] { 12, 20 }); |
51 |
1 |
ranges = mapping.getPDBResNumRanges(2, 3); |
52 |
1 |
assertTrue(ranges.isEmpty()); |
53 |
1 |
ranges = mapping.getPDBResNumRanges(1, 2); |
54 |
1 |
assertEquals(ranges.size(), 1); |
55 |
1 |
assertEquals(ranges.get(0)[0], 12); |
56 |
1 |
assertEquals(ranges.get(0)[1], 12); |
57 |
|
|
58 |
1 |
map.put(2, new int[] { 13, 20 }); |
59 |
1 |
ranges = mapping.getPDBResNumRanges(1, 2); |
60 |
1 |
assertEquals(ranges.size(), 1); |
61 |
1 |
assertEquals(ranges.get(0)[0], 12); |
62 |
1 |
assertEquals(ranges.get(0)[1], 13); |
63 |
|
|
64 |
1 |
map.put(3, new int[] { 15, 20 }); |
65 |
1 |
ranges = mapping.getPDBResNumRanges(1, 5); |
66 |
1 |
assertEquals(ranges.size(), 2); |
67 |
1 |
assertEquals(ranges.get(0)[0], 12); |
68 |
1 |
assertEquals(ranges.get(0)[1], 13); |
69 |
1 |
assertEquals(ranges.get(1)[0], 15); |
70 |
1 |
assertEquals(ranges.get(1)[1], 15); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (37) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
73 |
1 |
@Test(groups = "Functional")... |
74 |
|
public void testEquals() |
75 |
|
{ |
76 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDE"); |
77 |
1 |
SequenceI seq2 = new Sequence("seq1", "ABCDE"); |
78 |
1 |
String pdbFile = "a/b/file1.pdb"; |
79 |
1 |
String pdbId = "1a70"; |
80 |
1 |
String chain = "A"; |
81 |
1 |
String mappingDetails = "these are the mapping details, honest"; |
82 |
1 |
HashMap<Integer, int[]> map = new HashMap<>(); |
83 |
|
|
84 |
1 |
Mapping seqToPdbMapping = new Mapping(seq1, |
85 |
|
new MapList(new int[] |
86 |
|
{ 1, 5 }, new int[] { 2, 6 }, 1, 1)); |
87 |
1 |
StructureMapping sm1 = new StructureMapping(seq1, pdbFile, pdbId, chain, |
88 |
|
map, mappingDetails, seqToPdbMapping); |
89 |
1 |
assertFalse(sm1.equals(null)); |
90 |
1 |
assertFalse(sm1.equals("x")); |
91 |
|
|
92 |
1 |
StructureMapping sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, |
93 |
|
map, mappingDetails, seqToPdbMapping); |
94 |
1 |
assertTrue(sm1.equals(sm2)); |
95 |
1 |
assertTrue(sm2.equals(sm1)); |
96 |
1 |
assertEquals(sm1.hashCode(), sm2.hashCode()); |
97 |
|
|
98 |
|
|
99 |
1 |
sm2 = new StructureMapping(seq2, pdbFile, pdbId, chain, map, |
100 |
|
mappingDetails, seqToPdbMapping); |
101 |
1 |
assertFalse(sm1.equals(sm2)); |
102 |
1 |
assertFalse(sm2.equals(sm1)); |
103 |
|
|
104 |
|
|
105 |
1 |
sm2 = new StructureMapping(seq1, "a/b/file2.pdb", pdbId, chain, map, |
106 |
|
mappingDetails, seqToPdbMapping); |
107 |
1 |
assertFalse(sm1.equals(sm2)); |
108 |
1 |
assertFalse(sm2.equals(sm1)); |
109 |
|
|
110 |
|
|
111 |
1 |
sm2 = new StructureMapping(seq1, pdbFile, "1A70", chain, map, |
112 |
|
mappingDetails, seqToPdbMapping); |
113 |
1 |
assertFalse(sm1.equals(sm2)); |
114 |
1 |
assertFalse(sm2.equals(sm1)); |
115 |
|
|
116 |
|
|
117 |
1 |
sm2 = new StructureMapping(seq1, pdbFile, pdbId, "B", map, |
118 |
|
mappingDetails, seqToPdbMapping); |
119 |
1 |
assertFalse(sm1.equals(sm2)); |
120 |
1 |
assertFalse(sm2.equals(sm1)); |
121 |
|
|
122 |
|
|
123 |
1 |
sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, null, |
124 |
|
mappingDetails, seqToPdbMapping); |
125 |
1 |
assertTrue(sm1.equals(sm2)); |
126 |
1 |
assertTrue(sm2.equals(sm1)); |
127 |
|
|
128 |
|
|
129 |
1 |
sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map, |
130 |
|
"different details!", seqToPdbMapping); |
131 |
1 |
assertFalse(sm1.equals(sm2)); |
132 |
1 |
assertFalse(sm2.equals(sm1)); |
133 |
|
|
134 |
|
|
135 |
1 |
Mapping map2 = new Mapping(seq1, |
136 |
|
new MapList(new int[] |
137 |
|
{ 1, 5 }, new int[] { 3, 7 }, 1, 1)); |
138 |
1 |
sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map, |
139 |
|
mappingDetails, map2); |
140 |
1 |
assertFalse(sm1.equals(sm2)); |
141 |
1 |
assertFalse(sm2.equals(sm1)); |
142 |
|
} |
143 |
|
} |