public IChemModel ParseSubstance(XElement parser) { IChemModel model = builder.NewChemModel(); // assume the current element is PC-Compound if (!parser.Name.Equals(Name_EL_PCSUBSTANCE)) { return(null); } foreach (var elm in parser.Descendants(Name_EL_PCCOMPOUNDS)) { var set = ParseCompoundsBlock(elm); model.MoleculeSet = set; } foreach (var elm in parser.Descendants(Name_EL_PCSUBSTANCE_SID)) { string sid = GetSID(elm); model.SetProperty(CDKPropertyName.Title, sid); } return(model); }
/// <summary> /// Read the Gaussian98 output. /// </summary> /// <param name="chemFile"></param> /// <returns>a ChemFile with the coordinates, energies, and vibrations.</returns> private IChemFile ReadChemFile(IChemFile chemFile) { IChemSequence sequence = chemFile.Builder.NewChemSequence(); IChemModel model = null; string line = input.ReadLine(); string levelOfTheory; string description; int modelCounter = 0; // Find first set of coordinates by skipping all before "Standard orientation" while (line != null) { if (line.Contains("Standard orientation:")) { // 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 (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.Contains("Standard orientation:")) { // Found a set of coordinates // Add current frame to file and create a new one. if (!readOptimizedStructureOnly.IsSet) { sequence.Add(model); } else { Trace.TraceInformation("Skipping frame, because I was told to do"); } FrameRead(); model = chemFile.Builder.NewChemModel(); modelCounter++; ReadCoordinates(model); } else if (line.Contains("SCF Done:")) { // Found an energy model.SetProperty(CDKPropertyName.Remark, line.Trim()); } else if (line.Contains("Harmonic frequencies")) { // Found a set of vibrations // ReadFrequencies(frame); } else if (line.Contains("Total atomic charges")) { ReadPartialCharges(model); } else if (line.Contains("Magnetic shielding")) { // Found NMR data ReadNMRData(model, line); } else if (line.Contains("GINC")) { // Found calculation level of theory levelOfTheory = ParseLevelOfTheory(line); Debug.WriteLine($"Level of Theory for this model: {levelOfTheory}"); description = lastRoute + ", model no. " + modelCounter; model.SetProperty(CDKPropertyName.Description, description); } else { } line = input.ReadLine(); } // Add last frame to file sequence.Add(model); FrameRead(); } chemFile.Add(sequence); return(chemFile); }
private IChemSequence ReadChemSequence(IChemSequence sequence) { IChemModel model = null; try { string line = input.ReadLine(); // Find first set of coordinates while (line != null) { if (line.Contains("Standard orientation:")) { // Found a set of coordinates model = sequence.Builder.NewChemModel(); try { ReadCoordinates(model); } catch (IOException exception) { 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 (line != null) { if (line.Contains("Standard orientation:")) { // Found a set of coordinates // Add current frame to file and create a new one. sequence.Add(model); FrameRead(); model = sequence.Builder.NewChemModel(); ReadCoordinates(model); } else if (line.Contains("SCF Done:")) { // Found an energy model.SetProperty("NCDK.IO.Gaussian03Reaer:SCF Done", line.Trim()); } else if (line.Contains("Harmonic frequencies")) { // Found a set of vibrations } else if (line.Contains("Mulliken atomic charges")) { ReadPartialCharges(model); } else if (line.Contains("Magnetic shielding")) { // Found NMR data } else if (line.Contains("GINC")) { // Found calculation level of theory // FIXME: is doing anything with it? } line = input.ReadLine(); } // Add current frame to file sequence.Add(model); FrameRead(); } } catch (IOException exception) { throw new CDKException("Error while reading general structure: " + exception.ToString(), exception); } return(sequence); }