Skip to content

Commit

Permalink
Aromaticity information is lost on descriptor execution unless the 'a…
Browse files Browse the repository at this point in the history
…romaticity parameter' is set to true. Already perceived -- pre-perceived -- aromaticity information should not be lost automatically if this parameter is set to false. Perception of unset parameters only via the helper method in the AtomContainerManipulator rectifies this issue. Three test cases: 1) Benzene with pre-perceived aromaticity and no aromaticity perception in the descriptor. 2) Benzene with no pre-perceived aromaticity and no aromaticity perception in the descriptor. 3) Benzene with no pre-perceived aromaticity and perception in the descriptor.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
Stephan Beisken authored and egonw committed Feb 8, 2014
1 parent ed01edc commit 13c5dc2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Expand Up @@ -210,7 +210,7 @@ public DescriptorValue calculate(IAtomContainer atomContainer) {
IAtomContainer ac;
try {
ac = (IAtomContainer) atomContainer.clone();
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac);
AtomContainerManipulator.percieveAtomTypesAndConfigureUnsetProperties(ac);
CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(ac.getBuilder());
hAdder.addImplicitHydrogens(ac);
AtomContainerManipulator.convertImplicitToExplicitHydrogens(ac);
Expand Down
Expand Up @@ -28,11 +28,16 @@
import org.junit.Ignore;
import org.junit.Test;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.aromaticity.Aromaticity;
import org.openscience.cdk.aromaticity.ElectronDonation;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.Cycles;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.smiles.SmilesParser;

import static org.hamcrest.Matchers.closeTo;

/**
* TestSuite that runs XlogP tests.
*
Expand Down Expand Up @@ -267,5 +272,37 @@ public void testno1596() throws ClassNotFoundException, CDKException, java.lang.
//logger.debug("no1822:"+((DoubleResult)descriptor.calculate(mol).getValue()).doubleValue()+"\n");
Assert.assertEquals(2.36, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.1); //at: 16
}

@Test public void testAromaticBenzene() throws java.lang.Exception {
Object[] params = { false, true };
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("C1=CC=CC=C1"); // benzene
Aromaticity aromaticity = new Aromaticity(ElectronDonation.daylight(), Cycles.all());
aromaticity.apply(mol);
assertAtomTypesPerceived(mol);
addExplicitHydrogens(mol);
Assert.assertThat(((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), closeTo(2.02, 0.01));
}

@Test public void testNonAromaticBenzene() throws java.lang.Exception {
Object[] params = { false, true };
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("C1=CC=CC=C1"); // benzene
assertAtomTypesPerceived(mol);
addExplicitHydrogens(mol);
Assert.assertThat(((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), closeTo(2.08, 0.01));
}

@Test public void testPerceivedAromaticBenzene() throws java.lang.Exception {
Object[] params = { true, true };
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("C1=CC=CC=C1"); // benzene
assertAtomTypesPerceived(mol);
addExplicitHydrogens(mol);
Assert.assertThat(((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), closeTo(2.02, 0.01));
}
}

0 comments on commit 13c5dc2

Please sign in to comment.