BondCountDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer container) { if (order.equals("")) { int bondCount = 0; for (IBond bond : container.bonds()) { boolean hasHydrogen = false; for (int i = 0; i < bond.getAtomCount(); i++) { if (bond.getAtom(i).getAtomicNumber() == IElement.H) { hasHydrogen = true; break; } } if (!hasHydrogen) bondCount++; } return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult( bondCount), getDescriptorNames(), null); } int bondCount = 0; for (IBond bond : container.bonds()) { if (bondMatch(bond.getOrder(), order)) { bondCount += 1; } } return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult( bondCount), getDescriptorNames()); } BondCountDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtomContainer container); @Override IDescriptorResult getDescriptorResultType(); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testDefaultSetting() throws Exception { IMolecularDescriptor descriptor = new BondCountDescriptor(); IAtomContainer mol = sp.parseSmiles("CCO"); Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue()); mol = sp.parseSmiles("C=C=C"); Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue()); mol = sp.parseSmiles("CC=O"); Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue()); mol = sp.parseSmiles("CC#N"); Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue()); }