vibesketch.document.formats

Import and export: SMILES, MOL, SDF, RXN, CDXML, InChI, names, KET and XYZ.

Import turns a file into molecules (and a reaction, when the format carries one), writes them onto the canvas as KET and derives the document from it, so an imported structure is drawn exactly like a drawn one. An XYZ file, as vibe-view exports one, keeps its coordinates as each species’ 3D structure. Export reads the document: structures keep the coordinates they have on the canvas.

Formats a document cannot be expressed in are refused with the reason, never approximated: an RXN file needs a reaction, PNG of a reaction scheme needs a renderer this version does not have.

Module Attributes

EXPORT_FORMATS

the format of every file in the vibe family.

WHOLE_DOCUMENTS

Formats that carry a whole document, not just structures.

Functions

export(document, fmt, *[, style])

document in fmt; raises ExportRefused.

format_for_path(path)

The import format a file name implies; raises ImportFailed.

import_into(document, data, fmt, *[, mode])

Read data and draw it on document's canvas (a new document if None).

read_structures(data, fmt)

Read structures in fmt; raises ImportFailed.

species_mols(document)

An RDKit molecule per species: with canvas coordinates when drawn.

Classes

Imported(molecules, reaction, conditions, ket)

Payload(content, media_type, extension)

Exceptions

ExportRefused

The document cannot be expressed in the requested format.

ImportFailed

The data could not be read in the stated format.

vibesketch.document.formats.EXPORT_FORMATS: tuple[str, ...] = ('qvf', 'vsk', 'ket', 'mol', 'sdf', 'rxn', 'smiles', 'inchi', 'svg', 'png')

the format of every file in the vibe family.

Type:

QVF first

exception vibesketch.document.formats.ExportRefused

Bases: ValueError

The document cannot be expressed in the requested format.

exception vibesketch.document.formats.ImportFailed

Bases: ValueError

The data could not be read in the stated format.

class vibesketch.document.formats.Imported(molecules: 'list[Any]' = <factory>, reaction: 'tuple[list[Any], list[Any], list[Any]] | None' = None, conditions: 'list[str]' = <factory>, ket: 'dict[str, Any] | None' = None)

Bases: object

Parameters:
molecules: list[Any]
reaction: tuple[list[Any], list[Any], list[Any]] | None = None
conditions: list[str]
ket: dict[str, Any] | None = None

A whole canvas (KET or a .vsk’s), used as it is.

class vibesketch.document.formats.Payload(content: 'bytes', media_type: 'str', extension: 'str')

Bases: object

Parameters:
content: bytes
media_type: str
extension: str
vibesketch.document.formats.export(document, fmt, *, style=None)

document in fmt; raises ExportRefused.

Parameters:
Return type:

Payload

vibesketch.document.formats.format_for_path(path)

The import format a file name implies; raises ImportFailed.

Parameters:

path (str | Path)

Return type:

str

vibesketch.document.formats.import_into(document, data, fmt, *, mode='append')

Read data and draw it on document’s canvas (a new document if None).

Parameters:
Return type:

Derivation

vibesketch.document.formats.read_structures(data, fmt)

Read structures in fmt; raises ImportFailed.

Parameters:
Return type:

Imported

vibesketch.document.formats.species_mols(document)

An RDKit molecule per species: with canvas coordinates when drawn.

Parameters:

document (Document)

Return type:

dict[str, Any]