Class Scine::Utils::ChemicalFileHandler¶
-
class
ChemicalFileHandler
¶ Handles the reading and writing of chemical file formats.
Matches suffixes to chemical file formats and then dispatches the calls to appropriate streaming I/O handlers. Catches I/O errors.
Public Static Functions
-
static std::pair<AtomCollection, BondOrderCollection>
read
(const std::string &filename)¶ Reads an atom collection and tries to read a bond order collection from a file.
Supported file formats are currently:
mol
xyz
- Parameters
filename
: The path to the file to read
If
obabel
is found in your path, all formats that openbabel supports are also available.- Note
The format of a file is deduced from its suffix.
- Return
an AtomCollection and a BondOrderCollection read from the file. The BondOrderCollection may be empty if the file format does not include such information
- Exceptions
FileInaccessibleException
: if the file does not exist or cannot be openedFormatUnsupportedException
: if the file suffix cannot be matched to a supported file formatFormatMismatchException
: if the file’s format does not match the parser’s expectations (e.g. if the suffix does not match the format)NoBondInformationException
: if the format does not contain bond order information
-
static void
write
(const std::string &filename, const AtomCollection &atoms)¶ Writes an atom collection to a file.
Supported file formats are currently
xyz
mol
- Note
Overwrites existing files
- Parameters
filename
: The path to the file to writeatoms
: The atom collection to commit to a file
- Exceptions
FormatUnsupportedException
: if the file suffix cannot be matched to a supported file formatFileInaccessibleException
: if the file cannot be created
-
static void
write
(const std::string &filename, const AtomCollection &atoms, const BondOrderCollection &bondOrders)¶ Writes an atom collection and a bond order collection to a file.
Supported file formats are currently
mol
- Note
Overwrites existing files
- Parameters
filename
: The path to the file to writeatoms
: The atom collection to commit to a file
- Exceptions
FormatUnsupportedException
: if the file suffix cannot be matched to a supported file formatFileInaccessibleException
: if the file cannot be created
-
struct
FileInaccessibleException
: public exception¶ Exception thrown if the file does not exist or cannot be opened.
-
static std::pair<AtomCollection, BondOrderCollection>