Python interface reference¶
The Python interface is exposed in the chemfiles
module, and this page
list all the classes and methods in this module.
Error handling¶
Chemfiles uses exceptions for error handling, throwing
ChemfilesError
when an
error occurs.
-
exception
chemfiles.misc.
ChemfilesError
¶ Exception class for errors in chemfiles
-
exception
chemfiles.misc.
ChemfilesWarning
¶ Warnings from the Chemfiles runtime.
-
class
chemfiles.misc.
FormatMetadata
¶ FormatMetadata
contains metadata associated with one format. The following fields are directly accessible:- Parameters
name (str) – name of the format
extension (str) – extension associated with the format, or
None
if there is no extension associated with this formatdescription (str) – extended user-facing description of the format
reference (str) – extended user-facing description of the format
read (bool) – is reading files in this format implemented?
write (bool) – is writing files in this format implemented?
memory (bool) – does this format support in-memory IO?
positions (bool) – does this format support storing atomic positions?
velocities (bool) – does this format support storing atomic velocities?
unit_cell (bool) – does this format support storing unit cell information?
atoms (bool) – does this format support storing atom names or types?
bonds (bool) – does this format support storing bonds between atoms?
residues (bool) – does this format support storing residues?
-
chemfiles.misc.
add_configuration
(path)¶ Read configuration data from the file at
path
.By default, chemfiles reads configuration from any file name .chemfilesrc in the current directory or any parent directory. This function can be used to add data from another configuration file.
This function will fail if there is no file at
path
, or if the file is incorrectly formatted. Data from the new configuration file will overwrite any existing data.
-
chemfiles.misc.
formats_list
()¶ Get the list of formats known by chemfiles, as well as all associated metadata.
- Return type
list(FormatMetadata)
-
chemfiles.misc.
set_warnings_callback
(function)¶ Call function on every warning event. The callback should take a string message and return nothing.
By default, warnings are send to python warnings module.