@ Override public DescriptorValue calculate ( IAtomContainer container ) { int atomCount = 0 ; if ( container == null ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , getDescriptorNames ( ) , new CDKException ( "The supplied AtomContainer was NULL" ) ) ; } if ( container . getAtomCount ( ) == 0 ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , getDescriptorNames ( ) , new CDKException ( "The supplied AtomContainer did not have any atoms" ) ) ; } if ( elementName . equals ( "*" ) ) { for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { // we assume that UNSET is equivalent to 0 implicit H's Integer hcount = container . getAtom ( i ) . getImplicitHydrogenCount ( ) ; if ( hcount != CDKConstants . UNSET ) atomCount += hcount ; } atomCount += container . getAtomCount ( ) ; } else if ( elementName . equals ( "H" ) ) { for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { if ( container . getAtom ( i ) . getSymbol ( ) . equals ( elementName ) ) { atomCount += 1 ; } else { // we assume that UNSET is equivalent to 0 implicit H's Integer hcount = container . getAtom ( i ) . getImplicitHydrogenCount ( ) ; if ( hcount != CDKConstants . UNSET ) atomCount += hcount ; } } } else { for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { if ( container . getAtom ( i ) . getSymbol ( ) . equals ( elementName ) ) { atomCount += 1 ; } } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( atomCount ) , getDescriptorNames ( ) ) ; }
this could be useful for other descriptors like polar surface area ...