示例#1
0
        /// <summary>
        /// Reads all the structures stored in all the files specified
        /// specified.
        /// </summary>
        /// <param name="fileNames">The paths to the files to be read.</param>
        /// <returns>An IEnumerable over the structures contained in the files</returns>
        public static IEnumerable<OBMol> ReadFiles(params string[] fileNames)
        {
            OBMol obMol;
                foreach (string fileName in fileNames)
                {
                    obMol = new OBMol();
                    //would be better to record the error and move on
                    //then make the class non-static and allow access to the
                    //errors
                    if (!File.Exists(fileName))
                        throw new FileNotFoundException("Could not find file : " + fileName);

                    converter.SetInFormat(OBConversion.FormatFromExt(fileName));
                    converter.ReadFile(obMol, fileName);
                    yield return obMol;

                    while (converter.Read(obMol))
                        yield return obMol;

            }
        }
示例#2
0
 public static bool WriteFile(OBMol mol, string fileName)
 {
     return WriteFile(mol, OBConversion.FormatFromExt(fileName).GetID(), fileName);
 }
示例#3
0
        public static bool WriteFile(OBMol mol, string format, string fileName)
        {
            writer.SetOutFormat(format);

            return writer.WriteFile(mol, fileName);
        }
示例#4
0
 public static string GetFileText(OBMol mol, string format)
 {
     return writer.WriteString(mol);
 }