private void readPartialCharges ( IChemModel model ) throws CDKException , IOException { logger . info ( "Reading partial atomic charges" ) ; IAtomContainerSet moleculeSet = model . getMoleculeSet ( ) ; IAtomContainer molecule = moleculeSet . getAtomContainer ( 0 ) ; String line = input . readLine ( ) ; // skip first line after "Total atomic charges" while ( input . ready ( ) ) { line = input . readLine ( ) ; logger . debug ( "Read charge block line: " + line ) ; if ( ( line == null ) || ( line . indexOf ( "Sum of Mulliken charges" ) >= 0 ) ) { logger . debug ( "End of charge block found" ) ; break ; } StringReader sr = new StringReader ( line ) ; StreamTokenizer tokenizer = new StreamTokenizer ( sr ) ; if ( tokenizer . nextToken ( ) == StreamTokenizer . TT_NUMBER ) { int atomCounter = ( int ) tokenizer . nval ; tokenizer . nextToken ( ) ; // ignore the symbol double charge = 0.0 ; if ( tokenizer . nextToken ( ) == StreamTokenizer . TT_NUMBER ) { charge = ( double ) tokenizer . nval ; logger . debug ( "Found charge for atom " + atomCounter + ": " + charge ) ; } else { throw new CDKException ( "Error while reading charge: expected double." ) ; } IAtom atom = molecule . getAtom ( atomCounter - 1 ) ; atom . setCharge ( charge ) ; } } }
Reads partial atomic charges and add the to the given ChemModel .