Skip to content

Commit

Permalink
Added unit test for undefined G-M partial charges
Browse files Browse the repository at this point in the history
Change-Id: I71ed92eda37139a25a46f0af34555b8be4f36888
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rajarshi authored and egonw committed Feb 20, 2012
1 parent 7d698ef commit 38b548f
Showing 1 changed file with 38 additions and 5 deletions.
Expand Up @@ -24,19 +24,27 @@
package org.openscience.cdk.charges;


import java.util.Iterator;

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.Atom;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
import org.openscience.cdk.io.ISimpleChemObjectReader;
import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.tools.LonePairElectronChecker;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;

import java.util.Iterator;
import java.util.List;
import java.io.InputStream;

/**
* Description of the Class
Expand Down Expand Up @@ -209,12 +217,37 @@ public void testSetChiCatHydrogen_Double() throws Exception {
*
*/
@Test
public void testSetStepSize() throws Exception {

public void testSetStepSize() throws Exception {
GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges();
int STEP_SIZE = 22;
peoe.setStepSize(STEP_SIZE);
Assert.assertEquals(STEP_SIZE,peoe.getStepSize());

}

@Test
public void testUndefinedPartialCharge() throws Exception {
String filename = "data/mdl/burden_undefined.sdf";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
ChemFile content = reader.read(new ChemFile());
List cList = ChemFileManipulator.getAllAtomContainers(content);
IAtomContainer ac = (IAtomContainer) cList.get(0);

Assert.assertNotNull(ac);
addExplicitHydrogens(ac);
CDKHueckelAromaticityDetector.detectAromaticity(ac);

addExplicitHydrogens(ac);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac);
lpcheck.saturate(ac);

GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges();
peoe.calculateCharges(ac);

for (IAtom atom : ac.atoms()) {
Assert.assertFalse(atom.getSymbol() + " had an undefined partial charge", Double.isNaN(atom.getCharge()));
Assert.assertFalse(Double.isInfinite(atom.getCharge()));
}
}
}

0 comments on commit 38b548f

Please sign in to comment.