@ Override public DescriptorValue calculate ( IAtomContainer ac ) { ac = clone ( ac ) ; // don't mod original int rotatableBondsCount = 0 ; int degree0 ; int degree1 ; IRingSet ringSet ; try { ringSet = new SpanningTree ( ac ) . getBasicRings ( ) ; } catch ( NoSuchAtomException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , getDescriptorNames ( ) , e ) ; } for ( IBond bond : ac . bonds ( ) ) { if ( ringSet . getRings ( bond ) . getAtomContainerCount ( ) > 0 ) { bond . setFlag ( CDKConstants . ISINRING , true ) ; } } for ( IBond bond : ac . bonds ( ) ) { IAtom atom0 = bond . getBegin ( ) ; IAtom atom1 = bond . getEnd ( ) ; if ( atom0 . getSymbol ( ) . equals ( "H" ) || atom1 . getSymbol ( ) . equals ( "H" ) ) continue ; if ( bond . getOrder ( ) == Order . SINGLE ) { if ( ( BondManipulator . isLowerOrder ( ac . getMaximumBondOrder ( atom0 ) , IBond . Order . TRIPLE ) ) && ( BondManipulator . isLowerOrder ( ac . getMaximumBondOrder ( atom1 ) , IBond . Order . TRIPLE ) ) ) { if ( ! bond . getFlag ( CDKConstants . ISINRING ) ) { if ( excludeAmides && ( isAmide ( atom0 , atom1 , ac ) || isAmide ( atom1 , atom0 , ac ) ) ) { continue ; } // if there are explicit H's we should ignore those bonds degree0 = ac . getConnectedBondsCount ( atom0 ) - getConnectedHCount ( ac , atom0 ) ; degree1 = ac . getConnectedBondsCount ( atom1 ) - getConnectedHCount ( ac , atom1 ) ; if ( ( degree0 == 1 ) || ( degree1 == 1 ) ) { if ( includeTerminals ) { rotatableBondsCount += 1 ; } } else { rotatableBondsCount += 1 ; } } } } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( rotatableBondsCount ) , getDescriptorNames ( ) ) ; }
The method calculates the number of rotatable bonds of an atom container . If the boolean parameter is set to true terminal bonds are included .