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

📄 cml23fragmentstest.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* $RCSfile$ * $Author: egonw $ * $Date: 2007-05-05 12:00:36 +0000 (Sa, 05 Mai 2007) $ * $Revision: 8301 $ * * Copyright (C) 2003-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. * All we ask is that proper credit is given for our work, which includes * - but is not limited to - adding the above copyright notice to the beginning * of your source code files, and to any copyright notice that you may distribute * with programs based on this work. *  * 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.io.cml;import java.io.ByteArrayInputStream;import java.util.Enumeration;import junit.framework.Test;import junit.framework.TestSuite;import org.openscience.cdk.CDKConstants;import org.openscience.cdk.dict.DictRef;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IBond;import org.openscience.cdk.interfaces.IChemFile;import org.openscience.cdk.interfaces.IMolecule;import org.openscience.cdk.interfaces.IReaction;import org.openscience.cdk.interfaces.IReactionSet;import org.openscience.cdk.io.CMLReader;import org.openscience.cdk.qsar.DescriptorSpecification;import org.openscience.cdk.qsar.DescriptorValue;import org.openscience.cdk.qsar.result.DoubleResult;import org.openscience.cdk.qsar.result.IDescriptorResult;import org.openscience.cdk.test.CDKTestCase;/** * Atomic tests for the reading CML documents. All tested CML strings are valid CML 2.3, * as can be determined in cdk/src/org/openscience/cdk/test/io/cml/cml23TestFramework.xml. * * @cdk.module test-io * * @author Egon Willighagen <egonw@sci.kun.nl> */public class CML23FragmentsTest extends CDKTestCase {    public CML23FragmentsTest(String name) {        super(name);    }    public static Test suite() {        return new TestSuite(CML23FragmentsTest.class);    }    public void testAtomId() throws Exception {        String cmlString = "<molecule id='m1'><atomArray><atom id='a1'/></atomArray></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(1, mol.getAtomCount());        IAtom atom = mol.getAtom(0);        assertEquals("a1", atom.getID());    }            public void testAtomId3() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2 a3'/></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(3, mol.getAtomCount());        IAtom atom = mol.getAtom(1);        assertEquals("a2", atom.getID());    }        public void testAtomElementType3() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1' elementType='C'/></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(1, mol.getAtomCount());        IAtom atom = mol.getAtom(0);        assertEquals("C", atom.getSymbol());    }        public void testBond() throws Exception {        String cmlString = "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(2, mol.getAtomCount());        assertEquals(1, mol.getBondCount());        org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);        assertEquals(2, bond.getAtomCount());        IAtom atom1 = bond.getAtom(0);        IAtom atom2 = bond.getAtom(1);        assertEquals("a1", atom1.getID());        assertEquals("a2", atom2.getID());    }    public void testBond4() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2 a3'/><bondArray atomRef1='a1 a1' atomRef2='a2 a3' bondID='b1 b2'/></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(3, mol.getAtomCount());        assertEquals(2, mol.getBondCount());        org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);        assertEquals(2, bond.getAtomCount());        IAtom atom1 = bond.getAtom(0);        IAtom atom2 = bond.getAtom(1);        assertEquals("a1", atom1.getID());        assertEquals("a2", atom2.getID());        assertEquals("b2", mol.getBond(1).getID());    }    public void testBond5() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2 a3'/><bondArray atomRef1='a1 a1' atomRef2='a2 a3' order='1 1'/></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(3, mol.getAtomCount());        assertEquals(2, mol.getBondCount());        org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);        assertEquals(2, bond.getAtomCount());        assertEquals(1.0, bond.getOrder(), 0.0001);        bond = mol.getBond(1);        assertEquals(2, bond.getAtomCount());        assertEquals(1.0, bond.getOrder(), 0.0001);    }    public void testBondId() throws Exception {        String cmlString = "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(2, mol.getAtomCount());        assertEquals(1, mol.getBondCount());        org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);        assertEquals("b1", bond.getID());    }    public void testBondStereo() throws Exception {    	String cmlString = "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'><bondStereo dictRef='cml:H'/></bond></bondArray></molecule>";    	IChemFile chemFile = parseCMLString(cmlString);    	IMolecule mol = checkForSingleMoleculeFile(chemFile);    	assertEquals(2, mol.getAtomCount());    	assertEquals(1, mol.getBondCount());    	IBond bond = mol.getBond(0);    	assertEquals(CDKConstants.STEREO_BOND_DOWN, bond.getStereo());    }  public void testBondAromatic() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2'/><bondArray atomRef1='a1' atomRef2='a2' order='A'/></molecule>";        IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);        assertEquals(2, mol.getAtomCount());        assertEquals(1, mol.getBondCount());        org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);        assertEquals(CDKConstants.BONDORDER_SINGLE, bond.getOrder(), 0.0001);        assertEquals(true, bond.getFlag(CDKConstants.ISAROMATIC));    }        public void testBondAromatic2() throws Exception {      String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2'/><bondArray><bond atomRefs='a1 a2' order='2'><bondType dictRef='cdk:aromaticBond'/></bond></bondArray></molecule>";      IChemFile chemFile = parseCMLString(cmlString);      IMolecule mol = checkForSingleMoleculeFile(chemFile);      assertEquals(2, mol.getAtomCount());      assertEquals(1, mol.getBondCount());      org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);      assertEquals(CDKConstants.BONDORDER_DOUBLE, bond.getOrder(), 0.0001);      assertEquals(true, bond.getFlag(CDKConstants.ISAROMATIC));  }  public void testList() throws Exception {        String cmlString =           "<list>" +           "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule>" +          "<molecule id='m2'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule>" +          "</list>";                IChemFile chemFile = parseCMLString(cmlString);        checkForXMoleculeFile(chemFile, 2);    }    public void testCoordinates2D() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2' x2='0.0 0.1' y2='1.2 1.3'/></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);                assertEquals(2, mol.getAtomCount());        assertNotNull(mol.getAtom(0).getPoint2d());        assertNotNull(mol.getAtom(1).getPoint2d());        assertNull(mol.getAtom(0).getPoint3d());        assertNull(mol.getAtom(1).getPoint3d());    }      public void testCoordinates3D() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2' x3='0.0 0.1' y3='1.2 1.3' z3='2.1 2.5'/></molecule>";                IChemFile chemFile = parseCMLString(cmlString);        IMolecule mol = checkForSingleMoleculeFile(chemFile);                assertEquals(2, mol.getAtomCount());        assertNull(mol.getAtom(0).getPoint2d());        assertNull(mol.getAtom(1).getPoint2d());        assertNotNull(mol.getAtom(0).getPoint3d());        assertNotNull(mol.getAtom(1).getPoint3d());    }        public void testFractional3D() throws Exception {        String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2' xFract='0.0 0.1' yFract='1.2 1.3' zFract='2.1 2.5'/></molecule>";

⌨️ 快捷键说明

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