Skip to content

Commit

Permalink
Added the Mannhold LogP descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Oct 31, 2009
1 parent a7adc9f commit 1e6b6cd
Show file tree
Hide file tree
Showing 3 changed files with 272 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/refs/cheminf.bibx
Expand Up @@ -401,6 +401,17 @@ obtained by accurate mass spectrometry</bibtex:title>
</bibtex:article>
</bibtex:entry>

<bibtex:entry id="Mannhold2009">
<bibtex:article>
<bibtex:author>Mannhold, R. and Poda, G.I. and Ostermann, C. and Tetko, I.V.</bibtex:author>
<bibtex:title>Calculation of molecular lipophilicity: State-of-the-art and comparison of log P methods on more than 96,000 compounds</bibtex:title>
<bibtex:journal>J.Pharm.Sci.</bibtex:journal>
<bibtex:year>2009</bibtex:year>
<bibtex:volume>98</bibtex:volume>
<bibtex:pages>861--893</bibtex:pages>
</bibtex:article>
</bibtex:entry>

<bibtex:entry id="Molchanova96">
<bibtex:article>
<bibtex:author>Molchanova</bibtex:author>
Expand Down
@@ -0,0 +1,177 @@
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openscience.cdk.qsar.descriptors.molecular;

import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.config.Elements;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IDescriptor;
import org.openscience.cdk.qsar.IMolecularDescriptor;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.DoubleResultType;
import org.openscience.cdk.qsar.result.IDescriptorResult;

/**
* <p>Prediction of logP based on the number of carbon and hetero atoms. The
* implemented equation was proposed in {@cdk.cite Mannhold2009}.
*
* @cdk.module qsarmolecular
* @cdk.githash
* @cdk.set qsar-descriptors
* @cdk.dictref qsar-descriptors:mannholdLogP
*
* @cdk.keyword LogP
* @cdk.keyword descriptor
*/
@TestClass(
"org.openscience.cdk.qsar.descriptors.molecular.MannholdLogPDescriptorTest"
)
public class MannholdLogPDescriptor implements IMolecularDescriptor {

private static final String[] names = {"MLogP"};

/**
* Gets the specification attribute of the MannholdLogPDescriptor object.
*
* @return The specification value
*/
@TestMethod("testGetSpecification")
public DescriptorSpecification getSpecification() {
return new DescriptorSpecification(
"http://www.blueobelisk.org/ontologies/" +
"chemoinformatics-algorithms/#mannholdLogP",
this.getClass().getName(),
"$Id$",
"The Chemistry Development Kit"
);
}

/**
* This {@link IDescriptor} does not have any parameters. If it had, this
* would have been the method to set them.
*
* @param params The new parameter value
* @exception CDKException Exception throw when invalid parameter values
* are passed
* @see #getParameters
*/
@TestMethod("testSetParameters_arrayObject")
public void setParameters(Object[] params) throws CDKException {
if (params != null && params.length > 0) {
throw new CDKException("MannholdLogPDescriptor has no parameters.");
}
}

/**
* Gets the parameters attribute of the MannholdLogPDescriptor object.
*
* @return A zero-length Object array.
* @see #setParameters
*/
@TestMethod("testGetParameters")
public Object[] getParameters() {
return new Object[0];
}

@TestMethod("testNamesConsistency")
public String[] getDescriptorNames() {
return names;
}

private DescriptorValue getDummyDescriptorValue(Exception e) {
return new DescriptorValue(getSpecification(), getParameterNames(),
getParameters(), new DoubleResult(Double.NaN),
getDescriptorNames(), e
);
}

/**
* Calculates the Mannhold LogP for an atom container.
*
* @param atomContainer {@link IAtomContainer} to calculate the
* descriptor value for.
* @return A descriptor value wrapping a {@link DoubleResult}.
*/
@TestMethod("testCalculate_IAtomContainer")
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 (!Elements.HYDROGEN.getSymbol().equals(atom.getSymbol())) {
if (Elements.CARBON.getSymbol().equals(atom.getSymbol())) {
carbonCount++;
} else {
heteroCount++;
}
}
}
double mLogP = 1.46 + 0.11*carbonCount - 0.11*heteroCount;

return new DescriptorValue(
getSpecification(), getParameterNames(), getParameters(),
new DoubleResult(mLogP), getDescriptorNames()
);
}

/**
* Returns a type of return value calculated by this descriptor.
*
* @return returns a {@link DoubleResult}.
*/
@TestMethod("testGetDescriptorResultType")
public IDescriptorResult getDescriptorResultType() {
return new DoubleResultType();
}

/**
* Gets the parameterNames attribute for this descriptor.
*
* @return A zero-length String array.
*/
@TestMethod("testGetParameterNames")
public String[] getParameterNames() {
return new String[0];
}

/**
* Gets the parameterType attribute for a given parameter name. It
* always returns null, as this descriptor does not have any parameters.
*
* @param name Name of the parameter for which the type is requested.
* @return The parameterType of the given parameter.
*/
@TestMethod("testGetParameterType_String")
public Object getParameterType(String name) {
return null;
}

}

@@ -0,0 +1,84 @@
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.openscience.cdk.qsar.descriptors.molecular;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;

/**
* TestSuite that runs unit tests.
*
* @cdk.module test-qsarmolecular
* @see MannholdLogPDescriptor
*/
public class MannholdLogPDescriptorTest extends MolecularDescriptorTest {

@Before
public void setUp() throws Exception {
setDescriptor(MannholdLogPDescriptor.class);
}

@Test
public void testMethanol() {
IChemObjectBuilder builder =
NoNotificationChemObjectBuilder.getInstance();
IMolecule methanol = builder.newMolecule();
methanol.addAtom(builder.newAtom("C"));
methanol.addAtom(builder.newAtom("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 =
NoNotificationChemObjectBuilder.getInstance();
IMolecule methane = builder.newMolecule();
methane.addAtom(builder.newAtom("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 =
NoNotificationChemObjectBuilder.getInstance();
IMolecule chloroform = builder.newMolecule();
chloroform.addAtom(builder.newAtom("C"));
for (int i=0; i<3; i++) {
chloroform.addAtom(builder.newAtom("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);
}
}

0 comments on commit 1e6b6cd

Please sign in to comment.