Skip to content

Registry

multimolecule.io.registry.save

Python
save(
    record,
    path: str | Path,
    format: str | None = None,
    **kwargs
) -> Path

Save a structure file, dispatching by extension or explicit format.

Source code in multimolecule/io/registry.py
Python
def save(record, path: str | Path, format: str | None = None, **kwargs) -> Path:
    r"""Save a structure file, dispatching by extension or explicit format."""

    path = Path(path)
    format = _normalize_format(format, path)
    if format in DBN:
        return write_dbn(record, path)
    if format in BPSEQ:
        return write_bpseq(record, path)
    if format in FASTA:
        return write_fasta(record, path)
    if format in ST:
        return write_st(record, path, **kwargs)
    raise ValueError(f"Trying to save {path!r} with unsupported extension={format!r}")

multimolecule.io.registry.load

Python
load(path: str | Path, format: str | None = None)

Load a structure file, dispatching by extension or explicit format.

Source code in multimolecule/io/registry.py
Python
def load(path: str | Path, format: str | None = None):
    r"""Load a structure file, dispatching by extension or explicit format."""

    path = Path(path)
    format = _normalize_format(format, path)
    if format in DBN:
        return read_dbn(path)
    if format in BPSEQ:
        return read_bpseq(path)
    if format in FASTA:
        return read_fasta(path)
    if format in ST:
        return read_st(path)
    raise ValueError(f"Trying to load {path!r} with unsupported extension={format!r}")