/** * {@inheritDoc} */ @Override public void setPoint3d(Point3d point3d) { atom.setPoint3d(point3d); }
/** * {@inheritDoc} */ @Override public void setPoint3d(Point3d point3d) { atom.setPoint3d(point3d); }
@Override public IAtomContainer next() { Point3d[] tmp = coordinates.get(current); for (int j = 0; j < atomContainer.getAtomCount(); j++) { IAtom atom = atomContainer.getAtom(j); atom.setPoint3d(tmp[j]); } last = current++; return atomContainer; }
@Override public IAtomContainer next() { Point3d[] tmp = coordinates.get(current); for (int j = 0; j < atomContainer.getAtomCount(); j++) { IAtom atom = atomContainer.getAtom(j); atom.setPoint3d(tmp[j]); } last = current++; return atomContainer; }
private void assignCoords(IAtomContainer template, Map<IChemObject, IChemObject> map) { for (IAtom src : template.atoms()) { IAtom dst = (IAtom) map.get(src); dst.setPoint3d(new Point3d(src.getPoint3d())); } }
private void addTemplateMol(IAtomContainer mol) { templates.add(mol); QueryAtomContainer query = QueryAtomContainerCreator.createAnyAtomAnyBondContainer(mol, false); queries.add(query); for (int i = 0; i < mol.getAtomCount(); i++) { query.getAtom(i).setPoint3d(new Point3d(mol.getAtom(i).getPoint3d())); } patterns.add(Pattern.findSubstructure(query)); }
private void setCoordinatesToZero(IAtomContainer mol) { for (IAtom atom : mol.atoms()) { atom.setPoint3d(new Point3d(0.0, 0.0, 0.0)); } }
private static void set3D(IAtomContainer container, int index, IAtom[] atoms) { if ((container.getAtom(index)).getPoint3d() != null) { atoms[index].setPoint3d(new Point3d(container.getAtom(index).getPoint3d())); } }
private static void set3D(IAtomContainer container, int index, IAtom[] atoms) { if ((container.getAtom(index)).getPoint3d() != null) { atoms[index].setPoint3d(new Point3d(container.getAtom(index).getPoint3d())); } }
static IAtom atom(String symbol, int h, double x, double y, double z) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(h); a.setPoint3d(new Point3d(x, y, z)); return a; } }
@Test public void testSetPoint3d_Point3d() { Point3d point3d = new Point3d(1.0, 2.0, 3.0); IAtom a = (IAtom) newChemObject(); a.setPoint3d(point3d); Assert.assertEquals(point3d, a.getPoint3d()); }
@Test public void writeDimensionField3D() throws Exception { IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setImplicitHydrogenCount(4); atom.setPoint3d(new Point3d(0.5, 0.5, 0.1)); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV2000Writer mdlw = new MDLV2000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("3D")); }
@Test public void testGetFarthestAtom_Point3d_IAtomContainer() { AtomPlacer3D atmplacer = new AtomPlacer3D(); IAtomContainer molecule = TestMoleculeFactory.makeBenzene(); molecule.getAtom(0).setPoint3d(new Point3d(0.0, 0.0, 0.0)); molecule.getAtom(1).setPoint3d(new Point3d(1.0, 1.0, 1.0)); molecule.getAtom(4).setPoint3d(new Point3d(3.0, 2.0, 1.0)); molecule.getAtom(5).setPoint3d(new Point3d(4.0, 4.0, 4.0)); IAtom farthestFromAtoma = atmplacer.getFarthestAtom(molecule.getAtom(0).getPoint3d(), molecule); IAtom farthestFromAtomb = atmplacer.getFarthestAtom(molecule.getAtom(4).getPoint3d(), molecule); Assert.assertEquals(molecule.getAtom(5), farthestFromAtoma); Assert.assertEquals(molecule.getAtom(0), farthestFromAtomb); }
@Test public void get3DCoordinateCoverage_Partial() { IAtomContainer container = new AtomContainer(); IAtom atom1 = new Atom("C"); IAtom atom2 = new Atom("C"); IAtom atom3 = new Atom("C"); atom1.setPoint3d(new Point3d(1, 1, 0)); atom3.setPoint3d(new Point3d(1, 1, 0)); container.addAtom(atom1); container.addAtom(atom2); container.addAtom(atom3); Assert.assertEquals(GeometryUtil.CoordinateCoverage.PARTIAL, GeometryUtil.get3DCoordinateCoverage(container)); }
/** * Method to test the clone() method */ @Test public void testClone_Point3d() throws Exception { IAtom atom = (IAtom) newChemObject(); atom.setPoint3d(new Point3d(2, 3, 4)); IAtom clone = (IAtom) atom.clone(); Assert.assertEquals(clone.getPoint3d().x, 2.0, 0.001); }
@Test public void rescaleBondLength_IAtom_IAtom_Point3d() { IAtom atom1 = new Atom("C"); atom1.setPoint3d(new Point3d(1, 1, 1)); atom1.setCovalentRadius(0.2); IAtom atom2 = new Atom("C"); atom2.setPoint3d(new Point3d(2, 2, 2)); atom2.setCovalentRadius(0.2); Point3d newpoint = new AtomTetrahedralLigandPlacer3D().rescaleBondLength(atom1, atom2, atom2.getPoint3d()); Assert.assertEquals(0.4, newpoint.distance(atom1.getPoint3d()), 0.001); }
@Test @Override public void testGeometricCenterAllPlacedAtoms_IAtomContainer() { AtomPlacer3D atmplacer = new AtomPlacer3D(); IAtomContainer molecule = TestMoleculeFactory.makeAlkane(2); for (IAtom atom : molecule.atoms()) { atom.setFlag(CDKConstants.ISPLACED, true); } molecule.getAtom(0).setPoint3d(new Point3d(-1.0, 0.0, 0.0)); molecule.getAtom(1).setPoint3d(new Point3d(1.0, 0.0, 0.0)); Point3d center = atmplacer.geometricCenterAllPlacedAtoms(molecule); Assert.assertEquals(0.0, center.x, 0.01); Assert.assertEquals(0.0, center.y, 0.01); Assert.assertEquals(0.0, center.z, 0.01); }
@Test public void testIAtom_Point3d() throws Exception { IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setID("a1"); atom.setPoint3d(new Point3d(1.0, 2.0, 3.0)); mol.addAtom(atom); IAtomContainer copy = CMLRoundTripTool.roundTripMolecule(convertor, mol); String difference = AtomDiff.diff(atom, copy.getAtom(0)); Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length()); }
@Test public void testGetPoint3d() { Point3d point3d = new Point3d(1.0, 2.0, 3.0); IAtom a = (IAtom) newChemObject(); a.setPoint3d(point3d); Assert.assertNotNull(a.getPoint3d()); assertEquals(point3d, a.getPoint3d(), 0.001); }
@Test public void testIAtom_Point8d() throws Exception { IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setID("a1"); atom.setPoint2d(new Point2d(0.0, 0.0)); atom.setPoint3d(new Point3d(-1.0, -2.0, -3.0)); atom.setFractionalPoint3d(new Point3d(1.0, 2.0, 3.0)); mol.addAtom(atom); IAtomContainer copy = CMLRoundTripTool.roundTripMolecule(convertor, mol); String difference = AtomDiff.diff(atom, copy.getAtom(0)); Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length()); }