pub fn guess_format(path: &str) -> String
Get the format that chemfiles would use to read a file at the given
The format is mostly guessed from the path extension, chemfiles only tries
to read the file to distinguish between CIF and mmCIF files. Opening the
file using the returned format string might still fail. For example, it will
fail if the file is not actually formatted according to the guessed format;
or the format/compression combination is not supported (e.g.
XTC / GZ will
not work since the XTC reader does not support compressed files).
The returned format is represented in a way compatible with the various
Trajectory constructors, i.e.
"<format name> [/ <compression>]", where
compression is optional.
let format = chemfiles::guess_format("trajectory.xyz.xz"); assert_eq!(format, "XYZ / XZ"); let format = chemfiles::guess_format("trajectory.nc"); assert_eq!(format, "Amber NetCDF");