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