private void readCoordinates ( IChemModel model ) throws CDKException , IOException { IAtomContainer container = model . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; String line = input . readLine ( ) ; line = input . readLine ( ) ; line = input . readLine ( ) ; line = input . readLine ( ) ; while ( input . ready ( ) ) { line = input . readLine ( ) ; if ( ( line == null ) || ( line . indexOf ( "-----" ) >= 0 ) ) { break ; } int atomicNumber = 0 ; StringReader sr = new StringReader ( line ) ; StreamTokenizer token = new StreamTokenizer ( sr ) ; token . nextToken ( ) ; // ignore first token if ( token . nextToken ( ) == StreamTokenizer . TT_NUMBER ) { atomicNumber = ( int ) token . nval ; if ( atomicNumber == 0 ) { // Skip dummy atoms. Dummy atoms must be skipped // if frequencies are to be read because Gaussian // does not report dummy atoms in frequencies, and // the number of atoms is used for reading frequencies. continue ; } } else { throw new IOException ( "Error reading coordinates" ) ; } token . nextToken ( ) ; // ignore third token double x = 0.0 ; double y = 0.0 ; double z = 0.0 ; if ( token . nextToken ( ) == StreamTokenizer . TT_NUMBER ) { x = token . nval ; } else { throw new IOException ( "Error reading coordinates" ) ; } if ( token . nextToken ( ) == StreamTokenizer . TT_NUMBER ) { y = token . nval ; } else { throw new IOException ( "Error reading coordinates" ) ; } if ( token . nextToken ( ) == StreamTokenizer . TT_NUMBER ) { z = token . nval ; } else { throw new IOException ( "Error reading coordinates" ) ; } String symbol = "Du" ; symbol = PeriodicTable . getSymbol ( atomicNumber ) ; IAtom atom = model . getBuilder ( ) . newInstance ( IAtom . class , symbol ) ; atom . setPoint3d ( new Point3d ( x , y , z ) ) ; container . addAtom ( atom ) ; } IAtomContainerSet moleculeSet = model . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ; moleculeSet . addAtomContainer ( model . getBuilder ( ) . newInstance ( IAtomContainer . class , container ) ) ; model . setMoleculeSet ( moleculeSet ) ; }
Reads a set of coordinates into ChemModel .