Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a unit test to check that molecular descriptors do not throw Ex…
…ceptions when disconnected structures are passed

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Sep 28, 2011
1 parent 277dd03 commit 853ca50
Showing 1 changed file with 32 additions and 4 deletions.
Expand Up @@ -20,27 +20,38 @@
*/
package org.openscience.cdk.qsar.descriptors.molecular;

import javax.vecmath.Point3d;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.openscience.cdk.Atom;
import org.openscience.cdk.AtomContainer;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.dict.Dictionary;
import org.openscience.cdk.dict.DictionaryDatabase;
import org.openscience.cdk.dict.Entry;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.*;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IBond.Order;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IMolecularDescriptor;
import org.openscience.cdk.qsar.descriptors.DescriptorTest;
import org.openscience.cdk.qsar.result.*;
import org.openscience.cdk.qsar.result.BooleanResult;
import org.openscience.cdk.qsar.result.DoubleArrayResult;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import org.openscience.cdk.qsar.result.IntegerArrayResult;
import org.openscience.cdk.qsar.result.IntegerResult;
import org.openscience.cdk.tools.diff.AtomContainerDiff;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import javax.vecmath.Point3d;

/**
* Tests for molecular descriptors.
*
Expand Down Expand Up @@ -343,6 +354,23 @@ public void testAtomContainerHandling() throws Exception {
assertEqualOutput(v1, v2, errorMessage);
}

/**
* Descriptors should not throw Exceptions on disconnected structures,
* but return NA instead.
*/
@Test
public void testDisconnectedStructureHandling() throws Exception {
IAtomContainer disconnected = new AtomContainer();
IAtom chloride = new Atom("Cl");
chloride.setFormalCharge(-1);
disconnected.addAtom(chloride);
IAtom sodium = new Atom("Na");
sodium.setFormalCharge(+1);
disconnected.addAtom(sodium);

IDescriptorResult v1 = descriptor.calculate(disconnected).getValue();
}

@Ignore
@Test public void testTakeIntoAccountBondHybridization() {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
Expand Down

0 comments on commit 853ca50

Please sign in to comment.