StructGenAtomTypeGuesser implements IAtomTypeGuesser { @Override public List<IAtomType> possibleAtomTypes(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (factory == null) { try { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/structgen_atomtypes.xml", atom.getBuilder()); } catch (Exception ex1) { logger.error(ex1.getMessage()); logger.debug(ex1); throw new CDKException("Could not instantiate the AtomType list!", ex1); } } double bondOrderSum = atomContainer.getBondOrderSum(atom); IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); int charge = atom.getFormalCharge(); int hcount = atom.getImplicitHydrogenCount(); List<IAtomType> matchingTypes = new ArrayList<IAtomType>(); IAtomType[] types = factory.getAtomTypes(atom.getSymbol()); for (IAtomType type : types) { logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount <= type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { matchingTypes.add(type); } } logger.debug(" No Match"); return matchingTypes; } StructGenAtomTypeGuesser(); @Override List<IAtomType> possibleAtomTypes(IAtomContainer atomContainer, IAtom atom);  }
@Test public void testPossibleAtomTypes_IAtomContainer_IAtom() throws java.lang.Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("C"); atom.setImplicitHydrogenCount(3); Atom atom2 = new Atom("N"); atom2.setImplicitHydrogenCount(2); mol.addAtom(atom); mol.addAtom(atom2); mol.addBond(new Bond(atom, atom2, IBond.Order.SINGLE)); StructGenAtomTypeGuesser atm = new StructGenAtomTypeGuesser(); List<IAtomType> matched = atm.possibleAtomTypes(mol, atom); Assert.assertNotNull(matched); Assert.assertTrue(matched.size() > 0); Assert.assertTrue(matched.get(0) instanceof IAtomType); Assert.assertEquals("C", ((IAtomType) matched.get(0)).getSymbol()); }