PetitjeanNumberDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer atomContainer) { IAtomContainer cloneContainer = AtomContainerManipulator.removeHydrogens(atomContainer); double petitjeanNumber; int diameter = PathTools.getMolecularGraphDiameter(cloneContainer); int radius = PathTools.getMolecularGraphRadius(cloneContainer); if (diameter == 0) petitjeanNumber = 0; else petitjeanNumber = (diameter - radius) / (double) diameter; return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( petitjeanNumber), getDescriptorNames()); } PetitjeanNumberDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtomContainer atomContainer); @Override IDescriptorResult getDescriptorResultType(); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testSingleAtomCase() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("O"); Assert.assertEquals(0, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.01); }