@ Override public boolean isSaturated ( IAtom atom , IAtomContainer ac ) throws CDKException { IAtomType [ ] atomTypes = getAtomTypeFactory ( atom . getBuilder ( ) ) . getAtomTypes ( atom . getSymbol ( ) ) ; if ( atomTypes . length == 0 ) return true ; double bondOrderSum = ac . getBondOrderSum ( atom ) ; IBond . Order maxBondOrder = ac . getMaximumBondOrder ( atom ) ; Integer hcount = atom . getImplicitHydrogenCount ( ) == CDKConstants . UNSET ? 0 : atom . getImplicitHydrogenCount ( ) ; Integer charge = atom . getFormalCharge ( ) == CDKConstants . UNSET ? 0 : atom . getFormalCharge ( ) ; try { logger . debug ( "*** Checking saturation of atom " , atom . getSymbol ( ) , "" + ac . indexOf ( atom ) + " ***" ) ; logger . debug ( "bondOrderSum: " + bondOrderSum ) ; logger . debug ( "maxBondOrder: " + maxBondOrder ) ; logger . debug ( "hcount: " + hcount ) ; } catch ( Exception exc ) { logger . debug ( exc ) ; } for ( int f = 0 ; f < atomTypes . length ; f ++ ) { if ( bondOrderSum - charge + hcount == atomTypes [ f ] . getBondOrderSum ( ) && ! BondManipulator . isHigherOrder ( maxBondOrder , atomTypes [ f ] . getMaxBondOrder ( ) ) ) { logger . debug ( "*** Good ! ***" ) ; return true ; } } logger . debug ( "*** Bad ! ***" ) ; return false ; }
Checks whether an Atom is saturated by comparing it with known AtomTypes .