1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.potential.bonded;
39
40 import static org.junit.Assert.assertArrayEquals;
41
42 import ffx.potential.MolecularAssembly;
43 import ffx.potential.utils.Loop;
44 import ffx.potential.utils.PotentialsUtils;
45 import java.io.File;
46 import java.util.Arrays;
47 import java.util.Collection;
48
49 import ffx.utilities.FFXTest;
50 import org.junit.After;
51 import org.junit.Test;
52 import org.junit.runner.RunWith;
53 import org.junit.runners.Parameterized;
54 import org.junit.runners.Parameterized.Parameters;
55
56
57 @RunWith(Parameterized.class)
58 public class LoopClosureTest extends FFXTest {
59
60 private final MolecularAssembly molecularAssembly;
61 private final Loop loop;
62
63 private final double[][] xyzNTest;
64 private final double[][] xyzCTest;
65 private final double[][] xyzATest;
66
67 public LoopClosureTest(
68 double[][] xyzNTest, double[][] xyzATest, double[][] xyzCTest, double[][] xyzOTest) {
69 int startResidue = 2;
70 int endResidue = 4;
71 ClassLoader classLoader = getClass().getClassLoader();
72 File structure = new File(classLoader.getResource("LoopClosureTest.pdb").getPath());
73 PotentialsUtils potentialsUtils = new PotentialsUtils();
74 molecularAssembly = potentialsUtils.open(structure);
75 loop = new Loop(molecularAssembly, startResidue, endResidue);
76
77 this.xyzNTest = xyzNTest;
78 this.xyzATest = xyzATest;
79 this.xyzCTest = xyzCTest;
80 }
81
82 @Parameters
83 public static Collection<Object[]> data() {
84
85 double[][] xyzNTest = new double[3][3];
86 double[][] xyzATest = new double[3][3];
87 double[][] xyzCTest = new double[3][3];
88 double[][] xyzOTest = new double[3][3];
89
90
91 xyzNTest[0][0] = 7.773;
92 xyzNTest[0][1] = -9.71;
93 xyzNTest[0][2] = -7.32;
94 xyzATest[0][0] = 6.331;
95 xyzATest[0][1] = -9.839;
96 xyzATest[0][2] = -7.259;
97 xyzCTest[0][0] = 5.886372894231285;
98 xyzCTest[0][1] = -10.55641925089512;
99 xyzCTest[0][2] = -5.994873283542817;
100 xyzOTest[0][0] = 4.7066623518635335;
101 xyzOTest[0][1] = -10.772063009151791;
102 xyzOTest[0][2] = -5.7426213147669065;
103
104 xyzNTest[1][0] = 6.267265566616004;
105 xyzNTest[1][1] = -11.821304411459156;
106 xyzNTest[1][2] = -5.840321341761048;
107 xyzATest[1][0] = 5.873570174757412;
108 xyzATest[1][1] = -12.55730694668949;
109 xyzATest[1][2] = -4.654655197113309;
110 xyzCTest[1][0] = 4.522327673119161;
111 xyzCTest[1][1] = -13.229312851952344;
112 xyzCTest[1][2] = -4.836181407502477;
113 xyzOTest[1][0] = 4.000608042124467;
114 xyzOTest[1][1] = -13.903386108027433;
115 xyzOTest[1][2] = -3.955679208709603;
116
117 xyzNTest[2][0] = 3.9321584783416297;
118 xyzNTest[2][1] = -13.724556941299172;
119 xyzNTest[2][2] = -3.7520533645561343;
120 xyzATest[2][0] = 2.642;
121 xyzATest[2][1] = -14.377;
122 xyzATest[2][2] = -3.863;
123 xyzCTest[2][0] = 1.658;
124 xyzCTest[2][1] = -13.856;
125 xyzCTest[2][2] = -2.821;
126 xyzOTest[2][0] = 0.5084362754396345;
127 xyzOTest[2][1] = -14.272368583539699;
128 xyzOTest[2][2] = -2.7373896189696216;
129
130 return Arrays.asList(
131 new Object[][] {
132 {xyzNTest, xyzATest, xyzCTest, xyzOTest},
133 });
134 }
135
136 @After
137 public void after() {
138 molecularAssembly.getPotentialEnergy().destroy();
139 System.gc();
140 }
141
142 @Test
143 public void loopTest() {
144 var rA = loop.getRA();
145 var rC = loop.getRC();
146 var rN = loop.getRN();
147
148 for (int j = 0; j < xyzATest.length; j++) {
149 assertArrayEquals(xyzATest[j], rA[j], 1e-8);
150 assertArrayEquals(xyzCTest[j], rC[j], 1e-8);
151 assertArrayEquals(xyzNTest[j], rN[j], 1e-8);
152 }
153 }
154 }