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

📄 smilesparsertest.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* $Revision: 8332 $ $Author: shk3 $ $Date: 2007-05-15 13:25:07 +0000 (Di, 15 Mai 2007) $ * *  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.smiles;import java.util.Iterator;import java.util.List;import junit.framework.Test;import junit.framework.TestSuite;import org.openscience.cdk.CDKConstants;import org.openscience.cdk.exception.CDKException;import org.openscience.cdk.graph.ConnectivityChecker;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IBond;import org.openscience.cdk.interfaces.IMolecule;import org.openscience.cdk.interfaces.IMoleculeSet;import org.openscience.cdk.interfaces.IPseudoAtom;import org.openscience.cdk.interfaces.IReaction;import org.openscience.cdk.isomorphism.IsomorphismTester;import org.openscience.cdk.layout.StructureDiagramGenerator;import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;import org.openscience.cdk.smiles.SmilesParser;import org.openscience.cdk.test.CDKTestCase;/** * Please see the test.gui package for visual feedback on tests. *  * @author         steinbeck * @cdk.module     test-smiles * @cdk.created    2003-09-19 *  * @see org.openscience.cdk.test.gui.SmilesParserTest */public class SmilesParserTest extends CDKTestCase {		private SmilesParser sp;	/**	 *  Constructor for the SmilesParserTest object	 */	public SmilesParserTest(String name) {		super(name);	}	public void setUp() {		sp = new SmilesParser(NoNotificationChemObjectBuilder.getInstance());	}	/**	 *  A unit test suite for JUnit	 *	 *@return    The test suite	 */	public static Test suite()	{		return new TestSuite(SmilesParserTest.class);	}		public void testPyridine_N_oxideUncharged() throws Exception {		String smiles = "O=n1ccccc1";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(7, mol.getAtomCount());	}		public void testPyridine_N_oxideCharged() throws Exception {		String smiles = "[O-][n+]1ccccc1";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(7, mol.getAtomCount());	}	/*	 * The next methods tests compounds with several conjugated rings	 * These compounds would not fail if the Aromaticity Detection was changed	 * so that a ring is aromatic if all the atoms in a ring have already been flagged	 * as aromatic from the testing of other rings in the system.	 */	public void testUnusualConjugatedRings() throws Exception {				//7090-41-7:		String smiles = "c1(Cl)cc2c3cc(Cl)c(Cl)cc3c2cc1Cl";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(16, mol.getAtomCount());	}		public void testUnusualConjugatedRings_2() throws Exception {		//206-44-0:		String smiles = "c(c(ccc1)ccc2)(c1c(c3ccc4)c4)c23";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(16, mol.getAtomCount());	}		public void testUnusualConjugatedRings_3() throws Exception {			if (!super.runSlowTests()) fail("Skipped time consuming test.");				//207-08-9:		String smiles = "c2ccc1cc3c(cc1c2)c4cccc5cccc3c45";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(20, mol.getAtomCount());	}		public void testUnusualConjugatedRings_4() throws Exception {		//2693-46-1:		String smiles = "Nc1c(c23)cccc3c4ccccc4c2cc1";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(17, mol.getAtomCount());	}		public void testUnusualConjugatedRings_5() throws Exception {		//205-99-2:		String smiles = "c12ccccc1cc3c4ccccc4c5c3c2ccc5";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(20, mol.getAtomCount());	}		public void test187_78_0 () throws Exception {		// are all 4 rings aromatic? Is smiles correct?		String smiles = "c1c(c23)ccc(c34)ccc4ccc2c1";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(14, mol.getAtomCount());	}		public void test187_78_0_PubChem() throws Exception {		// are all 4 rings aromatic? Is smiles correct?		String smiles = "C1=CC2=C3C(=CC=C4C3=C1C=C4)C=C2";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(14, mol.getAtomCount());	}	public void test41814_78_2 () throws Exception {		String smiles = "Cc1cccc2sc3nncn3c12";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(13, mol.getAtomCount());	}		public void test239_64_5 () throws Exception {		String smiles = "c1ccc4c(c1)ccc5c3ccc2ccccc2c3nc45";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(21, mol.getAtomCount());	}		/*	 * Compounds like Indolizine (274-40-8) with a fused nitrogen as part of a 6 membered ring	 * and another ring do not parse	 */	public void testIndolizine () throws Exception {		String smiles = "c2cc1cccn1cc2";		IMolecule mol = sp.parseSmiles(smiles);		assertEquals(9, mol.getAtomCount());	}			/**	 *  A unit test for JUnit	 */	public void testSmiles1() throws Exception {		String smiles = "C1c2c(c3c(c(O)cnc3)cc2)CC(=O)C1";		IMolecule molecule = sp.parseSmiles(smiles);		assertEquals(16, molecule.getAtomCount());	}	/**	 *  A unit test for JUnit	 */	public void testSmiles2() throws Exception {		String smiles = "O=C(O3)C1=COC(OC4OC(CO)C(O)C(O)C4O)C2C1C3C=C2COC(C)=O";		IMolecule molecule = sp.parseSmiles(smiles);		assertEquals(29, molecule.getAtomCount());	}	/**	 *  A unit test for JUnit	 */	public void testSmiles3() throws Exception	{		String smiles = "CN1C=NC2=C1C(N(C)C(N2C)=O)=O";		IMolecule molecule = sp.parseSmiles(smiles);		assertEquals(14, molecule.getAtomCount());	}	/**	 *  A unit test for JUnit	 */	public void testSmiles4() throws Exception {		String smiles = "CN(C)CCC2=CNC1=CC=CC(OP(O)(O)=O)=C12";		IMolecule molecule = sp.parseSmiles(smiles);		assertEquals(19, molecule.getAtomCount());	}	/**	 *  A unit test for JUnit	 */	public void testSmiles5() throws Exception {		String smiles = "O=C(O)C1C(OC(C3=CC=CC=C3)=O)CC2N(C)C1CC2";		IMolecule molecule = sp.parseSmiles(smiles);		assertEquals(21, molecule.getAtomCount());	}	/**	 *  A unit test for JUnit	 */	public void testSmiles6() throws Exception {		String smiles = "C1(C2(C)(C))C(C)=CCC2C1";		IMolecule molecule = sp.parseSmiles(smiles);		assertEquals(10, molecule.getAtomCount());	}	public void testSmiles7() throws Exception {		String smiles = "C1(C=C(C=C(C=C(C=C(C=CC%35=C%36)C%31=C%35C%32=C%33C%36=C%34)C%22=C%31C%23=C%32C%24=C%25C%33=C%26C%34=CC%27=CC%28=CC=C%29)C%14=C%22C%15=C%23C%16=C%24C%17=C%18C%25=C%19C%26=C%27C%20=C%28C%29=C%21)C6=C%14C7=C%15C8=C%16C9=C%17C%12=C%11C%18=C%10C%19=C%20C%21=CC%10=CC%11=CC(C=C%30)=C%12%13)=C(C6=C(C7=C(C8=C(C9=C%13C%30=C5)C5=C4)C4=C3)C3=C2)C2=CC=C1";		IMolecule molecule = sp.parseSmiles(smiles);		assertNotNull(molecule);	}	public void testSmiles8() throws Exception {		String smiles = "CC1(C(=C(CC(C1)O)C)C=CC(=CC=CC(=CC=CC=C(C=CC=C(C=CC1=C(CC(CC1(C)C)O)C)C)C)C)C)C";		IMolecule molecule = sp.parseSmiles(smiles);		assertNotNull(molecule);	}	public void testSmiles9() throws Exception {		String smiles = "NC(C(C)C)C(NC(C(C)O)C(NC(C(C)C)C(NC(CCC(N)=O)C(NC(CC([O-])[O-])C(NCC(NC(CC(N)=O)C(NC(Cc1ccccc1)C(NC(CO)C(NC(Cc2ccccc2)C(NC(CO)C(NC(CC(C)C)C(NC(CCC([O-])[O-])C(NC(CO)C(NC(C(C)C)C(NC(CCCC[N+])C(NC(CCCC[N+])C(NC(CC(C)C)C(NC(CCCC[N+])C(NC(CC([O-])[O-])C(NC(C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O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O)=O";		IMolecule molecule = sp.parseSmiles(smiles);		assertNotNull(molecule);	}	/**	 * @cdk.bug 1296113	 */	public void testSFBug1296113() throws Exception {		String smiles = "S(=O)(=O)(-O)-c1c2c(c(ccc2-N-c2ccccc2)-N=N-c2c3c(c(cc2)-N=N-c2c4c(c(ccc4)-S(=O)(=O)-O)ccc2)cccc3)ccc1";		IMolecule molecule = sp.parseSmiles(smiles);		assertNotNull(molecule);	}    /**     * @cdk.bug 1324105     */    public void testAromaticSmiles2() throws Exception {    	String smiles = "n12:n:n:n:c:2:c:c:c:c:1";    	IMolecule molecule = sp.parseSmiles(smiles);    	Iterator bonds = molecule.bonds();    	while (bonds.hasNext()) assertTrue(((IBond)bonds.next()).getFlag(CDKConstants.ISAROMATIC));    }	/**	 *  A unit test for JUnit	 */	public void testAromaticSmilesWithCharge() throws Exception {		String smiles = "c1cc[c-]cc1";		IMolecule molecule = sp.parseSmiles(smiles);		assertTrue(molecule.getAtom(0).getFlag(CDKConstants.ISAROMATIC));		assertTrue(molecule.getBond(0).getFlag(CDKConstants.ISAROMATIC));	}	/**	 *  A unit test for JUnit	 */	public void testAromaticSmiles() throws Exception {		String smiles = "c1ccccc1";		IMolecule molecule = sp.parseSmiles(smiles);		assertTrue(molecule.getAtom(0).getFlag(CDKConstants.ISAROMATIC));		assertTrue(molecule.getBond(0).getFlag(CDKConstants.ISAROMATIC));	}			/**	 * @cdk.bug 630475	 */	public void testSFBug630475() throws Exception {		String smiles = "CC1(C(=C(CC(C1)O)C)C=CC(=CC=CC(=CC=CC=C(C=CC=C(C=CC1=C(CC(CC1(C)C)O)C)C)C)C)C)C";		IMolecule mol = sp.parseSmiles(smiles);		assertTrue(mol.getAtomCount() > 0);	}	/**	 * @cdk.bug 585811	 */	public void testSFBug585811() throws Exception {		String smiles = "CC(C(C8CCC(CC8)=O)C3C4C(CC5(CCC(C9=CC(C=CN%10)=C%10C=C9)CCCC5)C4)C2CCC1CCC7(CCC7)C6(CC6)C1C2C3)=O";		IMolecule mol = sp.parseSmiles(smiles);		assertTrue(mol.getAtomCount() > 0);	}	/**	 * @cdk.bug 593648	 */	public void testSFBug593648() throws Exception {		String smiles = "CC1=CCC2CC1C(C)2C";		IMolecule mol = sp.parseSmiles(smiles);				IMolecule apinene = mol.getBuilder().newMolecule();		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 1		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 2		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 3		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 4		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 5		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 6		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 7		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 8		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 9		apinene.addAtom(mol.getBuilder().newAtom("C"));		// 10				apinene.addBond(0, 1, 2.0);		// 1		apinene.addBond(1, 2, 1.0);		// 2		apinene.addBond(2, 3, 1.0);		// 3		apinene.addBond(3, 4, 1.0);		// 4		apinene.addBond(4, 5, 1.0);		// 5		apinene.addBond(5, 0, 1.0);		// 6

⌨️ 快捷键说明

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