private IAtomContainer setInitialCharges ( IAtomContainer ac ) throws CDKException { Matcher matOC = null ; Matcher matOP = null ; Matcher matOS = null ; Matcher mat_p = null ; Matcher mat_n = null ; String hoseCode = "" ; for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { try { hoseCode = hcg . getHOSECode ( ac , ac . getAtom ( i ) , 3 ) ; } catch ( CDKException ex1 ) { throw new CDKException ( "Could not build HOSECode from atom " + i + " due to " + ex1 . toString ( ) , ex1 ) ; } hoseCode = removeAromaticityFlagsFromHoseCode ( hoseCode ) ; matOC = pOC . matcher ( hoseCode ) ; matOP = pOP . matcher ( hoseCode ) ; matOS = pOS . matcher ( hoseCode ) ; mat_p = p_p . matcher ( hoseCode ) ; mat_n = p_n . matcher ( hoseCode ) ; if ( matOC . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 0.500 ) ; } else if ( matOP . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 0.666 ) ; } else if ( matOS . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 0.500 ) ; } else if ( mat_p . matches ( ) ) { ac . getAtom ( i ) . setCharge ( + 1.000 ) ; } else if ( mat_n . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 1.000 ) ; } else { ac . getAtom ( i ) . setCharge ( new Double ( ac . getAtom ( i ) . getFormalCharge ( ) ) ) ; } } return ac ; }
Sets the initialCharges attribute of the AtomTypeCharges object .