public int calculateNumberOfImplicitHydrogens ( IAtom atom , double bondOrderSum , IBond . Order maxBondOrder , int neighbourCount ) throws CDKException { int missingHydrogens = 0 ; if ( atom instanceof IPseudoAtom ) { logger . debug ( "don't figure it out... it simply does not lack H's" ) ; return 0 ; } logger . debug ( "Calculating number of missing hydrogen atoms" ) ; // get default atom IAtomType [ ] atomTypes = getAtomTypeFactory ( atom . getBuilder ( ) ) . getAtomTypes ( atom . getSymbol ( ) ) ; if ( atomTypes . length == 0 ) { logger . warn ( "Element not found in configuration file: " , atom ) ; return 0 ; } logger . debug ( "Found atomtypes: " , atomTypes . length ) ; for ( int f = 0 ; f < atomTypes . length ; f ++ ) { IAtomType type = atomTypes [ f ] ; if ( couldMatchAtomType ( atom , bondOrderSum , maxBondOrder , type ) ) { logger . debug ( "This type matches: " , type ) ; int formalNeighbourCount = type . getFormalNeighbourCount ( ) ; if ( type . getHybridization ( ) == CDKConstants . UNSET ) { missingHydrogens = ( int ) ( type . getBondOrderSum ( ) - bondOrderSum ) ; } else if ( type . getHybridization ( ) == Hybridization . SP3 ) { missingHydrogens = formalNeighbourCount - neighbourCount ; } else if ( type . getHybridization ( ) == Hybridization . SP2 ) { missingHydrogens = formalNeighbourCount - neighbourCount ; } else if ( type . getHybridization ( ) == Hybridization . SP1 ) { missingHydrogens = formalNeighbourCount - neighbourCount ; } else { missingHydrogens = ( int ) ( type . getBondOrderSum ( ) - bondOrderSum ) ; } break ; } } logger . debug ( "missing hydrogens: " , missingHydrogens ) ; return missingHydrogens ; }
Calculates the number of hydrogens that can be added to the given atom to fullfil the atom s valency . It will return 0 for PseudoAtoms and for atoms for which it does not have an entry in the configuration file .