AtomPlacer3D { public int[] findHeavyAtomsInChain(IAtomContainer molecule, IAtomContainer chain) { int[] heavy = {-1, -1}; int hc = 0; for (int i = 0; i < chain.getAtomCount(); i++) { if (isHeavyAtom(chain.getAtom(i))) { if (heavy[0] < 0) { heavy[0] = molecule.indexOf(chain.getAtom(i)); } hc++; } } heavy[1] = hc; return heavy; } AtomPlacer3D(); void initilize(Map parameterSet); int[] findHeavyAtomsInChain(IAtomContainer molecule, IAtomContainer chain); IAtomContainer markPlaced(IAtomContainer ac); void placeAliphaticHeavyChain(IAtomContainer molecule, IAtomContainer chain); void zmatrixChainToCartesian(IAtomContainer molecule, boolean flagBranched); double getBondLengthValue(String id1, String id2); double getAngleValue(String id1, String id2, String id3); IAtom getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(IAtomContainer molecule); IAtom getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(IAtomContainer molecule); IAtom getNextPlacedHeavyAtomWithUnplacedRingNeighbour(IAtomContainer molecule); IAtom getFarthestAtom(Point3d refAtomPoint, IAtomContainer ac); IAtom getUnplacedRingHeavyAtom(IAtomContainer molecule, IAtom atom); Point3d geometricCenterAllPlacedAtoms(IAtomContainer molecule); IAtom getPlacedHeavyAtom(IAtomContainer molecule, IAtom atom); IAtom getPlacedHeavyAtom(IAtomContainer molecule, IAtom atomA, IAtom atomB); IAtomContainer getPlacedHeavyAtoms(IAtomContainer molecule, IAtom atom); int numberOfUnplacedHeavyAtoms(IAtomContainer ac); boolean allHeavyAtomsPlaced(IAtomContainer ac);  }
@Test public void testFindHeavyAtomsInChain_IAtomContainer_IAtomContainer() throws Exception { String filename = "data/mdl/allmol232.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close(); List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(chemFile); IAtomContainer ac = new AtomContainer(containersList.get(0)); addExplicitHydrogens(ac); IAtomContainer chain = ac.getBuilder().newInstance(IAtomContainer.class); for (int i = 16; i < 25; i++) { chain.addAtom(ac.getAtom(i)); } chain.addAtom(ac.getAtom(29)); chain.addAtom(ac.getAtom(30)); int[] result = new AtomPlacer3D().findHeavyAtomsInChain(ac, chain); Assert.assertEquals(16, result[0]); Assert.assertEquals(11, result[1]); }