vibeview.api¶
High-level Python API for vibe-view — programmatic access to all QVF operations.
Import with from vibeview.api import * (__all__ lists the public
functions) or use individual functions.
All functions accept QVFReader instances or file paths. They are the
programmatic equivalents of the vibe-view CLI commands.
Functions
|
Render the structure to a PNG file. |
|
Render a volume section to a PNG file. |
|
Borrow an existing reader, or close a reader opened from a source. |
|
Compare two QVFs: return energy delta, section overlap, geometry RMSD. |
|
Return the structure as an XYZ string ( |
|
Return structure data as a dict with atoms, pbc, and lattice_vectors. |
|
Extract tabular data (same as |
|
Return a JSON-serializable summary of a volume section's grid. |
|
Check if a section exists in the QVF. |
|
Return full metadata for a QVF file as a dict. |
|
Render a section as terminal text and return it. |
|
Return a list of |
|
Extract sections without discarding metadata. |
|
Validate with qvf's reference validator (requires the |
- vibeview.api.capture_volume(source, section_id, path, **kwargs)[source]¶
Render a volume section to a PNG file.
- vibeview.api.closing_reader(source)[source]¶
Borrow an existing reader, or close a reader opened from a source.
Only readers created by this context are closed, on both normal return and exceptions. Caller-owned readers and binary streams remain open.
- vibeview.api.diff(source_a, source_b)[source]¶
Compare two QVFs: return energy delta, section overlap, geometry RMSD.
geo_rmsd_aisNonewhen the RMSD cannot be taken, andgeo_rmsd_skippedthen says why: a structure that cannot be read, a structure with no atoms, or atom counts that differ (#60). It isNonewhen the RMSD was taken.
- vibeview.api.export_xyz(source, section_id=None)[source]¶
Return the structure as an XYZ string (
section_idas inget_structure()).
- vibeview.api.get_structure(source, section_id=None)[source]¶
Return structure data as a dict with atoms, pbc, and lattice_vectors.
section_idnames a structure section; by default the shown one, the archive’s first structure (QVF spec § 4.1) for a fresh reader.
- vibeview.api.get_table(source, kind)[source]¶
Extract tabular data (same as
vibe-view table --kind).
- vibeview.api.get_volume(source, section_id)[source]¶
Return a JSON-serializable summary of a volume section’s grid.
Gives the grid geometry (
origin,voxel_vectors,shape) plus the value range (data_shape,data_min,data_max) – not the voxels themselves, so the result stays serializable. For thendarrayusevibeview.QVFReader.read_volume_data().The range is that of the field the viewer draws: the array goes through
vibeview.renderers.volume.stored_volume_field(), as in the browser and the terminal. A real array is summarised as stored. A complex one, which is not valid QVF v1, is reduced by the section’scomponentlabel first (#61).Returns
Noneif the section is absent or is not a volume.
- vibeview.api.info(source)[source]¶
Return full metadata for a QVF file as a dict.
Equivalent to
vibe-view info --json. A section’s genericlabelis included when it has one, and astructuresection carries its chemical identity (name,charge,multiplicity,smiles,inchi,inchikey; QVF spec § 5.1) as far as it states it.first_structureis the structure a viewer shows first and an export without a section takes (spec § 4.1), or None.
- vibeview.api.render_terminal(source, section_id=None, *, size=(100, 30), plain=False, **kwargs)[source]¶
Render a section as terminal text and return it.
The text counterpart of
capture_structure()/capture_volume(): same renderers, same colours, but the output is a string of braille characters instead of a PNG — and unlike the capture functions it needs no OpenGL context, so it works on a headless compute node.section_iddefaults to the structure section.plain=Truedrops the ANSI colour for logs and pipes. Extra keyword arguments are passed tovibeview.tui.show.render_section()(mode,representation,color_mode,replication,isovalue,rotation,show_labels,frame,chart,band_energy_unit).Returns a human-readable explanation rather than raising when the section has no graphical form (a citations block, say), so a caller sweeping every section never has to pre-filter by kind.
- vibeview.api.slice_qvf(source, output, *, keep=None, drop=None)[source]¶
Extract sections without discarding metadata. Refuse dangling references.
Viewer hints for removed sections are pruned. All other source fields and kept member bytes are preserved; the output is validated before replacement.
- vibeview.api.validate(source, *, limits=None)[source]¶
Validate with qvf’s reference validator (requires the
validationextra).Returns
valid,errors,warningsand structuredfindings(severity, code, where, message). Invalid archives includeerror; valid archives includen_sectionsandn_members. Hash/layout failures retain the member diagnostic fields when available. A viewer readability failure addsreader_errorseparately from qvf findings. An unreadable container or manifest raisesQVFOpenErrorwith the reference report retained in itsvalidation_reportattribute.limitssupplies overrides to qvf’sLimits.from_dict; unknown keys raise. The reference validator checks resource limits before reading payloads. Caller-owned streams and readers remain open and keep their stream position. An existing reader validates its original archive, without applying geometry edits. Missing validation support raisesQVFErrorrather than silently performing a partial check.