⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmff94atomtypematchertest.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* $RCSfile$ * $Author: egonw $ * $Date: 2007-05-01 12:48:26 +0000 (Di, 01 Mai 2007) $ * $Revision: 8283 $ *  * Copyright (C) 1997-2007  The Chemistry Development Kit (CDK) project *  * 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.atomtype;import java.io.InputStream;import java.io.InputStreamReader;import junit.framework.Test;import junit.framework.TestSuite;import org.openscience.cdk.CDKConstants;import org.openscience.cdk.DefaultChemObjectBuilder;import org.openscience.cdk.Molecule;import org.openscience.cdk.atomtype.MMFF94AtomTypeMatcher;import org.openscience.cdk.config.Elements;import org.openscience.cdk.exception.CDKException;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IAtomType;import org.openscience.cdk.interfaces.IBond;import org.openscience.cdk.interfaces.IChemObjectBuilder;import org.openscience.cdk.interfaces.IMolecule;import org.openscience.cdk.io.MDLReader;import org.openscience.cdk.nonotify.NNMolecule;import org.openscience.cdk.test.CDKTestCase;import org.openscience.cdk.tools.AtomTypeTools;import org.openscience.cdk.tools.HydrogenAdder;import org.openscience.cdk.tools.LoggingTool;import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;/** * Checks the functionality of the AtomType-MMFF94AtomTypeMatcher. * * @cdk.module test-extra * * @see org.openscience.cdk.atomtype.MMFF94AtomTypeMatcher */public class MMFF94AtomTypeMatcherTest extends CDKTestCase {	private LoggingTool logger;	private final IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();	private HydrogenAdder haad=new HydrogenAdder();		private static IMolecule testMolecule = null;		public MMFF94AtomTypeMatcherTest(String name) {        super(name);    }    public void setUp() throws Exception {    	logger = new LoggingTool(this);    }        public void setUpTestMolecule() throws Exception {    	if (testMolecule == null) {        	//logger.debug("**** START ATOMTYPE TEST ******");        	AtomTypeTools att=new AtomTypeTools();            MMFF94AtomTypeMatcher atm= new MMFF94AtomTypeMatcher();            InputStream ins=this.getClass().getClassLoader().getResourceAsStream("data/mdl/mmff94AtomTypeTest_molecule.mol");            MDLReader mdl=new MDLReader(new InputStreamReader(ins));            testMolecule=(Molecule)mdl.read(new NNMolecule());                       att.assignAtomTypePropertiesToAtom(testMolecule);            for (int i=0;i<testMolecule.getAtomCount();i++){            	logger.debug("atomNr:" + testMolecule.getAtom(i).toString());            	IAtomType matched = atm.findMatchingAtomType(testMolecule, testMolecule.getAtom(i));            	assertNotNull(matched);            	AtomTypeManipulator.configure(testMolecule.getAtom(i), matched);                   }                        logger.debug("MMFF94 Atom 0:"+testMolecule.getAtom(0).getAtomTypeName());    	}    }    public static Test suite() {        return new TestSuite(MMFF94AtomTypeMatcherTest.class);    }        public void testMMFF94AtomTypeMatcher() throws ClassNotFoundException, CDKException, java.lang.Exception {    	MMFF94AtomTypeMatcher matcher = new MMFF94AtomTypeMatcher();	    assertNotNull(matcher);	        }        public void testFindMatchingAtomType_IAtomContainer_IAtom() throws ClassNotFoundException, CDKException, java.lang.Exception {    	setUpTestMolecule();    	for (int i=0;i<testMolecule.getAtomCount();i++) {    		assertNotNull(testMolecule.getAtom(i).getAtomTypeName());    		assertTrue(testMolecule.getAtom(i).getAtomTypeName().length() > 0);    	}    }        // FIXME: Below should be tests for *all* atom types in the MM2 atom type specificiation        public void testSthi() throws Exception {    	setUpTestMolecule();    	assertEquals("Sthi",testMolecule.getAtom(0).getAtomTypeName());    }    public void testCsp2() throws Exception {    	setUpTestMolecule();    	assertEquals("Csp2",testMolecule.getAtom(7).getAtomTypeName());    }    public void testCsp() throws Exception {    	setUpTestMolecule();        assertEquals("Csp",testMolecule.getAtom(51).getAtomTypeName());    }    public void testNdbO() throws Exception {    	setUpTestMolecule();        assertEquals("N=O",testMolecule.getAtom(148).getAtomTypeName());    }    public void testOar() throws Exception {    	setUpTestMolecule();        assertEquals("Oar",testMolecule.getAtom(198).getAtomTypeName());    }    public void testN2OX() throws Exception {    	setUpTestMolecule();        assertEquals("N2OX",testMolecule.getAtom(233).getAtomTypeName());    }    public void testNAZT() throws Exception {    	setUpTestMolecule();        assertEquals("NAZT",testMolecule.getAtom(256).getAtomTypeName());    }        // Other tests    	public void testFindMatchingAtomType_IAtomContainer_IAtom_Methanol() throws ClassNotFoundException, CDKException, java.lang.Exception {//		logger.debug("**** START ATOMTYPE Methanol TEST ******");		//System.out.println("**** START ATOMTYPE Methanol TEST ******");          IMolecule mol = builder.newMolecule();		IAtom carbon = builder.newAtom(Elements.CARBON);		IAtom oxygen = builder.newAtom(Elements.OXYGEN);		// making sure the order matches the test results		mol.addAtom(carbon); 		mol.addAtom(oxygen);		mol.addBond(builder.newBond(carbon, oxygen, CDKConstants.BONDORDER_SINGLE));				haad.addExplicitHydrogensToSatisfyValency(mol);        		String [] testResult={"C","O","HC","HC","HC","HO"};		AtomTypeTools att=new AtomTypeTools();        MMFF94AtomTypeMatcher atm= new MMFF94AtomTypeMatcher();		att.assignAtomTypePropertiesToAtom(mol,false);        for (int i=0;i<mol.getAtomCount();i++){        	logger.debug("atomNr:" + mol.getAtom(i).toString());        	IAtomType matched = atm.findMatchingAtomType(mol, mol.getAtom(i));        	assertNotNull(matched);        	AtomTypeManipulator.configure(mol.getAtom(i), matched);               }        for (int i=0; i<testResult.length;i++){        	assertEquals(testResult[i],mol.getAtom(i).getAtomTypeName());        }                //System.out.println("MMFF94 Atom 0:"+mol.getAtom(0).getAtomTypeName());       	}	/**	 *  A unit test for JUnit with Methylamine	 */	public void testFindMatchingAtomType_IAtomContainer_IAtom_Methylamine() throws ClassNotFoundException, CDKException, java.lang.Exception {		//System.out.println("**** START ATOMTYPE Methylamine TEST ******");			IMolecule mol = builder.newMolecule();		IAtom carbon = builder.newAtom(Elements.CARBON);		IAtom nitrogen = builder.newAtom(Elements.NITROGEN);		// making sure the order matches the test results		mol.addAtom(carbon); 		mol.addAtom(nitrogen);		mol.addBond(builder.newBond(carbon, nitrogen, CDKConstants.BONDORDER_SINGLE));		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -