📄 structurediagramgeneratortest.java
字号:
public void testDiamantane() throws Exception { Molecule m = MoleculeFactory.makeDiamantane(); IAtomContainer ac = generateCoordinates(m); assertTrue(GeometryTools.has2DCoordinates(ac)); } /** * A unit test for JUnit * *@exception Exception thrown if something goes wrong *@cdk.bug 1670871 */ public void xtestBug1670871() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IMolecule mol = sp.parseSmiles("CC(=O)OC1C=CC(SC23CC4CC(CC(C4)C2)C3)N(C1SC56CC7CC(CC(C7)C5)C6)C(C)=O"); IAtomContainer ac = generateCoordinates(mol); //MoleculeViewer2D.display(new Molecule(ac), false); assertTrue(GeometryTools.has2DCoordinates(ac)); } /** * A unit test for JUnit */ public void testEthylCyclohexane() throws Exception { Molecule m = MoleculeFactory.makeEthylCyclohexane(); IAtomContainer ac = generateCoordinates(m); assertTrue(GeometryTools.has2DCoordinates(ac)); } /** * A unit test for JUnit */ public void testBicycloRings() throws Exception { Molecule m = MoleculeFactory.makeBicycloRings(); IAtomContainer ac = generateCoordinates(m); assertTrue(GeometryTools.has2DCoordinates(ac)); } /** * A unit test for JUnit */ public IMolecule makeJhao3() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IMolecule mol = sp.parseSmiles("C=C1C2=CC13(CC23)"); return mol; } /** * A unit test for JUnit */ public IMolecule makeJhao4() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IMolecule mol = sp.parseSmiles("CCC3C1CC23(CC12)"); return mol; } /** * A unit test for JUnit */ public void testBenzene() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IMolecule mol = sp.parseSmiles("c1ccccc1"); IAtomContainer ac = generateCoordinates(mol); assertTrue(GeometryTools.has2DCoordinates(ac)); } /** * @cdk.bug 780545 */ public void testBug780545() throws Exception { Molecule mol = new Molecule(); mol.addAtom(new Atom("C")); IAtomContainer ac = generateCoordinates(mol); assertTrue(GeometryTools.has2DCoordinates(ac)); } /** * @cdk.bug 1598409 */ public void testBug1598409() throws Exception { String smiles = "c1(:c(:c2-C(-c3:c(-C(=O)-c:2:c(:c:1-[H])-[H]):c(:c(:c(:c:3-[H])-[H])-N(-[H])-[H])-[H])=O)-[H])-[H]"; SmilesParser parser = new SmilesParser(NoNotificationChemObjectBuilder.getInstance()); IMolecule cdkMol = parser.parseSmiles(smiles); HueckelAromaticityDetector.detectAromaticity(cdkMol, false); new StructureDiagramGenerator(cdkMol).generateCoordinates(); } /** * @cdk.bug 1572062 */ public void testBug1572062() throws Exception { String filename = "data/mdl/sdg_test.mol";// set up molecule reader InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); IChemObjectReader molReader = new MDLReader(ins);// read molecule IMolecule molecule = (IMolecule) molReader.read(new Molecule());// rebuild 2D coordinates StructureDiagramGenerator structureDiagramGenerator = new StructureDiagramGenerator(); for (int i = 0; i < 10; i++) { structureDiagramGenerator.setMolecule(molecule); structureDiagramGenerator.generateCoordinates(); } } /** * @cdk.bug 884993 */ public void testBug884993() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IMolecule mol = sp.parseSmiles("[N+](=O)([O-])C1=C(O)C(=CC(=C1)[N+](=O)[O-])[N+](=O)[O-].C23N(CCCC2)CCCC3"); try{ IAtomContainer ac = generateCoordinates(mol); assertTrue(GeometryTools.has2DCoordinates(ac)); fail("This should have thrown a 'Molecule not connected' exception."); } catch(Exception exc) { // OK, an exception should have been thrown if (!(exc.toString().indexOf("Molecule not connected")>= 0)) fail(); } } /** * @cdk.bug 1714794 */ public void xtestBug1714794() throws Exception { String problematicMol2AsSmiles = "N1c2c(c3c(c4c(c(c3O)C)OC(OC=CC(C(C(C(C(C(C(C(C=CC=C(C1=O)C)C)O)C)O)C)OC(=O)C)C)OC)(C4=O)C)c(c2C=NN(C12CC3CC(C1)CC(C2)C3)C)O)O"; SmilesParser parser = new SmilesParser(NoNotificationChemObjectBuilder.getInstance()); IMolecule cdkMol = parser.parseSmiles(problematicMol2AsSmiles); HueckelAromaticityDetector.detectAromaticity(cdkMol, false); new StructureDiagramGenerator(cdkMol).generateCoordinates(); assertTrue(GeometryTools.has2DCoordinates(cdkMol)); String problematicMol2 = "@<TRIPOS>MOLECULE\n" + "mol_197219.smi\n" + " 129 135 0 0 0\n" + "SMALL\n" + "GASTEIGER\n" + "Energy = 0\n" + "\n" + "@<TRIPOS>ATOM\n" + " 1 N1 0.0000 0.0000 0.0000 N.am 1 <1> -0.2782\n" + " 2 H1 0.0000 0.0000 0.0000 H 1 <1> 0.1552\n" + " 3 C1 0.0000 0.0000 0.0000 C.ar 1 <1> 0.0886\n" + " 4 C2 0.0000 0.0000 0.0000 C.ar 1 <1> 0.1500\n" + " 5 C3 0.0000 0.0000 0.0000 C.ar 1 <1> 0.0714\n" + " 6 C4 0.0000 0.0000 0.0000 C.ar 1 <1> 0.0456\n" + " 7 C5 0.0000 0.0000 0.0000 C.ar 1 <1> 0.0788\n" + " 8 C6 0.0000 0.0000 0.0000 C.ar 1 <1> 0.1435\n" + " 9 C7 0.0000 0.0000 0.0000 C.ar 1 <1> 0.0342\n" + " 10 C8 0.0000 0.0000 0.0000 C.ar 1 <1> 0.1346\n" + " 11 O1 0.0000 0.0000 0.0000 O.3 1 <1> -0.5057\n" + " 12 H2 0.0000 0.0000 0.0000 H 1 <1> 0.2922\n" + " 13 C9 0.0000 0.0000 0.0000 C.3 1 <1> -0.0327\n" + " 14 H3 0.0000 0.0000 0.0000 H 1 <1> 0.0280\n" + " 15 H4 0.0000 0.0000 0.0000 H 1 <1> 0.0280\n" + " 16 H5 0.0000 0.0000 0.0000 H 1 <1> 0.0280\n" + " 17 O2 0.0000 0.0000 0.0000 O.3 1 <1> -0.4436\n" + " 18 C10 0.0000 0.0000 0.0000 C.3 1 <1> 0.3143\n" + " 19 O3 0.0000 0.0000 0.0000 O.2 1 <1> -0.4528\n" + " 20 C11 0.0000 0.0000 0.0000 C.2 1 <1> 0.0882\n" + " 21 H6 0.0000 0.0000 0.0000 H 1 <1> 0.1022\n" + " 22 C12 0.0000 0.0000 0.0000 C.2 1 <1> -0.0208\n" + " 23 H7 0.0000 0.0000 0.0000 H 1 <1> 0.0628\n" + " 24 C13 0.0000 0.0000 0.0000 C.3 1 <1> 0.0854\n" + " 25 H8 0.0000 0.0000 0.0000 H 1 <1> 0.0645\n" + " 26 C14 0.0000 0.0000 0.0000 C.3 1 <1> 0.0236\n" + " 27 H9 0.0000 0.0000 0.0000 H 1 <1> 0.0362\n" + " 28 C15 0.0000 0.0000 0.0000 C.3 1 <1> 0.1131\n" + " 29 H10 0.0000 0.0000 0.0000 H 1 <1> 0.0741\n" + " 30 C16 0.0000 0.0000 0.0000 C.3 1 <1> 0.0200\n" + " 31 H11 0.0000 0.0000 0.0000 H 1 <1> 0.0359\n" + " 32 C17 0.0000 0.0000 0.0000 C.3 1 <1> 0.0661\n" + " 33 H12 0.0000 0.0000 0.0000 H 1 <1> 0.0600\n" + " 34 C18 0.0000 0.0000 0.0000 C.3 1 <1> 0.0091\n" + " 35 H13 0.0000 0.0000 0.0000 H 1 <1> 0.0348\n" + " 36 C19 0.0000 0.0000 0.0000 C.3 1 <1> 0.0661\n" + " 37 H14 0.0000 0.0000 0.0000 H 1 <1> 0.0602\n" + " 38 C20 0.0000 0.0000 0.0000 C.3 1 <1> 0.0009\n" + " 39 H15 0.0000 0.0000 0.0000 H 1 <1> 0.0365\n" + " 40 C21 0.0000 0.0000 0.0000 C.2 1 <1> -0.0787\n" + " 41 H16 0.0000 0.0000 0.0000 H 1 <1> 0.0576\n" + " 42 C22 0.0000 0.0000 0.0000 C.2 1 <1> -0.0649\n" + " 43 H17 0.0000 0.0000 0.0000 H 1 <1> 0.0615\n" + " 44 C23 0.0000 0.0000 0.0000 C.2 1 <1> -0.0542\n" + " 45 H18 0.0000 0.0000 0.0000 H 1 <1> 0.0622\n" + " 46 C24 0.0000 0.0000 0.0000 C.2 1 <1> 0.0115\n" + " 47 C25 0.0000 0.0000 0.0000 C.2 1 <1> 0.2441\n" + " 48 O4 0.0000 0.0000 0.0000 O.2 1 <1> -0.2702\n" + " 49 C26 0.0000 0.0000 0.0000 C.3 1 <1> -0.0348\n" + " 50 H19 0.0000 0.0000 0.0000 H 1 <1> 0.0279\n" + " 51 H20 0.0000 0.0000 0.0000 H 1 <1> 0.0279\n" + " 52 H21 0.0000 0.0000 0.0000 H 1 <1> 0.0279\n" + " 53 C27 0.0000 0.0000 0.0000 C.3 1 <1> -0.0566\n" + " 54 H22 0.0000 0.0000 0.0000 H 1 <1> 0.0236\n" + " 55 H23 0.0000 0.0000 0.0000 H 1 <1> 0.0236\n" + " 56 H24 0.0000 0.0000 0.0000 H 1 <1> 0.0236\n" + " 57 O5 0.0000 0.0000 0.0000 O.3 1 <1> -0.3909\n" + " 58 H25 0.0000 0.0000 0.0000 H 1 <1> 0.2098\n" + " 59 C28 0.0000 0.0000 0.0000 C.3 1 <1> -0.0577\n" + " 60 H26 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 61 H27 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 62 H28 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 63 O6 0.0000 0.0000 0.0000 O.3 1 <1> -0.3910\n" + " 64 H29 0.0000 0.0000 0.0000 H 1 <1> 0.2098\n" + " 65 C29 0.0000 0.0000 0.0000 C.3 1 <1> -0.0567\n" + " 66 H30 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 67 H31 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 68 H32 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 69 O7 0.0000 0.0000 0.0000 O.3 1 <1> -0.4608\n" + " 70 C30 0.0000 0.0000 0.0000 C.2 1 <1> 0.3042\n" + " 71 O8 0.0000 0.0000 0.0000 O.2 1 <1> -0.2512\n" + " 72 C31 0.0000 0.0000 0.0000 C.3 1 <1> 0.0332\n" + " 73 H33 0.0000 0.0000 0.0000 H 1 <1> 0.0342\n" + " 74 H34 0.0000 0.0000 0.0000 H 1 <1> 0.0342\n" + " 75 H35 0.0000 0.0000 0.0000 H 1 <1> 0.0342\n" + " 76 C32 0.0000 0.0000 0.0000 C.3 1 <1> -0.0564\n" + " 77 H36 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 78 H37 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 79 H38 0.0000 0.0000 0.0000 H 1 <1> 0.0234\n" + " 80 O9 0.0000 0.0000 0.0000 O.3 1 <1> -0.3753\n" + " 81 C33 0.0000 0.0000 0.0000 C.3 1 <1> 0.0372\n" + " 82 H39 0.0000 0.0000 0.0000 H 1 <1> 0.0524\n" + " 83 H40 0.0000 0.0000 0.0000 H 1 <1> 0.0524\n" + " 84 H41 0.0000 0.0000 0.0000 H 1 <1> 0.0524\n" + " 85 C34 0.0000 0.0000 0.0000 C.2 1 <1> 0.2505\n" + " 86 O10 0.0000 0.0000 0.0000 O.2 1 <1> -0.2836\n" + " 87 C35 0.0000 0.0000 0.0000 C.3 1 <1> 0.0210\n" + " 88 H42 0.0000 0.0000 0.0000 H 1 <1> 0.0309\n" + " 89 H43 0.0000 0.0000 0.0000 H 1 <1> 0.0309\n" + " 90 H44 0.0000 0.0000 0.0000 H 1 <1> 0.0309\n" + " 91 C36 0.0000 0.0000 0.0000 C.ar 1 <1> 0.1361\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -