AtomHybridizationDescriptor extends AbstractAtomicDescriptor implements IAtomicDescriptor { @Override public DescriptorValue calculate(IAtom atom, IAtomContainer container) { try { matched = CDKAtomTypeMatcher.getInstance(atom.getBuilder()).findMatchingAtomType(container, atom); } catch (CDKException e) { return getDummyDescriptorValue(e); } if (matched == null) { int atnum = container.indexOf(atom); return getDummyDescriptorValue(new CDKException("The matched atom type was null (atom number " + atnum + ") " + atom.getSymbol())); } Hybridization atomHybridization = matched.getHybridization(); IntegerResult result = new IntegerResult(atomHybridization == null ? 0 : atomHybridization.ordinal()); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result, getDescriptorNames()); }  @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtom atom, IAtomContainer container); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testAtomHybridizationDescriptorTest() throws ClassNotFoundException, CDKException, java.lang.Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C#CC=CC"); addExplicitHydrogens(mol); IAtomType.Hybridization[] expectedStates = new IAtomType.Hybridization[]{IAtomType.Hybridization.SP1, IAtomType.Hybridization.SP1, IAtomType.Hybridization.SP2, IAtomType.Hybridization.SP2, IAtomType.Hybridization.SP3}; for (int i = 0; i < expectedStates.length; i++) { Assert.assertEquals(expectedStates[i].ordinal(), ((IntegerResult) descriptor.calculate(mol.getAtom(i), mol) .getValue()).intValue()); } }
@Test public void testBug1701073() throws Exception { String[] smiles = new String[]{"C1CCCC=2[C]1(C(=O)NN2)C", "C1CCCC=2[C]1(C(=O)NN2)O", "C[Si](C)(C)[CH](Br)CC(F)(Br)F", "c1(ccc(cc1)O)C#N", "CCN(CC)C#CC#CC(=O)OC", "C(#CN1CCCCC1)[Sn](C)(C)C", "c1([As+](c2ccccc2)(c2ccccc2)C)ccccc1.[I-]", "c1(noc(n1)CCC(=O)N(CC)CC)c1ccc(cc1)C", "c1c(c(ccc1)O)/C=N/CCCC", "c1(ccc(cc1)C#Cc1ccc(cc1)C#C)OC"}; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol; Iterator<IAtom> atoms; for (String smile : smiles) { mol = sp.parseSmiles(smile); addImplicitHydrogens(mol); AtomContainerManipulator.convertImplicitToExplicitHydrogens(mol); atoms = mol.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); ((IntegerResult) descriptor.calculate(atom, mol).getValue()).intValue(); } } }