예제 #1
0
        /// <summary> Read the Gaussian98 output.
        ///
        /// </summary>
        /// <returns> a ChemFile with the coordinates, energies, and
        /// vibrations.
        /// </returns>
        /// <throws>  IOException  if an I/O error occurs </throws>
        /// <throws>  CDKException Description of the Exception </throws>
        private IChemFile readChemFile(IChemFile chemFile)
        {
            IChemSequence sequence = chemFile.Builder.newChemSequence();
            IChemModel    model    = null;

            System.String line = input.ReadLine();
            System.String levelOfTheory;
            System.String description;
            int           modelCounter = 0;

            // Find first set of coordinates by skipping all before "Standard orientation"
            while (input.Peek() != -1 && (line != null))
            {
                if (line.IndexOf("Standard orientation:") >= 0)
                {
                    // Found a set of coordinates
                    model = chemFile.Builder.newChemModel();
                    readCoordinates(model);
                    break;
                }
                line = input.ReadLine();
            }
            if (model != null)
            {
                // Read all other data
                line = input.ReadLine().Trim();
                while (input.Peek() != -1 && (line != null))
                {
                    if (line.IndexOf("#") == 0)
                    {
                        // Found the route section
                        // Memorizing this for the description of the chemmodel
                        lastRoute    = line;
                        modelCounter = 0;
                    }
                    else if (line.IndexOf("Standard orientation:") >= 0)
                    {
                        // Found a set of coordinates
                        // Add current frame to file and create a new one.
                        if (!readOptimizedStructureOnly.Set)
                        {
                            sequence.addChemModel(model);
                        }
                        else
                        {
                            //logger.info("Skipping frame, because I was told to do");
                        }
                        fireFrameRead();
                        model = chemFile.Builder.newChemModel();
                        modelCounter++;
                        readCoordinates(model);
                    }
                    else if (line.IndexOf("SCF Done:") >= 0)
                    {
                        // Found an energy
                        model.setProperty(CDKConstants.REMARK, line.Trim());
                    }
                    else if (line.IndexOf("Harmonic frequencies") >= 0)
                    {
                        // Found a set of vibrations
                        // readFrequencies(frame);
                    }
                    else if (line.IndexOf("Total atomic charges") >= 0)
                    {
                        readPartialCharges(model);
                    }
                    else if (line.IndexOf("Magnetic shielding") >= 0)
                    {
                        // Found NMR data
                        readNMRData(model, line);
                    }
                    else if (line.IndexOf("GINC") >= 0)
                    {
                        // Found calculation level of theory
                        levelOfTheory = parseLevelOfTheory(line);
                        //logger.debug("Level of Theory for this model: " + levelOfTheory);
                        description = lastRoute + ", model no. " + modelCounter;
                        model.setProperty(CDKConstants.DESCRIPTION, description);
                    }
                    else
                    {
                        ////logger.debug("Skipping line: " + line);
                    }
                    line = input.ReadLine();
                }

                // Add last frame to file
                sequence.addChemModel(model);
                fireFrameRead();
            }
            chemFile.addChemSequence(sequence);

            return(chemFile);
        }
예제 #2
0
        private IChemSequence readChemSequence(IChemSequence sequence)
        {
            IChemModel model = null;

            try
            {
                System.String line = input.ReadLine();
                //String levelOfTheory = null;

                // Find first set of coordinates
                while (input.Peek() != -1 && (line != null))
                {
                    if (line.IndexOf("Standard orientation:") >= 0)
                    {
                        // Found a set of coordinates
                        model = sequence.Builder.newChemModel();
                        try
                        {
                            readCoordinates(model);
                        }
                        catch (System.IO.IOException exception)
                        {
                            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                            throw new CDKException("Error while reading coordinates: " + exception.ToString(), exception);
                        }
                        break;
                    }
                    line = input.ReadLine();
                }
                if (model != null)
                {
                    // Read all other data
                    line = input.ReadLine();
                    while (input.Peek() != -1 && (line != null))
                    {
                        if (line.IndexOf("Standard orientation:") >= 0)
                        {
                            // Found a set of coordinates
                            // Add current frame to file and create a new one.
                            sequence.addChemModel(model);
                            fireFrameRead();
                            model = sequence.Builder.newChemModel();
                            readCoordinates(model);
                        }
                        else if (line.IndexOf("SCF Done:") >= 0)
                        {
                            // Found an energy
                            model.setProperty("org.openscience.cdk.io.Gaussian03Reaer:SCF Done", line.Trim());
                        }
                        else if (line.IndexOf("Harmonic frequencies") >= 0)
                        {
                            // Found a set of vibrations
                            try
                            {
                                readFrequencies(model);
                            }
                            catch (System.IO.IOException exception)
                            {
                                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                throw new CDKException("Error while reading frequencies: " + exception.ToString(), exception);
                            }
                        }
                        else if (line.IndexOf("Mulliken atomic charges") >= 0)
                        {
                            readPartialCharges(model);
                        }
                        else if (line.IndexOf("Magnetic shielding") >= 0)
                        {
                            // Found NMR data
                            try
                            {
                                readNMRData(model, line);
                            }
                            catch (System.IO.IOException exception)
                            {
                                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                throw new CDKException("Error while reading NMR data: " + exception.ToString(), exception);
                            }
                        }
                        else if (line.IndexOf("GINC") >= 0)
                        {
                            // Found calculation level of theory
                            //levelOfTheory = parseLevelOfTheory(line);
                            // FIXME: is doing anything with it?
                        }
                        line = input.ReadLine();
                    }

                    // Add current frame to file
                    sequence.addChemModel(model);
                    fireFrameRead();
                }
            }
            catch (System.IO.IOException exception)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                throw new CDKException("Error while reading general structure: " + exception.ToString(), exception);
            }
            return(sequence);
        }