AtomicNumberDifferenceDescriptor extends AbstractBondDescriptor implements IBondDescriptor { @Override public DescriptorValue calculate(IBond bond, IAtomContainer ac) { ensureIsotopeFactory(); if (bond.getAtomCount() != 2) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, new CDKException("Only 2-center bonds are considered")); } IAtom[] atoms = BondManipulator.getAtomArray(bond); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Math.abs(factory.getElement(atoms[0].getSymbol()).getAtomicNumber() - factory.getElement(atoms[1].getSymbol()).getAtomicNumber())), NAMES); } AtomicNumberDifferenceDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IBond bond, IAtomContainer ac); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testDescriptor1() throws InvalidSmilesException { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol1 = sp.parseSmiles("CC"); double value = ((DoubleResult) descriptor.calculate(mol1.getBond(0), mol1).getValue()).doubleValue(); Assert.assertEquals(0, value, 0.0000); }
@Test public void testDescriptor2() throws InvalidSmilesException { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol1 = sp.parseSmiles("CO"); double value = ((DoubleResult) descriptor.calculate(mol1.getBond(0), mol1).getValue()).doubleValue(); Assert.assertEquals(2, value, 0.0000); }