View Javadoc
1   //******************************************************************************
2   //
3   // Title:       Force Field X.
4   // Description: Force Field X - Software for Molecular Biophysics.
5   // Copyright:   Copyright (c) Michael J. Schnieders 2001-2024.
6   //
7   // This file is part of Force Field X.
8   //
9   // Force Field X is free software; you can redistribute it and/or modify it
10  // under the terms of the GNU General Public License version 3 as published by
11  // the Free Software Foundation.
12  //
13  // Force Field X is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  // details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA 02111-1307 USA
21  //
22  // Linking this library statically or dynamically with other modules is making a
23  // combined work based on this library. Thus, the terms and conditions of the
24  // GNU General Public License cover the whole combination.
25  //
26  // As a special exception, the copyright holders of this library give you
27  // permission to link this library with independent modules to produce an
28  // executable, regardless of the license terms of these independent modules, and
29  // to copy and distribute the resulting executable under terms of your choice,
30  // provided that you also meet, for each linked independent module, the terms
31  // and conditions of the license of that module. An independent module is a
32  // module which is not derived from or based on this library. If you modify this
33  // library, you may extend this exception to your version of the library, but
34  // you are not obligated to do so. If you do not wish to do so, delete this
35  // exception statement from your version.
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  /** @author Mallory R. Tollefson */
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      // Residue 1
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     // Residue 2
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     // Residue 3
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}, // constructor arguments for test set 1
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 }