@ Override public boolean isSaturated ( IAtom atom , IAtomContainer container ) throws CDKException { if ( atom instanceof IPseudoAtom ) { logger . debug ( "don't figure it out... it simply does not lack H's" ) ; return true ; } IAtomType [ ] atomTypes = getAtomTypeFactory ( atom . getBuilder ( ) ) . getAtomTypes ( atom . getSymbol ( ) ) ; if ( atomTypes . length == 0 ) { logger . warn ( "Missing entry in atom type list for " , atom . getSymbol ( ) ) ; return true ; } double bondOrderSum = container . getBondOrderSum ( atom ) ; IBond . Order maxBondOrder = container . getMaximumBondOrder ( atom ) ; int hcount = atom . getImplicitHydrogenCount ( ) ; int charge = atom . getFormalCharge ( ) ; logger . debug ( "Checking saturation of atom " , atom . getSymbol ( ) ) ; logger . debug ( "bondOrderSum: " , bondOrderSum ) ; logger . debug ( "maxBondOrder: " , maxBondOrder ) ; logger . debug ( "hcount: " , hcount ) ; logger . debug ( "charge: " , charge ) ; boolean elementPlusChargeMatches = false ; for ( int f = 0 ; f < atomTypes . length ; f ++ ) { IAtomType type = atomTypes [ f ] ; if ( couldMatchAtomType ( atom , bondOrderSum , maxBondOrder , type ) ) { if ( bondOrderSum + hcount == type . getBondOrderSum ( ) && ! BondManipulator . isHigherOrder ( maxBondOrder , type . getMaxBondOrder ( ) ) ) { logger . debug ( "We have a match: " , type ) ; logger . debug ( "Atom is saturated: " , atom . getSymbol ( ) ) ; return true ; } else { // ok, the element and charge matche, but unfulfilled elementPlusChargeMatches = true ; } } // else: formal charges don't match } if ( elementPlusChargeMatches ) { logger . debug ( "No, atom is not saturated." ) ; return false ; } // ok, the found atom was not in the list logger . error ( "Could not find atom type!" ) ; throw new CDKException ( "The atom with element " + atom . getSymbol ( ) + " and charge " + charge + " is not found." ) ; }
Checks whether an Atom is saturated by comparing it with known AtomTypes . It returns true if the atom is an PseudoAtom and when the element is not in the list .