1 /* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net> 2 * 3 * Contact: cdk-devel@lists.sourceforge.net 4 * 5 * This program is free software; you can redistribute it and/or modify it under 6 * the terms of the GNU Lesser General Public License as published by the Free 7 * Software Foundation; either version 2.1 of the License, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 * details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this program; if not, write to the Free Software Foundation, Inc., 17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 package org.openscience.cdk.qsar.descriptors.molecular; 20 21 import org.junit.Assert; 22 import org.junit.Before; 23 import org.junit.Test; 24 import org.openscience.cdk.interfaces.IAtom; 25 import org.openscience.cdk.interfaces.IBond; 26 import org.openscience.cdk.interfaces.IChemObjectBuilder; 27 import org.openscience.cdk.interfaces.IAtomContainer; 28 import org.openscience.cdk.silent.SilentChemObjectBuilder; 29 import org.openscience.cdk.qsar.result.DoubleResult; 30 import org.openscience.cdk.qsar.result.IDescriptorResult; 31 32 /** 33 * TestSuite that runs unit tests. 34 * 35 * @cdk.module test-qsarmolecular 36 * @see MannholdLogPDescriptor 37 */ 38 public class MannholdLogPDescriptorTest extends MolecularDescriptorTest { 39 40 @Before setUp()41 public void setUp() throws Exception { 42 setDescriptor(MannholdLogPDescriptor.class); 43 } 44 45 @Test testMethanol()46 public void testMethanol() { 47 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); 48 IAtomContainer methanol = builder.newInstance(IAtomContainer.class); 49 methanol.addAtom(builder.newInstance(IAtom.class, "C")); 50 methanol.addAtom(builder.newInstance(IAtom.class, "O")); 51 methanol.addBond(0, 1, IBond.Order.SINGLE); 52 IDescriptorResult result = descriptor.calculate(methanol).getValue(); 53 Assert.assertTrue(result instanceof DoubleResult); 54 Assert.assertEquals(1.46, ((DoubleResult) result).doubleValue(), 0.01); 55 } 56 57 @Test testMethane()58 public void testMethane() { 59 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); 60 IAtomContainer methane = builder.newInstance(IAtomContainer.class); 61 methane.addAtom(builder.newInstance(IAtom.class, "C")); 62 IDescriptorResult result = descriptor.calculate(methane).getValue(); 63 Assert.assertTrue(result instanceof DoubleResult); 64 Assert.assertEquals(1.57, ((DoubleResult) result).doubleValue(), 0.01); 65 } 66 67 @Test testChloroform()68 public void testChloroform() { 69 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); 70 IAtomContainer chloroform = builder.newInstance(IAtomContainer.class); 71 chloroform.addAtom(builder.newInstance(IAtom.class, "C")); 72 for (int i = 0; i < 3; i++) { 73 chloroform.addAtom(builder.newInstance(IAtom.class, "Cl")); 74 chloroform.addBond(0, (i + 1), IBond.Order.SINGLE); 75 } 76 IDescriptorResult result = descriptor.calculate(chloroform).getValue(); 77 Assert.assertTrue(result instanceof DoubleResult); 78 Assert.assertEquals(1.24, ((DoubleResult) result).doubleValue(), 0.01); 79 } 80 } 81