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

📄 structurediagramgeneratortest.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* $Revision: 8312 $ $Author: egonw $ $Date: 2007-05-08 11:48:15 +0000 (Di, 08 Mai 2007) $ * *  Copyright (C) 2003-2007  Christoph Steinbeck <steinbeck@users.sf.net> * *  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.layout;import java.io.InputStream;import java.io.StringReader;import java.util.List;import javax.vecmath.Vector2d;import junit.framework.Test;import junit.framework.TestSuite;import org.openscience.cdk.Atom;import org.openscience.cdk.ChemFile;import org.openscience.cdk.ChemObject;import org.openscience.cdk.DefaultChemObjectBuilder;import org.openscience.cdk.Molecule;import org.openscience.cdk.applications.swing.MoleculeListViewer;import org.openscience.cdk.applications.swing.MoleculeViewer2D;import org.openscience.cdk.aromaticity.HueckelAromaticityDetector;import org.openscience.cdk.geometry.GeometryTools;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.interfaces.IChemModel;import org.openscience.cdk.interfaces.IChemSequence;import org.openscience.cdk.interfaces.IMolecule;import org.openscience.cdk.io.CMLReader;import org.openscience.cdk.io.IChemObjectReader;import org.openscience.cdk.io.MDLReader;import org.openscience.cdk.io.MDLV2000Reader;import org.openscience.cdk.io.Mol2Reader;import org.openscience.cdk.layout.StructureDiagramGenerator;import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;import org.openscience.cdk.smiles.SmilesParser;import org.openscience.cdk.templates.MoleculeFactory;import org.openscience.cdk.test.CDKTestCase;import org.openscience.cdk.tools.manipulator.ChemModelManipulator;/** *  A set of test cases for the StructureDiagramGenerator * * @cdk.module test-extra * *@author     steinbeck *@cdk.created    August 29, 2003 */public class StructureDiagramGeneratorTest extends CDKTestCase{	MoleculeListViewer moleculeListViewer = null;	boolean standAlone = false;	/**	 *  Constructor for the StructureDiagramGeneratorTest object	 */	public StructureDiagramGeneratorTest(String name)	{		super(name);	}	/**	 *  The JUnit setup method	 */	public void setUp() 	{ 				}	/**	 *  A unit test suite for JUnit	 *	 *@return    The test suite	 */	public static Test suite()	{		return new TestSuite(StructureDiagramGeneratorTest.class);	}	public void runVisualTests() throws Exception	{		moleculeListViewer = new MoleculeListViewer();		//MoleculeViewer2D.display(MoleculeFactory.loadMolecule("data/mdl/reserpine.mol"), true);		/*showIt(MoleculeFactory.loadMolecule("data/mdl/reserpine.mol"), "Reserpine");		showIt(MoleculeFactory.loadMolecule("data/mdl/four-ring-5x10.mol"), "5x10 condensed four membered rings");		showIt(MoleculeFactory.loadMolecule("data/mdl/six-ring-4x4.mol"), "4x4 condensed six membered rings");		showIt(MoleculeFactory.loadMolecule("data/mdl/polycarpol.mol")		, "Polycarpol");*/		showIt(MoleculeFactory.makeAlphaPinene(), "alpha-Pinene");		showIt(MoleculeFactory.makeBiphenyl(), "Biphenyl");		showIt(MoleculeFactory.make4x3CondensedRings(), "4x3CondensedRings");		showIt(MoleculeFactory.makePhenylEthylBenzene(), "PhenylEthylBenzene");		showIt(MoleculeFactory.makeSpiroRings(), "Spiro");		showIt(MoleculeFactory.makeMethylDecaline(), "Methyldecaline");		showIt(MoleculeFactory.makeBranchedAliphatic(), "Branched aliphatic");		showIt(MoleculeFactory.makeDiamantane(), "Diamantane - Was A Problem! - Solved :-)");		showIt(MoleculeFactory.makeEthylCyclohexane(), "Ethylcyclohexane");		showIt(MoleculeFactory.makeBicycloRings(), "Bicyclo-[2.2.2]-octane");				//showIt(makeBug736137(), "Bug 736137");		//showIt(makeBug891021(), "Bug 891021");		showIt(makeJhao1(), "Bug jhao1");		showIt(makeJhao2(), "Bug jhao2");		showIt(makeJhao3(), "Bug jhao3");		showIt(makeJhao4(), "Bug jhao4");	}	private boolean showIt(IMolecule molecule, String name) throws Exception	{		MoleculeViewer2D mv = new MoleculeViewer2D();		mv.setAtomContainer(generateCoordinates(molecule));		moleculeListViewer.addStructure(mv, name);		return true;	}	public IAtomContainer generateCoordinates(IMolecule m) throws Exception	{		StructureDiagramGenerator sdg = new StructureDiagramGenerator();		sdg.setMolecule(m);		sdg.generateCoordinates(new Vector2d(0, 1));		return sdg.getMolecule();	}	/**	 * @cdk.bug 736137	 */	public void testBug736137() throws Exception	{		String filename = "data/mdl/bug736137.mol";		InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);		MDLV2000Reader reader = new MDLV2000Reader(ins);		ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile());		IChemSequence chemSequence = chemFile.getChemSequence(0);		IChemModel chemModel = chemSequence.getChemModel(0);		List atomContainers = ChemModelManipulator.getAllAtomContainers(chemModel);		assertEquals(1, atomContainers.size());	}	public void visualBugPMR() throws Exception	{                String filename = "data/SL0016a.cml";		InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);		CMLReader reader = new CMLReader(ins);		ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile());		IChemSequence seq = chemFile.getChemSequence(0);		IChemModel model = seq.getChemModel(0);		IMolecule mol = model.getMoleculeSet().getMolecule(0);		MoleculeViewer2D.display(mol, true);		//logger.debug(new SmilesGenerator().createSMILES(mol));	}				/**	 *  A unit test for JUnit	 */	public void testAlphaPinene() throws Exception	{		Molecule m = MoleculeFactory.makeAlphaPinene();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));	}	/**	 *  A unit test for JUnit	 */	public void testBiphenyl() throws Exception	{		Molecule m = MoleculeFactory.makeBiphenyl();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));	}	/**	 *  A unit test for JUnit	 */	public void test4x3CondensedRings() throws Exception	{		Molecule m = MoleculeFactory.make4x3CondensedRings();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));	}	/**	 *  A unit test for JUnit	 */	public void testPhenylEthylBenzene() throws Exception	{		Molecule m = MoleculeFactory.makePhenylEthylBenzene();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));	}	/**	 *  A unit test for JUnit	 */	public void testSpiroRings() throws Exception	{		Molecule m = MoleculeFactory.makeSpiroRings();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));		if (standAlone)MoleculeViewer2D.display(new Molecule(ac), false);	}	/**	 *  A unit test for JUnit	 */	public void testMethylDecaline() throws Exception	{		Molecule m = MoleculeFactory.makeMethylDecaline();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));	}	/**	 *  A unit test for JUnit	 */	public void testBranchedAliphatic() throws Exception	{		Molecule m = MoleculeFactory.makeBranchedAliphatic();		IAtomContainer ac = generateCoordinates(m);        assertTrue(GeometryTools.has2DCoordinates(ac));	}	/**	 *  A unit test for JUnit	 */

⌨️ 快捷键说明

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