@Test(expected = IllegalArgumentException.class) public void testNullContainer() { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); hydrogenPlacer.placeHydrogens2D(null, new Atom(), 1.5); }
/** * Place hydrogens connected to the given atom using the average bond length * in the container. * * @param container atom container of which <i>atom</i> is a member * @param atom the atom of which to place connected hydrogens * @throws IllegalArgumentException if the <i>atom</i> does not have 2d * coordinates * @see #placeHydrogens2D(org.openscience.cdk.interfaces.IAtomContainer, * double) */ public void placeHydrogens2D(IAtomContainer container, IAtom atom) { double bondLength = GeometryUtil.getBondLengthAverage(container); placeHydrogens2D(container, atom, bondLength); }
/** * Place hydrogens connected to the given atom using the average bond length * in the container. * * @param container atom container of which <i>atom</i> is a member * @param atom the atom of which to place connected hydrogens * @throws IllegalArgumentException if the <i>atom</i> does not have 2d * coordinates * @see #placeHydrogens2D(org.openscience.cdk.interfaces.IAtomContainer, * double) */ public void placeHydrogens2D(IAtomContainer container, IAtom atom) { double bondLength = GeometryUtil.getBondLengthAverage(container); placeHydrogens2D(container, atom, bondLength); }
@Test(expected = IllegalArgumentException.class) public void testAtomWithoutCoordinates() { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); hydrogenPlacer.placeHydrogens2D(new AtomContainer(), new Atom(), 1.5); }
/** * Place all hydrogens connected to atoms which have already been laid out. * * @param container atom container * @param bondLength bond length to user */ public void placeHydrogens2D(final IAtomContainer container, final double bondLength) { logger.debug("placing hydrogens on all atoms"); for (IAtom atom : container.atoms()) { // only place hydrogens for atoms which have coordinates if (atom.getPoint2d() != null) { placeHydrogens2D(container, atom, bondLength); } } logger.debug("hydrogen placement complete"); }
double bondLength = GeometryUtil.getBondLengthAverage(molecule); HydrogenPlacer hPlacer = new HydrogenPlacer(); molecule = original; hPlacer.placeHydrogens2D(molecule, bondLength);
/** * Place all hydrogens connected to atoms which have already been laid out. * * @param container atom container * @param bondLength bond length to user */ public void placeHydrogens2D(final IAtomContainer container, final double bondLength) { logger.debug("placing hydrogens on all atoms"); for (IAtom atom : container.atoms()) { // only place hydrogens for atoms which have coordinates if (atom.getPoint2d() != null) { placeHydrogens2D(container, atom, bondLength); } } logger.debug("hydrogen placement complete"); }
double bondLength = GeometryUtil.getBondLengthAverage(molecule); HydrogenPlacer hPlacer = new HydrogenPlacer(); molecule = original; hPlacer.placeHydrogens2D(molecule, bondLength);
@Test public void testNoConnections() { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); AtomContainer container = new AtomContainer(); Atom atom = new Atom("C", new Point2d(0, 0)); container.addAtom(atom); hydrogenPlacer.placeHydrogens2D(container, atom, 1.5); }
public void visualFullMolecule2DEvaluation() throws Exception { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); String filename = "data/mdl/reserpine.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLReader reader = new MDLReader(ins, Mode.STRICT); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0); org.openscience.cdk.interfaces.IChemModel model = seq.getChemModel(0); IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0); double bondLength = GeometryUtil.getBondLengthAverage(mol); logger.debug("Read Reserpine"); logger.debug("Starting addition of H's"); addExplicitHydrogens(mol); logger.debug("ended addition of H's"); hydrogenPlacer.placeHydrogens2D(mol, bondLength); }
@Test(expected = IllegalArgumentException.class) public void unplacedNonHydrogen() { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); // c2 is unplaced IAtom c1 = new Atom("C", new Point2d(0, 0)); IAtom c2 = new Atom("C"); IAtomContainer m = new AtomContainer(); m.addAtom(c1); m.addAtom(c2); m.addBond(new Bond(c1, c2)); hydrogenPlacer.placeHydrogens2D(m, 1.5); }
/** @cdk.bug 933572 */ @Test public void testBug933572() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("H")); ac.getAtom(0).setPoint2d(new Point2d(0, 0)); addExplicitHydrogens(ac); HydrogenPlacer hPlacer = new HydrogenPlacer(); hPlacer.placeHydrogens2D(ac, 36); for (int i = 0; i < ac.getAtomCount(); i++) { Assert.assertNotNull(ac.getAtom(i).getPoint2d()); } }
/** @cdk.bug 1269 */ @Test public void testH2() { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); // h1 has no coordinates IAtom h1 = new Atom("H"); IAtom h2 = new Atom("H", new Point2d(0, 0)); IAtomContainer m = new AtomContainer(); m.addAtom(h1); m.addAtom(h2); m.addBond(new Bond(h1, h2)); hydrogenPlacer.placeHydrogens2D(m, 1.5); assertNotNull(h1.getPoint2d()); }
@Test public void testPlaceHydrogens2D() throws Exception { HydrogenPlacer hydrogenPlacer = new HydrogenPlacer(); IAtomContainer dichloromethane = new AtomContainer(); Atom carbon = new Atom("C"); hydrogenPlacer.placeHydrogens2D(dichloromethane, carbon);