1 /* Copyright (C) 2007 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 6 * modify it under the terms of the GNU Lesser General Public License 7 * as published by the Free Software Foundation; either version 2.1 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more 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 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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.CDKTestCase; 25 import org.openscience.cdk.DefaultChemObjectBuilder; 26 import org.openscience.cdk.interfaces.IAtom; 27 import org.openscience.cdk.interfaces.IBond; 28 import org.openscience.cdk.interfaces.IAtomContainer; 29 30 /** 31 * @cdk.module test-qsarmolecular 32 */ 33 public class ChiIndexUtilsTest extends CDKTestCase { 34 35 DefaultChemObjectBuilder builder; 36 ChiIndexUtilsTest()37 public ChiIndexUtilsTest() {} 38 39 @Before setup()40 public void setup() { 41 builder = (DefaultChemObjectBuilder) DefaultChemObjectBuilder.getInstance(); 42 } 43 44 @Test testDeltaVSulphurSO()45 public void testDeltaVSulphurSO() { 46 IAtom s = builder.newInstance(IAtom.class, "S"); 47 IAtom o = builder.newInstance(IAtom.class, "O"); 48 IBond b = builder.newInstance(IBond.class, s, o); 49 b.setOrder(IBond.Order.DOUBLE); 50 51 IAtomContainer m = builder.newInstance(IAtomContainer.class); 52 m.addAtom(s); 53 m.addAtom(o); 54 m.addBond(b); 55 56 double deltav = ChiIndexUtils.deltavSulphur(s, m); 57 Assert.assertEquals(1.33, deltav, 0.01); 58 } 59 60 @Test testDeltaVSulphurSO2()61 public void testDeltaVSulphurSO2() { 62 IAtom s = builder.newInstance(IAtom.class, "S"); 63 IAtom o1 = builder.newInstance(IAtom.class, "O"); 64 IAtom o2 = builder.newInstance(IAtom.class, "O"); 65 IBond b1 = builder.newInstance(IBond.class, s, o1); 66 IBond b2 = builder.newInstance(IBond.class, s, o2); 67 b1.setOrder(IBond.Order.DOUBLE); 68 b2.setOrder(IBond.Order.DOUBLE); 69 70 IAtomContainer m = builder.newInstance(IAtomContainer.class); 71 m.addAtom(s); 72 m.addAtom(o1); 73 m.addBond(b1); 74 m.addAtom(o2); 75 m.addBond(b2); 76 77 double deltav = ChiIndexUtils.deltavSulphur(s, m); 78 Assert.assertEquals(2.67, deltav, 0.01); 79 } 80 81 } 82