MannholdLogPDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer atomContainer) { IAtomContainer ac = null; try { ac = (IAtomContainer) atomContainer.clone(); } catch (CloneNotSupportedException e) { return getDummyDescriptorValue(e); } int carbonCount = 0; int heteroCount = 0; for (IAtom atom : ac.atoms()) { if (atom.getAtomicNumber() != IElement.H) { if (atom.getAtomicNumber() == IElement.C) { carbonCount++; } else { heteroCount++; } } } double mLogP = 1.46 + 0.11 * carbonCount - 0.11 * heteroCount; return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(mLogP), getDescriptorNames()); }  @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 testMethanol() { IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); IAtomContainer methanol = builder.newInstance(IAtomContainer.class); methanol.addAtom(builder.newInstance(IAtom.class, "C")); methanol.addAtom(builder.newInstance(IAtom.class, "O")); methanol.addBond(0, 1, IBond.Order.SINGLE); IDescriptorResult result = descriptor.calculate(methanol).getValue(); Assert.assertTrue(result instanceof DoubleResult); Assert.assertEquals(1.46, ((DoubleResult) result).doubleValue(), 0.01); }
@Test public void testMethane() { IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); IAtomContainer methane = builder.newInstance(IAtomContainer.class); methane.addAtom(builder.newInstance(IAtom.class, "C")); IDescriptorResult result = descriptor.calculate(methane).getValue(); Assert.assertTrue(result instanceof DoubleResult); Assert.assertEquals(1.57, ((DoubleResult) result).doubleValue(), 0.01); }
@Test public void testChloroform() { IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); IAtomContainer chloroform = builder.newInstance(IAtomContainer.class); chloroform.addAtom(builder.newInstance(IAtom.class, "C")); for (int i = 0; i < 3; i++) { chloroform.addAtom(builder.newInstance(IAtom.class, "Cl")); chloroform.addBond(0, (i + 1), IBond.Order.SINGLE); } IDescriptorResult result = descriptor.calculate(chloroform).getValue(); Assert.assertTrue(result instanceof DoubleResult); Assert.assertEquals(1.24, ((DoubleResult) result).doubleValue(), 0.01); }