19package denoptim.molecularmodeling;
21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertNotNull;
23import static org.junit.jupiter.api.Assertions.assertTrue;
25import java.util.ArrayList;
26import java.util.logging.Logger;
28import javax.vecmath.Point3d;
30import org.junit.jupiter.api.Test;
31import org.openscience.cdk.Atom;
32import org.openscience.cdk.interfaces.IAtom;
33import org.openscience.cdk.interfaces.IAtomContainer;
34import org.openscience.cdk.silent.SilentChemObjectBuilder;
36import denoptim.constants.DENOPTIMConstants;
37import denoptim.graph.DGraph;
38import denoptim.molecularmodeling.zmatrix.ZMatrix;
39import denoptim.molecularmodeling.zmatrix.ZMatrixAtom;
49 private Logger
logger = Logger.getLogger(
"TestLogger");
57 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
58 IAtom atom0 =
new Atom(
"H");
63 0,
"H",
"H.1",
null,
null,
null,
64 null,
null,
null,
null);
69 molGraph, fmol, zmat,
"test",
70 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
75 Point3d coord0 = fmol.getAtom(0).getPoint3d();
76 assertNotNull(coord0);
77 assertEquals(0.0, coord0.x, 1e-10,
"First atom X coordinate");
78 assertEquals(0.0, coord0.y, 1e-10,
"First atom Y coordinate");
79 assertEquals(0.0, coord0.z, 1e-10,
"First atom Z coordinate");
88 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
89 IAtom atom0 =
new Atom(
"H");
90 IAtom atom1 =
new Atom(
"H");
96 0,
"H",
"H.1",
null,
null,
null,
97 null,
null,
null,
null);
99 1,
"H",
"H.1", zAtom0,
null,
null,
100 1.5,
null,
null,
null);
106 molGraph, fmol, zmat,
"test",
107 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
112 Point3d coord0 = fmol.getAtom(0).getPoint3d();
113 Point3d coord1 = fmol.getAtom(1).getPoint3d();
115 assertEquals(0.0, coord0.x, 1e-10,
"First atom X");
116 assertEquals(0.0, coord0.y, 1e-10,
"First atom Y");
117 assertEquals(0.0, coord0.z, 1e-10,
"First atom Z");
119 assertEquals(0.0, coord1.x, 1e-10,
"Second atom X");
120 assertEquals(0.0, coord1.y, 1e-10,
"Second atom Y");
121 assertEquals(1.5, coord1.z, 1e-10,
"Second atom Z (bond length)");
130 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
131 IAtom atom0 =
new Atom(
"H");
132 IAtom atom1 =
new Atom(
"O");
133 IAtom atom2 =
new Atom(
"H");
140 0,
"H",
"H.1",
null,
null,
null,
141 null,
null,
null,
null);
143 1,
"O",
"O.2", zAtom0,
null,
null,
144 1.0,
null,
null,
null);
146 2,
"H",
"H.1", zAtom1, zAtom0,
null,
147 1.0, 109.5,
null,
null);
154 molGraph, fmol, zmat,
"test",
155 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
160 Point3d coord0 = fmol.getAtom(0).getPoint3d();
161 Point3d coord1 = fmol.getAtom(1).getPoint3d();
162 Point3d coord2 = fmol.getAtom(2).getPoint3d();
165 assertEquals(0.0, coord0.x, 1e-10);
166 assertEquals(0.0, coord0.y, 1e-10);
167 assertEquals(0.0, coord0.z, 1e-10);
170 assertEquals(0.0, coord1.x, 1e-10);
171 assertEquals(0.0, coord1.y, 1e-10);
172 assertEquals(1.0, coord1.z, 1e-10);
175 assertTrue(Math.abs(coord2.x) > 1e-6,
"Third atom should have X != 0");
176 assertEquals(0.0, coord2.y, 1e-10,
"Third atom Y should be 0");
177 assertTrue(coord2.z > 0,
"Third atom Z should be positive");
186 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
187 IAtom atom0 =
new Atom(
"C");
188 IAtom atom1 =
new Atom(
"C");
189 IAtom atom2 =
new Atom(
"H");
190 IAtom atom3 =
new Atom(
"H");
198 0,
"C",
"C.3",
null,
null,
null,
199 null,
null,
null,
null);
201 1,
"C",
"C.3", zAtom0,
null,
null,
202 1.5,
null,
null,
null);
204 2,
"H",
"H.1", zAtom1, zAtom0,
null,
205 1.1, 109.5,
null,
null);
207 3,
"H",
"H.1", zAtom2, zAtom1, zAtom0,
208 1.1, 109.5, 60.0, 0);
216 molGraph, fmol, zmat,
"test",
217 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
223 for (
int i = 0; i < 4; i++)
225 Point3d coord = fmol.getAtom(i).getPoint3d();
226 assertNotNull(coord,
"Atom " + i +
" should have coordinates");
230 Point3d coord3 = fmol.getAtom(3).getPoint3d();
231 assertTrue(Math.abs(coord3.x) > 1e-6 || Math.abs(coord3.y) > 1e-6
232 || Math.abs(coord3.z) > 1e-6,
233 "Fourth atom should have non-zero coordinates");
242 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
243 IAtom atom0 =
new Atom(
"C");
244 IAtom atom1 =
new Atom(
"C");
245 IAtom atom2 =
new Atom(
"H");
246 IAtom atom3 =
new Atom(
"H");
254 0,
"C",
"C.3",
null,
null,
null,
255 null,
null,
null,
null);
257 1,
"C",
"C.3", zAtom0,
null,
null,
258 1.5,
null,
null,
null);
260 2,
"H",
"H.1", zAtom1, zAtom0,
null,
261 1.1, 109.5,
null,
null);
263 3,
"H",
"H.1", zAtom2, zAtom1, zAtom0,
264 1.1, 109.5, 60.0, 1);
272 molGraph, fmol, zmat,
"test",
273 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
279 Point3d coord3 = fmol.getAtom(3).getPoint3d();
280 assertNotNull(coord3,
"Atom 3 should have coordinates");
281 assertTrue(Math.abs(coord3.x) > 1e-6 || Math.abs(coord3.y) > 1e-6
282 || Math.abs(coord3.z) > 1e-6,
283 "Atom 3 should have non-zero coordinates");
292 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
293 IAtom atom0 =
new Atom(
"C");
294 IAtom atom1 =
new Atom(
"C");
295 IAtom atom2 =
new Atom(
"H");
296 IAtom atom3 =
new Atom(
"H");
304 0,
"C",
"C.3",
null,
null,
null,
305 null,
null,
null,
null);
307 1,
"C",
"C.3", zAtom0,
null,
null,
308 1.5,
null,
null,
null);
310 2,
"H",
"H.1", zAtom1, zAtom0,
null,
311 1.1, 109.5,
null,
null);
313 3,
"H",
"H.1", zAtom2, zAtom1, zAtom0,
314 1.1, 109.5, 60.0, -1);
322 molGraph, fmol, zmat,
"test",
323 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
329 Point3d coord3 = fmol.getAtom(3).getPoint3d();
330 assertNotNull(coord3,
"Atom 3 should have coordinates");
338 IAtomContainer fmol = SilentChemObjectBuilder.getInstance().newAtomContainer();
339 IAtom atom0 =
new Atom(
"C");
340 IAtom atom1 =
new Atom(
"C");
341 IAtom atom2 =
new Atom(
"H");
342 IAtom atom3 =
new Atom(
"H");
343 IAtom atom4 =
new Atom(
"P");
344 IAtom atom5 =
new Atom(
"O");
345 IAtom atom6 =
new Atom(
"Cl");
346 IAtom atom7 =
new Atom(
"H");
358 0,
"C",
"C.3",
null,
null,
null,
359 null,
null,
null,
null);
361 1,
"C",
"C.3", zAtom0,
null,
null,
362 1.0,
null,
null,
null);
364 2,
"H",
"H.1", zAtom1, zAtom0,
null,
365 1.0, 90.0,
null,
null);
367 3,
"H",
"H.1", zAtom2, zAtom1, zAtom0,
370 4,
"P",
"P.3", zAtom3, zAtom2, zAtom1,
371 1.0, 90.0, -90.0, 0);
373 5,
"O",
"O.3", zAtom4, zAtom3, zAtom2,
374 1.0, 90.0, 180.0, 0);
376 6,
"Cl",
"Cl.1", zAtom4, zAtom3, zAtom5,
379 7,
"H",
"H.1", zAtom4, zAtom3, zAtom5,
380 1.0, 90.0, 90.0, -1);
393 molGraph, fmol, zmat,
"test",
394 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
399 Point3d coord0 = fmol.getAtom(0).getPoint3d();
400 Point3d coord1 = fmol.getAtom(1).getPoint3d();
401 Point3d coord2 = fmol.getAtom(2).getPoint3d();
402 Point3d coord3 = fmol.getAtom(3).getPoint3d();
403 Point3d coord4 = fmol.getAtom(4).getPoint3d();
404 Point3d coord5 = fmol.getAtom(5).getPoint3d();
405 Point3d coord6 = fmol.getAtom(6).getPoint3d();
406 Point3d coord7 = fmol.getAtom(7).getPoint3d();
General set of constants used in DENOPTIM.
static final double FLOATCOMPARISONTOLERANCE
Smallest difference for comparison of double and float numbers.
Container for the list of vertices and the edges that connect them.
Collector of molecular information, related to a single chemical object, that is deployed within the ...
void updateXYZFromINT()
Converts currently loaded internal coordinates into Cartesian overwriting the current XYZ.
Unit test for ChemicalObjectModel.
void testUpdateXYZFromINT_FourthAtomWithDihedral()
void testUpdateXYZFromINT_FirstAtomAtOrigin()
void testUpdateXYZFromINT_ChiralityOne()
void testUpdateXYZFromINT_SecondAtomAlongZAxis()
void testUpdateXYZFromINT_ThirdAtomWithAngle()
void testUpdateXYZFromINT_ChiralityMinusOne()
void testUpdateXYZFromINT()
Representation of an atom in the ZMatrix.
Representation of an atom container's geometry with internal coordinates.
void addAtom(ZMatrixAtom atom)
Add an atom to the ZMatrix.