Structure.to_file#

Structure.to_file(filename)[source]#

Writes the Structure instance to disk.

Parameters:
filenamestr

The name of the file to be created. Supported extensions are

.pdb

Creates a PDB file

.cif

Creates an mmCIF file

Raises:
ValueError

If the extension is not supported.

Examples

>>> from importlib_resources import files
>>> from tempfile import NamedTemporaryFile
>>> from tme import Structure
>>> fname = str(files("tests.data").joinpath("Structures/5khe.cif"))
>>> oname = NamedTemporaryFile().name
>>> structure = Structure.from_file(filename=fname)
>>> structure.to_file(f"{oname}.cif") # Writes an mmCIF file to disk
>>> structure.to_file(f"{oname}.pdb") # Writes a PDB file to disk