1 /* Copyright (C) 2007 Federico 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 java.io.InputStream; 22 23 import org.junit.Assert; 24 import org.junit.Before; 25 import org.junit.Test; 26 import org.openscience.cdk.AtomContainer; 27 import org.openscience.cdk.interfaces.IAtomContainer; 28 import org.openscience.cdk.io.MDLV2000Reader; 29 import org.openscience.cdk.qsar.DescriptorValue; 30 import org.openscience.cdk.qsar.result.DoubleArrayResult; 31 32 /** 33 * @cdk.module test-qsarmolecular 34 */ 35 public class AutocorrelationDescriptorMassTest extends MolecularDescriptorTest { 36 AutocorrelationDescriptorMassTest()37 public AutocorrelationDescriptorMassTest() { 38 super(); 39 } 40 41 @Before setUp()42 public void setUp() throws Exception { 43 setDescriptor(AutocorrelationDescriptorMass.class); 44 } 45 46 @Test test1()47 public void test1() throws Exception { 48 String filename = "data/mdl/clorobenzene.mol"; 49 InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); 50 MDLV2000Reader reader = new MDLV2000Reader(ins); 51 IAtomContainer container = reader.read(new AtomContainer()); 52 DescriptorValue count = new AutocorrelationDescriptorMass().calculate(container); 53 Assert.assertEquals(5, count.getValue().length()); 54 Assert.assertTrue(count.getValue() instanceof DoubleArrayResult); 55 DoubleArrayResult result = (DoubleArrayResult) count.getValue(); 56 for (int i = 0; i < 5; i++) { 57 Assert.assertFalse(Double.isNaN(result.get(i))); 58 Assert.assertTrue(0.0 != result.get(i)); 59 } 60 } 61 62 } 63