From: <eg...@us...> - 2007-11-23 13:14:29
|
Revision: 9482 http://cdk.svn.sourceforge.net/cdk/?rev=9482&view=rev Author: egonw Date: 2007-11-23 05:14:28 -0800 (Fri, 23 Nov 2007) Log Message: ----------- Further tuned/fixed N atom types Modified Paths: -------------- branches/egonw/ibondorder/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java Modified: branches/egonw/ibondorder/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java =================================================================== --- branches/egonw/ibondorder/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java 2007-11-23 13:13:51 UTC (rev 9481) +++ branches/egonw/ibondorder/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java 2007-11-23 13:14:28 UTC (rev 9482) @@ -238,24 +238,28 @@ return null; } - private boolean bothNeighborsAreSp2(IAtom atom, IAtomContainer atomContainer) { - boolean bothNeighborsSP2 = true; - Iterator<IAtom> atoms = atomContainer.getConnectedAtomsList(atom).iterator(); - while (atoms.hasNext() && bothNeighborsSP2) { + private boolean atLeastTwoNeighborsAreSp2(IAtom atom, IAtomContainer atomContainer) { + int count = 0; + Iterator<IAtom> atoms = atomContainer.getConnectedAtomsList(atom).iterator(); + while (atoms.hasNext() && (count < 2)) { IAtom nextAtom = atoms.next(); if (!nextAtom.getSymbol().equals("H")) { if (nextAtom.getHybridization() != CDKConstants.UNSET && nextAtom.getHybridization() == Hybridization.SP2) { // OK, it's SP2 + count++; } else if (countAttachedDoubleBonds(atomContainer, nextAtom) > 0) { // OK, it's SP2 - } else { - bothNeighborsSP2 = false; - } + count++; + } // OK, not SP2 } } - return bothNeighborsSP2; + return count >= 2; } + + private boolean bothNeighborsAreSp2(IAtom atom, IAtomContainer atomContainer) { + return atLeastTwoNeighborsAreSp2(atom, atomContainer); + } private IAtomType perceiveNitrogens(IAtomContainer atomContainer, IAtom atom) throws CDKException { @@ -315,10 +319,11 @@ } else { // OK, use bond order info IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { + boolean isRingAtom = isRingAtom(atom, atomContainer); int explicitHydrogens = countExplicitHydrogens(atom, atomContainer); int connectedHeavyAtoms = atomContainer.getConnectedBondsCount(atom) - explicitHydrogens; if (connectedHeavyAtoms == 2) { - if (isAmide(atom, atomContainer)) { + if (!isRingAtom && isAmide(atom, atomContainer)) { return getAtomType("N.amide"); } List<IBond> bonds = atomContainer.getConnectedBondsList(atom); @@ -327,12 +332,15 @@ return getAtomType("N.sp2"); } else { // a N.sp3 which is expected to take part in an aromatic system - if (isRingAtom(atom, atomContainer) && bothNeighborsAreSp2(atom, atomContainer)) { + if (isRingAtom && bothNeighborsAreSp2(atom, atomContainer)) { return getAtomType("N.planar3"); } return getAtomType("N.sp3"); } } else if (connectedHeavyAtoms == 3) { + if (isRingAtom && bothNeighborsAreSp2(atom, atomContainer)) { + return getAtomType("N.planar3"); + } return getAtomType("N.sp3"); } else if (connectedHeavyAtoms == 1) { if (isAmide(atom, atomContainer)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |