19package denoptim.molecularmodeling.zmatrix;
21import static org.junit.Assert.assertNotEquals;
22import static org.junit.jupiter.api.Assertions.assertEquals;
23import static org.junit.jupiter.api.Assertions.assertFalse;
24import static org.junit.jupiter.api.Assertions.assertNotNull;
25import static org.junit.jupiter.api.Assertions.assertNull;
26import static org.junit.jupiter.api.Assertions.assertTrue;
30import javax.vecmath.Point3d;
32import org.junit.jupiter.api.Test;
33import org.openscience.cdk.Atom;
34import org.openscience.cdk.interfaces.IAtom;
35import org.openscience.cdk.interfaces.IBond;
36import org.openscience.cdk.interfaces.IAtomContainer;
37import org.openscience.cdk.silent.SilentChemObjectBuilder;
55 0,
"H",
"H.1",
null,
null,
null,
56 null,
null,
null,
null);
59 1,
"O",
"O.2", atom0,
null,
null,
60 1.5,
null,
null,
null);
63 2,
"C",
"C.3", atom1, atom0,
null,
64 1.4, 109.5,
null,
null);
67 3,
"H",
"H.1", atom2, atom1, atom0,
71 4,
"H",
"H.1", atom2, atom1, atom3,
72 1.4, 109.5, 109.0, 1);
75 5,
"H",
"H.1", atom4, atom2, atom1,
137 99,
"H",
"H.1",
null,
null,
null, 0.0, 0.0, 0.0, 0);
138 assertEquals(-1, zMatrix.
getIndex(atomNotInList));
202 assertNull(zMatrix.
getId());
204 zMatrix.
setId(
"test-zmatrix-1");
205 assertEquals(
"test-zmatrix-1", zMatrix.
getId());
207 zMatrix.
setId(
"another-id");
208 assertEquals(
"another-id", zMatrix.
getId());
211 assertNull(zMatrix.
getId());
247 assertEquals(1, bondsToAdd.size());
249 int[] bondToAdd = bondsToAdd.get(0);
250 assertEquals(2, Math.min(bondToAdd[0], bondToAdd[1]));
251 assertEquals(5, Math.max(bondToAdd[0], bondToAdd[1]));
262 assertEquals(1, bondsToDel.size());
264 int[] bondToDel = bondsToDel.get(0);
265 assertEquals(4, Math.min(bondToDel[0], bondToDel[1]));
266 assertEquals(5, Math.max(bondToDel[0], bondToDel[1]));
278 assertNotNull(cloned);
279 assertEquals(original.
getId(), cloned.
getId());
288 assertEquals(originalAtom.
getId(), clonedAtom.
getId());
309 assertEquals(5, bondData.size());
311 int[] bond = bondData.get(0);
312 assertEquals(0, bond[0]);
313 assertEquals(1, bond[1]);
325 assertEquals(zmat1, zmat1);
326 assertEquals(zmat1, zmat2);
327 assertNotEquals(zmat1,
null);
329 zmat2.
setId(
"Different");
330 assertNotEquals(zmat1, zmat2);
334 assertNotEquals(zmat1, zmat2);
338 assertNotEquals(zmat1, zmat2);
342 assertNotEquals(zmat1, zmat2);
354 "Equal ZMatrices should have same hash code");
356 zmat2.
setId(
"Different");
365 IAtomContainer mol = SilentChemObjectBuilder.getInstance().newAtomContainer();
366 IAtom atom0 =
new Atom(
"C",
new Point3d(0.0, 0.0, 0.0));
367 IAtom atom1 =
new Atom(
"C",
new Point3d(0.0, 0.0, 1.0));
368 IAtom atom2 =
new Atom(
"H",
new Point3d(1.0, 0.0, 1.0));
369 IAtom atom3 =
new Atom(
"H",
new Point3d(1.0, 1.0, 1.0));
370 IAtom atom4 =
new Atom(
"P",
new Point3d(1.0, 1.0, 0.0));
371 IAtom atom5 =
new Atom(
"O",
new Point3d(1.0, 2.0, 0.0));
372 IAtom atom6 =
new Atom(
"Cl",
new Point3d(0.0, 1.0, 0.0));
373 IAtom atom7 =
new Atom(
"H",
new Point3d(2.0, 1.0, 0.0));
382 mol.addBond(0, 1, IBond.Order.SINGLE);
383 mol.addBond(1, 2, IBond.Order.SINGLE);
384 mol.addBond(2, 3, IBond.Order.SINGLE);
385 mol.addBond(3, 4, IBond.Order.SINGLE);
386 mol.addBond(4, 5, IBond.Order.SINGLE);
387 mol.addBond(4, 6, IBond.Order.SINGLE);
388 mol.addBond(4, 7, IBond.Order.SINGLE);
Representation of an atom in the ZMatrix.
String getSymbol()
Get the symbol of the atom.
int getId()
Get the id of the atom.
String getType()
Get the type of the atom.
Representation of a bond in the ZMatrix.
ZMatrixAtom getAtm2()
Get the second atom in the bond.
ZMatrixAtom getAtm1()
Get the first atom in the bond.
Representation of an atom container's geometry with internal coordinates.
List< int[]> getBondsToDel()
Get the bonds to delete from the ZMatrix.
int getIndex(ZMatrixAtom atm)
Get the index of the atom.
List< int[]> getBondData()
Get the bond data for the ZMatrix.
void delBond(int a1, int a2)
Delete the bond between the two atoms at the given indices.
int getAtomCount()
Get the number of atoms in the ZMatrix.
Integer getChiralFlag(int index)
Get the chiral flag for the atom at the given index.
void removeAtom(ZMatrixAtom atm)
Remove an atom from the ZMatrix.
String getId()
Get the id of the ZMatrix.
int getBondCount()
Get the number of bonds in the ZMatrix.
int getBondRefAtomIndex(int index)
Get the index of the bond reference atom for the atom at the given index.
ZMatrix clone()
Clone the ZMatrix.
static ZMatrix getZMatrixFromIAC(IAtomContainer mol)
Convert IAtomContainer to ZMatrix.
ZMatrixBond getBond(int index)
Get the bond at the given index.
boolean usesProperDihedral(int idx1, int idx2)
Check if the dihedral between the two atoms at the given indices uses proper torsion.
void setId(String id)
Set the id of the ZMatrix.
void addBond(int a1, int a2)
Add a bond between the two atoms at the given indices.
List< int[]> getBondsToAdd()
Get the bonds to add to the Z-matrix.
ZMatrixAtom getAtom(int index)
Get the atom at the given index.
void addAtom(ZMatrixAtom atom)
Add an atom to the ZMatrix.
int getAngle2RefAtomIndex(int index)
Get the index of the second angle reference atom for the atom at the given index.
int getAngleRefAtomIndex(int index)
Get the index of the angle reference atom for the atom at the given index.
void testGetAngle2RefAtomIndex()
void testGetZMatrixFromIAC()
void testGetBondRefAtomIndex()
void testGetAngleRefAtomIndex()
void testUsesProperDihedral()
void testZMatrixHashCode()