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