|
occ
|
Unified reader/writer for SHELX .res/.ins crystallographic files. More...
#include <shelxfile.h>
Public Member Functions | |
| ShelxFile ()=default | |
| Default constructor. | |
| std::optional< occ::crystal::Crystal > | read_crystal_from_file (const std::string &filename) |
| Read a crystal structure from a SHELX file. | |
| std::optional< occ::crystal::Crystal > | read_crystal_from_string (const std::string &contents) |
| Read a crystal structure from a SHELX-formatted string. | |
| bool | write_crystal_to_file (const occ::crystal::Crystal &crystal, const std::string &filename) |
| Write a crystal structure to a SHELX file. | |
| std::string | write_crystal_to_string (const occ::crystal::Crystal &crystal) |
| Write a crystal structure to a SHELX-formatted string. | |
| void | write_crystal_to_stream (const occ::crystal::Crystal &crystal, std::ostream &stream) |
| Write a crystal structure to an output stream. | |
| void | set_title (const std::string &title) |
| Set the title/comment for SHELX output. | |
| void | set_wavelength (double wavelength) |
| Set the X-ray wavelength for SHELX output. | |
| const std::string & | error_message () const |
| Get the last error message. | |
Static Public Member Functions | |
| static bool | is_likely_shelx_filename (const std::string &filename) |
| Check if a filename appears to be a SHELX file. | |
Unified reader/writer for SHELX .res/.ins crystallographic files.
The ShelxFile class provides functionality to read and write crystal structures in the SHELX format, which is widely used in crystallography.
SHELX files contain crystallographic data including:
The class handles both .res (result) and .ins (instruction) file extensions and provides round-trip compatibility for reading and writing structures.
|
default |
Default constructor.
Creates a ShelxFile instance with default settings:
|
inline |
Get the last error message.
Returns a description of the last parsing or writing error that occurred.
|
static |
Check if a filename appears to be a SHELX file.
Examines the file extension to determine if it's likely a SHELX file.
| filename | File path to check |
| std::optional< occ::crystal::Crystal > occ::io::ShelxFile::read_crystal_from_file | ( | const std::string & | filename | ) |
Read a crystal structure from a SHELX file.
Parses a SHELX .res or .ins file and constructs a Crystal object from the contained crystallographic data.
| filename | Path to the SHELX file to read |
| std::optional< occ::crystal::Crystal > occ::io::ShelxFile::read_crystal_from_string | ( | const std::string & | contents | ) |
Read a crystal structure from a SHELX-formatted string.
Parses SHELX format data directly from a string buffer.
| contents | String containing SHELX-formatted data |
|
inline |
Set the title/comment for SHELX output.
Sets the title that will be written to the TITL line in SHELX files.
| title | Title string (will be written after "TITL ") |
|
inline |
Set the X-ray wavelength for SHELX output.
Sets the wavelength that will be written to the CELL line. Common values: 1.54178 Å (Cu Kα), 0.71073 Å (Mo Kα)
| wavelength | Wavelength in Angstroms (default: 1.54178 Å) |
| bool occ::io::ShelxFile::write_crystal_to_file | ( | const occ::crystal::Crystal & | crystal, |
| const std::string & | filename | ||
| ) |
Write a crystal structure to a SHELX file.
Writes the crystal structure in SHELX format to the specified file. The output includes all necessary SHELX keywords and formatting.
| crystal | Crystal structure to write |
| filename | Path where the SHELX file should be written |
| void occ::io::ShelxFile::write_crystal_to_stream | ( | const occ::crystal::Crystal & | crystal, |
| std::ostream & | stream | ||
| ) |
Write a crystal structure to an output stream.
Writes the crystal structure in SHELX format to the provided stream.
| crystal | Crystal structure to write |
| stream | Output stream to write to |
| std::string occ::io::ShelxFile::write_crystal_to_string | ( | const occ::crystal::Crystal & | crystal | ) |
Write a crystal structure to a SHELX-formatted string.
Converts the crystal structure to SHELX format and returns as string.
| crystal | Crystal structure to convert |