1 /* Copyright (C) 2001-2007 The Chemistry Development Kit (CDK) Project 2 * 3 * Contact: cdk-devel@lists.sourceforge.net 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public License 7 * as published by the Free Software Foundation; either version 2.1 8 * of the License, or (at your option) any later version. 9 * All we ask is that proper credit is given for our work, which includes 10 * - but is not limited to - adding the above copyright notice to the beginning 11 * of your source code files, and to any copyright notice that you may distribute 12 * with programs based on this work. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 * 23 */ 24 package org.openscience.cdk.aromaticity; 25 26 import org.openscience.cdk.CDKConstants; 27 import org.openscience.cdk.interfaces.IAtom; 28 import org.openscience.cdk.interfaces.IAtomContainer; 29 import org.openscience.cdk.interfaces.IBond; 30 import org.openscience.cdk.interfaces.IRing; 31 32 /** 33 * @cdk.module standard 34 * @cdk.githash 35 * 36 * @author Oliver Horlacher <oliver.horlacher@therastrat.com> 37 * @cdk.created 2002-03-14 38 * 39 * @cdk.keyword aromaticity detector 40 * @deprecated use {@link Aromaticity} 41 */ 42 @Deprecated 43 public class AromaticityCalculator { 44 45 /** 46 * Tests the <code>ring</code> in the <code>molecule</code> for aromaticity. Uses the 47 * Hückel rule (4n + 2) pie electrons. sp<sup>2</sup> hybridized C contibute 1 electron non 48 * sp<sup>2</sup> hybridized heteroatoms contribute 2 electrons (N and O should never be sp in 49 * or anything else in a ring and d electron elements get to complicated) 50 * sp<sup>2</sup> hybridized heteroatoms contribute 1 electron hybridization is worked out by 51 * counting the number of bonds with order 2. Therefore sp<sup>2</sup> hybridization is assumed 52 * if there is one bond of order 2. Otherwise sp<sup>3</sup> hybridization is assumed. 53 * 54 * @param ring the ring to test 55 * @param atomContainer the AtomContainer the ring is in 56 * @return true if the ring is aromatic false otherwise. 57 */ isAromatic(IRing ring, IAtomContainer atomContainer)58 public static boolean isAromatic(IRing ring, IAtomContainer atomContainer) { 59 60 java.util.Iterator<IAtom> ringAtoms = ring.atoms().iterator(); 61 int eCount = 0; 62 java.util.List<IBond> conectedBonds; 63 int numDoubleBond = 0; 64 boolean allConnectedBondsSingle; 65 66 while (ringAtoms.hasNext()) { 67 IAtom atom = ringAtoms.next(); 68 numDoubleBond = 0; 69 allConnectedBondsSingle = true; 70 conectedBonds = atomContainer.getConnectedBondsList(atom); 71 for (IBond conectedBond : conectedBonds) { 72 if (conectedBond.getOrder() == IBond.Order.DOUBLE && ring.contains(conectedBond)) { 73 numDoubleBond++; 74 } 75 76 // Count the Electron if bond order = 1.5 77 else if (conectedBond.getFlag(CDKConstants.ISAROMATIC) && ring.contains(conectedBond)) { 78 numDoubleBond = 1; 79 } 80 81 if (conectedBond.getOrder() != IBond.Order.SINGLE) { 82 allConnectedBondsSingle = false; 83 } 84 } 85 if (numDoubleBond == 1) { 86 //C or heteroatoms both contibute 1 electron in sp2 hybridized form 87 eCount++; 88 } else if (!atom.getSymbol().equals("C")) { 89 //Heteroatom probably in sp3 hybrid therefore 2 electrons contributed. 90 eCount = eCount + 2; 91 } else if (atom.getFlag(CDKConstants.ISAROMATIC)) { 92 eCount++; 93 } else if (allConnectedBondsSingle && atom.getSymbol().equals("C") && atom.getFormalCharge() == 1.0) { 94 // This is for tropylium and kinds. 95 // Dependence on hybridisation would be better: 96 // empty p-orbital is needed 97 continue; 98 } else { 99 return false; 100 } 101 } 102 return eCount - 2 != 0 && (eCount - 2) % 4 == 0; 103 } 104 } 105