@ Override public DescriptorValue calculate ( IAtomContainer atomContainer ) { int hBondAcceptors = 0 ; IAtomContainer ac ; try { ac = ( IAtomContainer ) atomContainer . clone ( ) ; } catch ( CloneNotSupportedException e ) { return getDummyDescriptorValue ( e ) ; } // aromaticity is detected prior to descriptor calculation if the respective parameter is set to true if ( checkAromaticity ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( ac ) ; Aromaticity . cdkLegacy ( ) . apply ( ac ) ; } catch ( CDKException e ) { return getDummyDescriptorValue ( e ) ; } } //org.openscience.cdk.interfaces.IAtom[] atoms = ac.getAtoms(); // labelled for loop to allow for labelled continue statements within the loop atomloop : for ( IAtom atom : ac . atoms ( ) ) { // looking for suitable nitrogen atoms if ( atom . getSymbol ( ) . equals ( "N" ) && atom . getFormalCharge ( ) <= 0 ) { // excluding nitrogens that are adjacent to an oxygen List < IBond > bonds = ac . getConnectedBondsList ( atom ) ; int nPiBonds = 0 ; for ( IBond bond : bonds ) { if ( bond . getOther ( atom ) . getSymbol ( ) . equals ( "O" ) ) continue atomloop ; if ( IBond . Order . DOUBLE . equals ( bond . getOrder ( ) ) ) nPiBonds ++ ; } // if the nitrogen is aromatic and there are no pi bonds then it's // lone pair cannot accept any hydrogen bonds if ( atom . getFlag ( CDKConstants . ISAROMATIC ) && nPiBonds == 0 ) continue ; hBondAcceptors ++ ; } // looking for suitable oxygen atoms else if ( atom . getSymbol ( ) . equals ( "O" ) && atom . getFormalCharge ( ) <= 0 ) { //excluding oxygens that are adjacent to a nitrogen or to an aromatic carbon List < IBond > neighbours = ac . getConnectedBondsList ( atom ) ; for ( IBond bond : neighbours ) { IAtom neighbor = bond . getOther ( atom ) ; if ( neighbor . getSymbol ( ) . equals ( "N" ) || ( neighbor . getSymbol ( ) . equals ( "C" ) && neighbor . isAromatic ( ) && bond . getOrder ( ) != IBond . Order . DOUBLE ) ) continue atomloop ; ; } hBondAcceptors ++ ; } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( hBondAcceptors ) , getDescriptorNames ( ) ) ; }
Calculates the number of H bond acceptors .