📄 pielectronegativitydescriptortest.java
字号:
/* $RCSfile$
* $Author: miguelrojasch $
* $Date: 2006-05-11 14:25:07 +0200 (Do, 11 Mai 2006) $
* $Revision: 6221 $
*
* Copyright (C) 2004-2007 Miguel Rojas <miguel.rojas@uni-koeln.de>
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.openscience.cdk.test.qsar.descriptors.atomic;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.qsar.IAtomicDescriptor;
import org.openscience.cdk.qsar.descriptors.atomic.PiElectronegativityDescriptor;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.test.CDKTestCase;
import org.openscience.cdk.tools.HydrogenAdder;
import org.openscience.cdk.tools.LonePairElectronChecker;
/**
* TestSuite that runs all QSAR tests.
*
* @cdk.module test-qsar
*/
public class PiElectronegativityDescriptorTest extends CDKTestCase {
/**
* Constructor for the PiElectronegativityDescriptorTest object
*
*/
public PiElectronegativityDescriptorTest() {}
/**
* A unit test suite for JUnit
*
*@return The test suite
*/
public static Test suite() {
return new TestSuite(PiElectronegativityDescriptorTest.class);
}
/**
* A unit test for JUnit with Methyl Fluoride
*/
public void testPiElectronegativityDescriptor_Methyl_Fluoride() throws ClassNotFoundException, CDKException, java.lang.Exception {
double [] testResult={3.9608,0.0,0.0,0.0,0.0};/* from Petra online: http://www2.chemie.uni-erlangen.de/services/petra/smiles.phtml*/
IAtomicDescriptor descriptor = new PiElectronegativityDescriptor();
Integer[] params = new Integer[1];
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("FC");
HydrogenAdder hAdder = new HydrogenAdder();
hAdder.addExplicitHydrogensToSatisfyValency(mol);
LonePairElectronChecker lpcheck = new LonePairElectronChecker();
lpcheck.newSaturate(mol);
for (int i = 0 ; i < mol.getAtomCount(); i++){
params[0] = new Integer(10);
descriptor.setParameters(params);
double result= ((DoubleResult)descriptor.calculate(mol.getAtom(i),mol).getValue()).doubleValue();
// logger.debug("result: "+result);
if(result == 0.0)
assertEquals(testResult[i],result, 0.0001);
else {
assertTrue(result != 0.0);
assertEquals(testResult[i],result, 0.03);
}
}
}
/**
* A unit test for JUnit with Methyl Chloride
*/
public void testPiElectronegativityDescriptor_Methyl_Chloride() throws ClassNotFoundException, CDKException, java.lang.Exception {
double [] testResult={4.7054,0.0,0.0,0.0,0.0};/* from Petra online: http://www2.chemie.uni-erlangen.de/services/petra/smiles.phtml*/
IAtomicDescriptor descriptor = new PiElectronegativityDescriptor();
Integer[] params = new Integer[1];
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("ClC");
HydrogenAdder hAdder = new HydrogenAdder();
hAdder.addExplicitHydrogensToSatisfyValency(mol);
LonePairElectronChecker lpcheck = new LonePairElectronChecker();
lpcheck.newSaturate(mol);
for (int i = 0 ; i < mol.getAtomCount(); i++){
params[0] = new Integer(10);
descriptor.setParameters(params);
double result= ((DoubleResult)descriptor.calculate(mol.getAtom(i),mol).getValue()).doubleValue();
// logger.debug("result: "+result);
if(result == 0.0)
assertEquals(testResult[i],result, 0.0001);
else {
assertTrue(result != 0.0);
assertEquals(testResult[i],result, 0.01);
}
}
}
/**
* A unit test for JUnit with Methyl iodide
*/
public void testPiElectronegativityDescriptor_Methyl_Iodide() throws ClassNotFoundException, CDKException, java.lang.Exception {
double [] testResult={4.1951,0.0,0.0,0.0,0.0};/* from Petra online: http://www2.chemie.uni-erlangen.de/services/petra/smiles.phtml*/
IAtomicDescriptor descriptor = new PiElectronegativityDescriptor();
Integer[] params = new Integer[1];
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("IC");
HydrogenAdder hAdder = new HydrogenAdder();
hAdder.addExplicitHydrogensToSatisfyValency(mol);
LonePairElectronChecker lpcheck = new LonePairElectronChecker();
lpcheck.newSaturate(mol);
for (int i = 0 ; i < mol.getAtomCount(); i++){
params[0] = new Integer(10);
descriptor.setParameters(params);
double result= ((DoubleResult)descriptor.calculate(mol.getAtom(i),mol).getValue()).doubleValue();
// logger.debug("result: "+result);
if(result == 0.0)
assertEquals(testResult[i],result, 0.0001);
else {
assertTrue(result != 0.0);
assertEquals(testResult[i],result, 0.01);
}
}
}
/**
* A unit test for JUnit with Methyl Bromide
*/
public void testPiElectronegativityDescriptor_Methyl_Bromide() throws ClassNotFoundException, CDKException, java.lang.Exception {
double [] testResult={3.8922,0.0,0.0,0.0,0.0};/* from Petra online: http://www2.chemie.uni-erlangen.de/services/petra/smiles.phtml*/
IAtomicDescriptor descriptor = new PiElectronegativityDescriptor();
Integer[] params = new Integer[1];
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("BrC");
HydrogenAdder hAdder = new HydrogenAdder();
hAdder.addExplicitHydrogensToSatisfyValency(mol);
LonePairElectronChecker lpcheck = new LonePairElectronChecker();
lpcheck.newSaturate(mol);
for (int i = 0 ; i < mol.getAtomCount(); i++){
params[0] = new Integer(10);
descriptor.setParameters(params);
double result= ((DoubleResult)descriptor.calculate(mol.getAtom(i),mol).getValue()).doubleValue();
// logger.debug("result: "+result);
if(result == 0.0)
assertEquals(testResult[i],result, 0.0001);
else {
assertTrue(result != 0.0);
assertEquals(testResult[i],result, 0.03);
}
}
}
/**
* A unit test for JUnit with Methyl Alcohol
*/
public void testPiElectronegativityDescriptor_Methyl_Alcohol() throws ClassNotFoundException, CDKException, java.lang.Exception {
double [] testResult={3.1138,0.0,0.0,0.0,0.0};/* from Petra online: http://www2.chemie.uni-erlangen.de/services/petra/smiles.phtml*/
IAtomicDescriptor descriptor = new PiElectronegativityDescriptor();
Integer[] params = new Integer[1];
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("OC");
HydrogenAdder hAdder = new HydrogenAdder();
hAdder.addExplicitHydrogensToSatisfyValency(mol);
LonePairElectronChecker lpcheck = new LonePairElectronChecker();
lpcheck.newSaturate(mol);
for (int i = 0 ; i < 4; i++){
params[0] = new Integer(10);
descriptor.setParameters(params);
double result= ((DoubleResult)descriptor.calculate(mol.getAtom(i),mol).getValue()).doubleValue();
// logger.debug("result: "+result);
if(result == 0.0)
assertEquals(testResult[i],result, 0.0001);
else {
assertTrue(result != 0.0);
assertEquals(testResult[i],result, 0.01);
}
}
}
/**
* A unit test for JUnit with Formaldehyde
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -