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

📄 hueckelaromaticitydetectortest.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				true				};		Molecule molecule = MoleculeFactory.makeAzulene();		boolean isAromatic = false;		boolean result = false;		isAromatic = HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			result = (molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResult[f]);			assertTrue(result);			logger.debug("Result for atom " + f + " is correct?: " + result);		}		if (standAlone && isAromatic)		{			System.out.println("Azulene is aromatic");		}	}	/**	 *  A unit test for JUnit. The N has to be counted correctly	 */	public void testIndole() throws Exception	{		Molecule molecule = MoleculeFactory.makeIndole();		boolean testResults[] = {				true,				true,				true,				true,				true,				true,				true,				true,				true				};		//boolean isAromatic = false;		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}	/**	 *  A unit test for JUnit. The N has to be counted correctly	 */	public void testPyrrole() throws Exception	{		Molecule molecule = MoleculeFactory.makePyrrole();		boolean testResults[] = {				true,				true,				true,				true,				true				};		//boolean isAromatic = false;		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}	/**	 *  A unit test for JUnit	 */	public void testThiazole() throws Exception	{		Molecule molecule = MoleculeFactory.makeThiazole();		boolean[] testResults = {true, true, true, true, true};		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}	/**	 *  A unit test for JUnit	 */	public void testTetraDehydroDecaline() throws Exception	{		boolean isAromatic = false;		//boolean testResults[] = {true, false, false};		SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());		IMolecule mol = sp.parseSmiles("C1CCCc2c1cccc2");		IRingSet rs = (new AllRingsFinder()).findAllRings(mol);		//logger.debug("rs.size(): " + rs.size());		HueckelAromaticityDetector.detectAromaticity(mol, rs, true);		IRing r = null;		int i = 0, aromacount = 0;		java.util.Iterator rings = rs.atomContainers();		while (rings.hasNext()) {			r = (IRing)rings.next();			isAromatic = r.getFlag(CDKConstants.ISAROMATIC);			if (standAlone && isAromatic)			{				System.out.println("Ring " + i + " in test molecule is aromatic.");			} else if (standAlone && !isAromatic)			{				System.out.println("Ring " + i + " in test molecule is not aromatic.");			}			if (isAromatic) aromacount++;			i++;		}		assertEquals(aromacount, 1);	}    /**     * This is a bug reported for JCP.     */    public void testSFBug956924() throws Exception {    	SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());    	IMolecule mol = sp.parseSmiles("[cH+]1cccccc1"); // tropylium cation    	assertTrue(HueckelAromaticityDetector.detectAromaticity(mol));    	assertEquals(7, mol.getAtomCount());    	for (int f = 0; f < mol.getAtomCount(); f++) {    		assertTrue(mol.getAtom(f).getFlag(CDKConstants.ISAROMATIC));    	}	}    /**     * This is a bug reported for JCP.     */    public void testSFBug956923() throws Exception {		boolean testResults[] = {false, false, false, false, false, false, false, false};		SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());		IMolecule mol = sp.parseSmiles("O=c1cccccc1"); // tropone		assertFalse(HueckelAromaticityDetector.detectAromaticity(mol));		assertEquals(testResults.length, mol.getAtomCount());		for (int f = 0; f < mol.getAtomCount(); f++) {			assertTrue(mol.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}	/**	 *  A unit test for JUnit	 */	public void testPorphyrine() throws Exception	{		IMolecule molecule = null;		boolean isAromatic = false;		boolean testResults[] = {				false,				false,				false,				false,				false,				true,				true,				true,				true,				true,				false,				true,				true,				true,				false,				true,				true,				false,				false,				true,				true,				false,				false,				false,				true,				true,				false,				false,				false,				true,				true,				false,				false,				false,				false,				true,				true,				true,				true,				false,				false,				false				};		String filename = "data/mdl/porphyrin.mol";		InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);		MDLReader reader = new MDLReader(ins);		molecule = (Molecule) reader.read((ChemObject) new Molecule());		isAromatic = HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertEquals(testResults[f], molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC));		}		assertTrue(isAromatic);	}	/**	 *  A unit test for JUnit	 */	public void testBug698152() throws Exception	{		Molecule molecule = null;		//boolean isAromatic = false;		boolean[] testResults = {true,				true,				true,				true,				true,				true,				false,				false,				false,				false,				false,				false,				false,				false,				false,				false,				false,				false};		String filename = "data/mdl/bug698152.mol";		InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);		MDLReader reader = new MDLReader(ins);		molecule = (Molecule) reader.read((ChemObject) new Molecule());		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}	/**	 *  A test for the fix of bug #716259, where a quinone ring 	 *  was falsely detected as aromatic	 */	public void testBug716259() throws Exception	{		Molecule molecule = null;		//boolean isAromatic = false;		boolean[] testResults = {			true,			true,			true,			true,			true,			true,			true,			true,			true,			true,			false,			false,			false,			false,			false,			false,			false,			false,			false		};		String filename = "data/mdl/bug716259.mol";		InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);		MDLReader reader = new MDLReader(ins);		molecule = (Molecule) reader.read((ChemObject) new Molecule());		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}			/**	 *  A unit test for JUnit	 */	public void testQuinone() throws Exception	{		Molecule molecule = MoleculeFactory.makeQuinone();		//boolean isAromatic = false;		boolean[] testResults = {false, false, false, false, false, false, false, false};		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}    public void testBug1328739() throws Exception {      String filename = "data/mdl/bug1328739.mol";      InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);      MDLReader reader = new MDLReader(ins);      Molecule molecule = (Molecule) reader.read(new Molecule());      HueckelAromaticityDetector.detectAromaticity(molecule);      assertEquals(15, molecule.getBondCount());      assertTrue(molecule.getBond(0).getFlag(CDKConstants.ISAROMATIC));      assertTrue(molecule.getBond(1).getFlag(CDKConstants.ISAROMATIC));      assertTrue(molecule.getBond(2).getFlag(CDKConstants.ISAROMATIC));      assertTrue(molecule.getBond(3).getFlag(CDKConstants.ISAROMATIC));      assertTrue(molecule.getBond(4).getFlag(CDKConstants.ISAROMATIC));      assertTrue(molecule.getBond(6).getFlag(CDKConstants.ISAROMATIC));  }	/**	 *  A unit test for JUnit	 */	public void testBenzene() throws Exception	{		Molecule molecule = MoleculeFactory.makeBenzene();		//boolean isAromatic = false;		boolean[] testResults = {true,true,true,true,true,true};		HueckelAromaticityDetector.detectAromaticity(molecule);		for (int f = 0; f < molecule.getAtomCount(); f++)		{			assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC) == testResults[f]);		}	}	private IMolecule makeAromaticMolecule()	{		  IMolecule mol = new Molecule();		  IAtom a1 = mol.getBuilder().newAtom("C");		  a1.setPoint2d(new Point2d(329.99999999999994, 971.0));  mol.addAtom(a1);		  IAtom a2 = mol.getBuilder().newAtom("C");		  a2.setPoint2d(new Point2d(298.8230854637602, 989.0));  mol.addAtom(a2);		  IAtom a3 = mol.getBuilder().newAtom("C");		  a3.setPoint2d(new Point2d(298.8230854637602, 1025.0));  mol.addAtom(a3);		  IAtom a4 = mol.getBuilder().newAtom("C");		  a4.setPoint2d(new Point2d(330.0, 1043.0));  mol.addAtom(a4);		  IAtom a5 = mol.getBuilder().newAtom("C");		  a5.setPoint2d(new Point2d(361.1769145362398, 1025.0));  mol.addAtom(a5);		  IAtom a6 = mol.getBuilder().newAtom("C");		  a6.setPoint2d(new Point2d(361.1769145362398, 989.0));  mol.addAtom(a6);		  IAtom a7 = mol.getBuilder().newAtom("C");		  a7.setPoint2d(new Point2d(392.3538290724796, 971.0));  mol.addAtom(a7);		  IAtom a8 = mol.getBuilder().newAtom("C");		  a8.setPoint2d(new Point2d(423.5307436087194, 989.0));  mol.addAtom(a8);		  IAtom a9 = mol.getBuilder().newAtom("C");		  a9.setPoint2d(new Point2d(423.5307436087194, 1025.0));  mol.addAtom(a9);		  IAtom a10 = mol.getBuilder().newAtom("C");		  a10.setPoint2d(new Point2d(392.3538290724796, 1043.0));  mol.addAtom(a10);		  IBond b1 = mol.getBuilder().newBond(a1, a2, 2.0);		  mol.addBond(b1);		  IBond b2 = mol.getBuilder().newBond(a2, a3, 1.0);		  mol.addBond(b2);		  IBond b3 = mol.getBuilder().newBond(a3, a4, 2.0);		  mol.addBond(b3);		  IBond b4 = mol.getBuilder().newBond(a4, a5, 1.0);		  mol.addBond(b4);		  IBond b5 = mol.getBuilder().newBond(a5, a6, 2.0);		  mol.addBond(b5);		  IBond b6 = mol.getBuilder().newBond(a6, a1, 1.0);		  mol.addBond(b6);		  IBond b7 = mol.getBuilder().newBond(a6, a7, 1.0);		  mol.addBond(b7);		  IBond b8 = mol.getBuilder().newBond(a7, a8, 1.0);		  mol.addBond(b8);		  IBond b9 = mol.getBuilder().newBond(a8, a9, 1.0);		  mol.addBond(b9);		  IBond b10 = mol.getBuilder().newBond(a9, a10, 1.0);		  mol.addBond(b10);		  IBond b11 = mol.getBuilder().newBond(a10, a5, 1.0);		  mol.addBond(b11);		  return mol;	}	}

⌨️ 快捷键说明

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