vibeview.qvf¶
QVF reader — the core file-open lifecycle.
Responsibilities: - Open .qvf zip archive, extract + validate manifest.json - Parse sections into pydantic models - Verify sha256 of every binary member before use (Rule 4) - Lazy extraction of volumetric .dat blobs
Module Attributes
the int64 maximum. |
|
Section-id prefix of wavefunction overlays computed by re-localization ( |
|
The identity fields a |
|
The arrows of a reaction step (QVF spec § 5.14); absent means forward. |
|
Raster types a |
|
The |
|
a filesystem path, raw zip bytes, or a seekable binary file-like object (BytesIO, an opened file, etc.). |
Functions
|
Force the replication count to 1 on every non-periodic axis. |
|
|
Classes
|
One atom. |
|
|
|
|
|
One contracted shell of the GTO basis (§ 1.5). |
|
Bond-order analysis section. |
|
BibTeX bibliography embedded in the QVF. |
|
COOP/COHP bonding analysis section (dos.coop or dos.cohp). |
|
A |
|
EPR section payload. |
|
|
|
A |
|
Geometry of a scalar field on a regular grid. |
|
job.spec section payload — the declarative specification of the calculation the archive requests (spec § 5.9). |
|
|
|
One member of a section (a file inside the zip). |
|
NMR section payload. |
|
|
|
|
|
One verified |
|
QTAIM topological analysis section. |
|
Read a .qvf archive and provide lazy access to sections. |
|
One species of a reaction step: a |
|
Self-contained reaction path (reaction.path). |
|
A |
|
One step of a |
|
One reaction-path waypoint annotation. |
|
Waypoint annotations layered on a referenced trajectory. |
|
run.record section payload — the self-contained record of one program invocation (verbatim input + full log, spec § 5.8). |
|
Per-iteration SCF trail. |
|
2D relaxed-scan energy surface (scan.surface). |
|
One section from the manifest. |
|
|
|
|
|
A unit cell, or a molecule when |
|
Which chemical species a |
|
spglib-style symmetry analysis embedded in the QVF. |
|
|
|
The excited state a set of natural transition orbitals describes (spec § 5.3). |
|
|
|
Viewer defaults from manifest.json. |
|
wavefunction.gto payload. |
Exceptions
A section (or root extension) flagged |
|
manifest.json failed JSON Schema validation. |
|
Base for all QVF reader errors. |
|
|
Cannot open/read the file; validation may attach its reference report. |
sha256 of a member does not match the manifest. |
|
Requested section id not found in manifest. |
- class vibeview.qvf.Source(*, program, version, calculation)[source]¶
Bases:
BaseModel- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class vibeview.qvf.MemberSpec(*, path, format, sha256, dtype=None, shape=None, media_type=None)[source]¶
Bases:
BaseModelOne member of a section (a file inside the zip).
- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class vibeview.qvf.Section(*, id, kind, members=<factory>, component=None, trajectory_ref=None, **extra_data)[source]¶
Bases:
BaseModelOne section from the manifest.
- Parameters:
- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- members: dict[str, MemberSpec]¶
- class vibeview.qvf.ViewerDefaults(*, auto_open=<factory>, **extra_data)[source]¶
Bases:
BaseModelViewer defaults from manifest.json.
Known fields (auto_open) are explicit. All other keys are per-section hints (e.g.
"density": {"isovalue": 0.05, ...}) and are captured via Pydantic’s extra=”allow” inmodel_extra.- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class vibeview.qvf.Manifest(*, qvf_version, source, sections, viewer_defaults=None, **extra_data)[source]¶
Bases:
BaseModel- Parameters:
- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- viewer_defaults: ViewerDefaults | None¶
- exception vibeview.qvf.QVFOpenError(message, *, validation_report=None)[source]¶
Bases:
QVFErrorCannot open/read the file; validation may attach its reference report.
- vibeview.qvf.MAX_ATOMIC_NUMBER = 9223372036854775807¶
the int64 maximum. Numbers beyond the element table are kept on purpose (a converter labels
Atom(999)“Z999”, and frame metadata keeps unknown display labels); the bond search stores atomic numbers as int64.- Type:
Largest
atomic_numberthe reader accepts
- exception vibeview.qvf.ManifestValidationError[source]¶
Bases:
QVFErrormanifest.json failed JSON Schema validation.
- exception vibeview.qvf.SHA256MismatchError[source]¶
Bases:
QVFErrorsha256 of a member does not match the manifest. Hard error for that section.
- exception vibeview.qvf.SectionNotFoundError[source]¶
Bases:
QVFErrorRequested section id not found in manifest.
- exception vibeview.qvf.CriticalSectionUnsupportedError[source]¶
Bases:
QVFErrorA section (or root extension) flagged
critical: truehas a kind the viewer cannot render. Per the QVF spec (§2.2 / §5.5 / §7) the consumer MUST refuse to open such a file rather than silently render a partial, misleading view.
- class vibeview.qvf.Atom(symbol, position, atomic_number, atom_name=None, residue_name=None, residue_seq=None, chain_id=None, b_factor=None)[source]¶
Bases:
objectOne atom. The biomolecular fields are optional and default to None.
Chemistry files (XYZ, a computed structure) carry none of them; a PDB carries all five, and the cartoon/ribbon work (roadmap workstream D) is built on them —
atom_nameidentifies the backbone trace,chain_id+residue_seqorder it,residue_namecolours it,b_factorcarries the temperature factor (or, for a predicted structure, the per-residue confidence a predictor writes into that column). Optional rather than required so every existing archive, and every non-biomolecular producer, keeps working untouched.- Parameters:
- vibeview.qvf.RELOCALIZED_PREFIX = 'wf_relocalized_'¶
Section-id prefix of wavefunction overlays computed by re-localization (
vibeview.relocalize); a geometry edit invalidates every one of them.
- vibeview.qvf.clamp_replication(replication, pbc)[source]¶
Force the replication count to 1 on every non-periodic axis.
Replicating along a non-periodic axis would tile the structure along a synthesized, non-physical lattice column — for a 2D slab that fabricates a stack of sheets that the calculation never contained.
- class vibeview.qvf.StructureData(atoms, pbc, lattice_vectors, bonds, dim=-1, supplied_residues=None, supplied_chains=None, supplied_secondary_structure=None)[source]¶
Bases:
objectA unit cell, or a molecule when
pbcis all-False.For
dim < 3the lattice rowsdim..2are non-physical: the producer synthesizes them so AO integrals and spglib always see a full-rank 3x3 matrix, and the SCF energy is provably invariant to their length. They are NOT cell edges and must never be drawn, replicated along, or used as a geometric extent.pbcis the only signal that separates a synthesized column from a real lattice vector — a synthesized 30-bohr normal and a real 30-bohr vacuum gap are numerically identical inlattice_vectors.- Parameters:
- property has_residues: bool¶
True when this structure carries biomolecular identity.
Either carrier counts: per-atom residue numbers, or a producer-supplied
residueslist on the section object. A producer may legitimately supply the second without the first.
- chain_ids()[source]¶
Chain ids, in presentation order.
The producer-supplied
chainslist when the archive has one (it may order chains for presentation, and may name a chain that contributes no residue), otherwise the chainschains()derived.
- chains()[source]¶
{chain_id: [(residue_seq, [atom indices]), ...]}.A producer-supplied
residueslist wins over the derivation below (spec § 5.1 precedence). Everything after this paragraph describes that derivation, which is what runs for a PDB import and for every archive whose producer supplied nothing.Residues appear in the order the file lists them, which for a PDB is the order along the chain — the ribbon must follow the actual connectivity, and sorting by residue number would silently reorder insertion codes or non-monotonic numbering. Atoms with no residue identity are skipped rather than lumped into a fake chain; a file with none simply yields
{}.Grouping is by contiguous run of (chain, sequence, name), not by a global key. PDB residue numbers are only four columns wide and wrap at 9999, so a solvated system reuses them: keying globally merged a lipid and a water that happened to share number 1001 into one 80-atom “residue” (measured: 1,256 such collisions on a 150k-atom membrane protein, 9,999 buckets where the file holds 12,010 residues). Contiguity is also what makes insertion codes behave, since those too are listed in order.
- ca_residues(chain_id=None)[source]¶
(chain, residue_seq, CA atom index)for each CA-bearing residue.The single ordering used by
backbone_trace()and by the supplied-assignment branch ofsecondary_structure(), so the two cannot drift apart: a per-CA label list that did not line up with the trace it is zipped against would mislabel a whole chain.Public because renderers need it. Anything building a per-CA array to zip against
backbone_trace()— a selection mask, a colour array — must walk this exact ordering rather than re-deriving it, since a second copy of the walk can drift. It was private until 2026-07-26, which forced the cartoon renderer to reach in throughgetattrand carry a duplicated fallback.
- backbone_trace(chain_id=None)[source]¶
Alpha-carbon coordinates, in chain order — the ribbon spine.
[N, 3]; empty when the structure has no CA atoms. Passchain_idfor a single chain, or leave it None to concatenate every chain (callers drawing one ribbon per chain should ask per chain, so the spline does not jump between them).
- secondary_structure(chain_id=None, *, detailed=False)[source]¶
Per-alpha-carbon secondary structure, aligned with
backbone_trace().One character per CA:
"H"helix,"E"extended strand,"C"coil. The list is always the same length as the trace for the samechain_id, so a renderer can zip the two.With
detailed=True, supplied subtype annotations additionally returnG(3-10 helix),I(pi helix) andB(beta bridge). Geometric assignment always returns the coarse H/E/C labels.A producer-supplied
secondary_structurerange list wins, per chain, over the geometric assignment described below (spec § 5.1 precedence). That is not a preference for tidiness: the CA-only assignment below genuinely cannot tell an alpha- from a pi- from a 3-10 helix, or a beta-bridge from a sheet, and a producer can.Assignment is from the CA trace alone. Real DSSP (Kabsch & Sander, Biopolymers 22, 2577 (1983)) reads backbone N/CA/C/O and assigns from hydrogen-bond energies; a QVF is not guaranteed to carry O at all, and vibe-view needs this only to decide ribbon geometry. CA-only assignment is an established family of approximations to it, the reference implementation being P-SEA (Labesse, Colloc’h, Pothier & Mornon, Comput. Appl. Biosci. 13, 291 (1997)), which discriminates on CA(i)-CA(i+k) distances plus the virtual CA angle and dihedral. This uses those same descriptors.
The numeric windows below are this implementation’s, chosen to bracket ideal geometry rather than transcribed from the paper.
tests/test_secondary_structure.pyconstructs an ideal right-handed alpha-helix (1.5 A rise, 100 deg/residue, CA on a 2.3 A radius) and an ideal extended strand (3.34 A rise) and measures, under this module’s dihedral sign convention:helix d2 5.43 d3 5.05 d4 6.20 tau 90.4 alpha 50.0 strand d2 6.68 d3 10.20 d4 13.36 tau 120.7 alpha 180.0
A left-handed helix measures alpha -50.0, so the dihedral sign is what keeps one from being read as the other.
Assignment is per chain even when
chain_idis None: running the window across a chain boundary would invent structure out of two unrelated termini that happen to be adjacent in the file.
- class vibeview.qvf.GridData(origin, voxel_vectors, shape, units='bohr')[source]¶
Bases:
objectGeometry of a scalar field on a regular grid.
A stored QVF volume keeps
originandvoxel_vectorsin bohr (design § 1.3a), the default. Fields the viewer samples itself, such as an orbital evaluated from the GTO wavefunction, are laid out in Å alongside the atoms and say so withunits="angstrom". Anything that places a grid in the Å scene scales byto_angstrominstead of assuming one convention.- Parameters:
- class vibeview.qvf.BandsData(kpath: 'dict[str, Any]', eigenvalues: 'np.ndarray', fermi: 'float | None')[source]¶
Bases:
object
- class vibeview.qvf.PhononBandsData(qpath: 'dict[str, Any]', frequencies: 'np.ndarray')[source]¶
Bases:
object
- class vibeview.qvf.PhononDOSData(frequencies: 'np.ndarray', dos: 'np.ndarray', meta: 'dict[str, Any]')[source]¶
Bases:
object
- class vibeview.qvf.EquationOfStateData(volumes: 'np.ndarray', energies: 'np.ndarray', fit: 'dict[str, Any]')[source]¶
Bases:
object
- class vibeview.qvf.SpectraData(frequencies: 'np.ndarray', intensities: 'np.ndarray', labels: 'list[str] | None' = None)[source]¶
Bases:
object
- class vibeview.qvf.TrajectoryData(atoms: 'list[Atom]', coords: 'np.ndarray', energies: 'list[float] | None')[source]¶
Bases:
object
- class vibeview.qvf.VibrationsData(atoms: 'list[Atom]', frequencies: 'np.ndarray', displacements: 'np.ndarray')[source]¶
Bases:
object
- class vibeview.qvf.AtomPropertiesData(mulliken_charges: 'np.ndarray | None', loewdin_charges: 'np.ndarray | None', spin_populations: 'np.ndarray | None' = None, hirshfeld_charges: 'np.ndarray | None' = None, iao_charges: 'np.ndarray | None' = None)[source]¶
Bases:
object- Parameters:
- class vibeview.qvf.CitationsData(bibtex)[source]¶
Bases:
objectBibTeX bibliography embedded in the QVF.
The writer stores references.bib as a binary member (utf-8 bytes + sha256). We decode here so renderers see a string.
- Parameters:
bibtex (str)
- class vibeview.qvf.RunRecordData(program, program_version, command, exit_status, started_utc, finished_utc, sequence, input_text, input_size, log_text, log_size, files, attachment_roles)[source]¶
Bases:
objectrun.record section payload — the self-contained record of one program invocation (verbatim input + full log, spec § 5.8).
input_text/log_textare decoded UTF-8 (None when the member is absent);input_size/log_sizeare the uncompressed byte counts from the ZIP central directory so a renderer can size-gate what it pushes to the DOM.filesis the optional filename index;attachment_roleslists attachment members present (their bytes are not read here).- Parameters:
- class vibeview.qvf.JobSpecData(job_type, method, basis, functional, charge, multiplicity, kpoints, tasks, options, raw)[source]¶
Bases:
objectjob.spec section payload — the declarative specification of the calculation the archive requests (spec § 5.9).
rawkeeps the full JobSpecPayload (open for forward growth); the typed fields mirror its portable top level.- Parameters:
- vibeview.qvf.STRUCTURE_IDENTITY_FIELDS: tuple[str, ...] = ('name', 'charge', 'multiplicity', 'smiles', 'inchi', 'inchikey')¶
The identity fields a
structuresection object may carry (QVF spec § 5.1, “Chemical identity”), besides the genericlabel.
- class vibeview.qvf.StructureIdentity(label=None, name=None, charge=None, multiplicity=None, smiles=None, inchi=None, inchikey=None)[source]¶
Bases:
objectWhich chemical species a
structuresection holds (QVF spec § 5.1).Read from the section object, never from a member. Every field is optional, and an absent one states nothing: a structure without
chargeis not declared neutral.labelis the generic section label, the short compound label a scheme shows (“1”, “3a”);nameis the chemical name. A value of the wrong type reads as absent.- Parameters:
- vibeview.qvf.REACTION_ARROWS: tuple[str, ...] = ('forward', 'equilibrium', 'retrosynthetic', 'resonance')¶
The arrows of a reaction step (QVF spec § 5.14); absent means forward.
- class vibeview.qvf.ReactionParticipant(structure_ref, coefficient=1.0)[source]¶
Bases:
objectOne species of a reaction step: a
structuresection and its coefficient.
- class vibeview.qvf.ReactionStep(id, reactants, products, reagents=<factory>, label=None, arrow='forward', conditions=<factory>, yield_percent=None, yield_text=None)[source]¶
Bases:
objectOne step of a
reaction.scheme(QVF spec § 5.14).Roles are chemical:
reactantsare consumed andproductsformed in the step’s forward direction whatever thearrow.- Parameters:
id (str)
reactants (list[ReactionParticipant])
products (list[ReactionParticipant])
reagents (list[ReactionParticipant])
label (str | None)
arrow (str)
yield_percent (float | None)
yield_text (str | None)
- reactants: list[ReactionParticipant]¶
- products: list[ReactionParticipant]¶
- reagents: list[ReactionParticipant]¶
- class vibeview.qvf.ReactionSchemeData(steps)[source]¶
Bases:
objectA
reaction.schemepayload: its steps in reading order.- Parameters:
steps (list[ReactionStep])
- steps: list[ReactionStep]¶
- vibeview.qvf.PREVIEW_RASTER_TYPES: frozenset[str] = frozenset({'image/jpeg', 'image/png'})¶
Raster types a
previewthumbnail may have (QVF spec § 5.15).
- class vibeview.qvf.PreviewImage(role, media_type, data)[source]¶
Bases:
objectOne verified
previewmember: its declared type and its bytes.
- class vibeview.qvf.NMRData(raw)[source]¶
Bases:
objectNMR section payload.
Writer (qvf.py::_write_spectra_nmr_section) pass-through of a dict with conventional keys: chemical_shifts, shielding_tensors, j_couplings, isotope, reference, solvent. Shape of each field is not schema-enforced, so we keep the raw dict and let the renderer decide what to surface.
- class vibeview.qvf.EPRData(raw)[source]¶
Bases:
objectEPR section payload.
Writer (qvf.py::_write_spectra_epr_section) pass-through of a dict with conventional keys: g_tensor, hyperfine, zero_field_splitting. Shape of each field is not schema-enforced, so we keep the raw dict and let the renderer decide what to surface.
- class vibeview.qvf.SymmetryData(raw)[source]¶
Bases:
objectspglib-style symmetry analysis embedded in the QVF.
Writer (qvf.py::_write_symmetry_section) passes through whatever dict the producer hands it (space group number, symbol, point group, Hall symbol, …). Keys are conventional, not enforced by schema. The renderer surfaces every key it finds.
- class vibeview.qvf.SCFHistoryData(iterations)[source]¶
Bases:
objectPer-iteration SCF trail.
Writer (qvf.py::_write_scf_history_section) stores a JSON document {“iterations”: [{“iter”, “energy_eh”, “delta_e”, “diis_error”}, …]}. Field set is conventional, not enforced by schema — keep them as plain dicts so the renderer can degrade gracefully when a key is missing (e.g. non-DIIS solvers have no diis_error).
- class vibeview.qvf.BondOrdersData(method, pairs)[source]¶
Bases:
objectBond-order analysis section.
- class vibeview.qvf.QTAIMData(points, bond_paths)[source]¶
Bases:
objectQTAIM topological analysis section.
- class vibeview.qvf.DOSData(energies, values, channels, projected)[source]¶
Bases:
objectA
dos.totalordos.projectedsection (spec § 4.8 / § 4.9).valuesis the DOS[n_pts]or[2, n_pts](spin axis leading) for a total DOS, and the per-channel projections[n_ch, n_pts]for a projected one, with a spin axis already summed away.channelsis the section’s channel list, empty for a total DOS.
- class vibeview.qvf.FermiSurfaceData(energies, mesh)[source]¶
Bases:
objectA
fermi_surfacesection: the energy mesh and its metadata.
- class vibeview.qvf.DOSCOOPData(energies, projections, integrated, meta)[source]¶
Bases:
objectCOOP/COHP bonding analysis section (dos.coop or dos.cohp).
- class vibeview.qvf.BasisShell(center, l, exponents, coefficients, pure=True)[source]¶
Bases:
objectOne contracted shell of the GTO basis (§ 1.5).
- class vibeview.qvf.TransitionOrbitals(role=None, state_index=None, excitation_energy_ev=None, states_ref=None)[source]¶
Bases:
objectThe excited state a set of natural transition orbitals describes (spec § 5.3).
Read from the canonical carriers first:
state_indexand theexcitation_energyof that state in theexcited_statessectionstate_refnames. Archives written before those existed carry the deprecatedexcitation_indexandexcitation_energy_evinstead, which are read when the canonical carrier is absent, so both show the same state. Each field is None when the archive does not say.- Parameters:
- class vibeview.qvf.WavefunctionGTOData(structure_ref, pure, n_ao, shells, spin, orbital_kind, energies, occupations, symmetry_labels, alpha_energies, alpha_occupations, beta_energies, beta_occupations, mo_coefficients, mo_coefficients_alpha, mo_coefficients_beta, symmetry_labels_beta=None, atom_populations=None, centroids_bohr=None, n_centres=None, localization_method=None, occupation_semantics=None, k_point=None, relocalization=None, density_unavailable_reason=None, transition_orbitals=None)[source]¶
Bases:
objectwavefunction.gto payload.
For restricted: mo_coefficients is set, mo_coefficients_alpha and mo_coefficients_beta are None.
For unrestricted: the per-spin variants are set, and mo_coefficients is None.
Each coefficient matrix is row-major [n_mo, n_ao].
- Parameters:
structure_ref (str)
pure (bool)
n_ao (int)
shells (list[BasisShell])
spin (str)
orbital_kind (str)
energies (ndarray | None)
occupations (ndarray | None)
alpha_energies (ndarray | None)
alpha_occupations (ndarray | None)
beta_energies (ndarray | None)
beta_occupations (ndarray | None)
mo_coefficients (ndarray | None)
mo_coefficients_alpha (ndarray | None)
mo_coefficients_beta (ndarray | None)
atom_populations (ndarray | None)
centroids_bohr (ndarray | None)
n_centres (ndarray | None)
localization_method (str | None)
occupation_semantics (str | None)
k_point (ndarray | None)
density_unavailable_reason (str | None)
transition_orbitals (TransitionOrbitals | None)
- shells: list[BasisShell]¶
- transition_orbitals: TransitionOrbitals | None = None¶
- class vibeview.qvf.ReactionWaypoint(frame_index, label, kind, energy_eh=None)[source]¶
Bases:
objectOne reaction-path waypoint annotation.
- class vibeview.qvf.ReactionPathData(atoms, coords, energies, reaction_coordinate, waypoints, lattice=None, dim=None, dim_per_frame=None, reaction_coordinate_label=None, reaction_coordinate_unit=None, frame_volumes=None, volume_grid=None, volume_frame_index=None, volume_label=None, volume_isovalue=None)[source]¶
Bases:
objectSelf-contained reaction path (reaction.path).
Binary layout matches trajectory: coords[n_frames, n_atoms, 3] in Å.
Periodic reaction paths additionally carry the per-frame lattice + dimensionality so the renderer can draw the cell and wrap atoms across periodic boundaries. A path is periodic when it has the
latticemember, never because of the manifest’sqvf_version(QVF spec § 3.1):latticeis None for molecular paths. Otherwise a float64 array of shape (3, 3) when every frame shares the same lattice (the fixed-cell common case) or (n_frames, 3, 3) for variable- cell paths. Columns are a, b, c, in bohr — matchingvibeqc.PeriodicSystem.lattice. The renderer is responsible for the bohr→Å conversion (coords are already Å).dimis None for molecular paths. Otherwise an int in {1, 2, 3};dim_per_frameis set instead when frames carry different dimensionalities.
- Parameters:
- waypoints: list[ReactionWaypoint]¶
- class vibeview.qvf.ReactionWaypointsData(trajectory_ref, waypoints, reaction_coordinate)[source]¶
Bases:
objectWaypoint annotations layered on a referenced trajectory.
- Parameters:
trajectory_ref (str)
waypoints (list[ReactionWaypoint])
- waypoints: list[ReactionWaypoint]¶
- class vibeview.qvf.ScanSurfaceData(axis_a, axis_b, energies, coordinate_a_label=None, coordinate_a_unit=None, coordinate_b_label=None, coordinate_b_unit=None, atoms=None, geometries=None)[source]¶
Bases:
object2D relaxed-scan energy surface (scan.surface).
energiesis[nA, nB](Hartree);axis_a/axis_bare the 1D driven-coordinate values. Optionalgeometriesis the relaxed structure at each node, flattened[nA*nB, n_atoms, 3]in Å (row-major over(a, b));atomscarries the element symbols.- Parameters:
- vibeview.qvf.scf_energy_eh(provenance)[source]¶
provenance["scf_energy"]as a float in hartree, or None.Producers write the energy either as a bare number or as
{"value": E, "unit": "hartree"}; every surface that prints or compares energies reads it through here.
- vibeview.qvf.MANIFEST_SCHEMA_URI: str = 'https://vibe-qc.org/spec/qvf/1/manifest.schema.json'¶
The
$idof the vendored v1 schema, theschema_uriof a v1 manifest.
- vibeview.qvf.QVFSource¶
a filesystem path, raw zip bytes, or a seekable binary file-like object (BytesIO, an opened file, etc.).
Used by vibe-qc to hand a freshly built QVF over to the viewer without touching disk.
- Type:
Anything QVFReader can open
alias of
str|Path|bytes|bytearray|memoryview|IO[bytes]
- class vibeview.qvf.QVFReader(source)[source]¶
Bases:
objectRead a .qvf archive and provide lazy access to sections.
The archive can come from any of:
a filesystem path (
str/pathlib.Pathending in.qvf)raw zip bytes (
bytes/bytearray/memoryview) — vibe-qc can build a QVF in memory viaqvf_bytes(...)and pass them ina seekable binary file-like object (
BytesIO, opened binary file, …)
The zip handle is kept open for the lifetime of the reader so lazy binary blobs can be read on demand.
close()(or use as a context manager) releases it; if the reader owns an in-memory buffer that is released too.- Parameters:
source (QVFSource)
- property viewer_defaults: ViewerDefaults | None¶
- scf_energy_eh()[source]¶
The provenance’s SCF energy in hartree, or None when it records none.
- Return type:
float | None
- property dipole_moment: dict[str, Any]¶
The manifest’s root
dipole_momentblock ({} when absent).Root, not ``provenance`` – QVF spec § 4.7 puts it there and the schema declares it as a root property. Reading it off
provenancesilently yieldsNonefor every file ever written, which is what left the dipole arrow and the dipole readout dead.Keys:
total_debye,vector_debye(3),origin(3).
- property thermochemistry: dict[str, Any]¶
The manifest’s root
thermochemistryblock ({} when absent).Root, for the same reason as
dipole_moment. Producer keys (python/vibeqc/runner.py) arezpve_eh,enthalpy_eh,entropy_cal_mol_k,gibbs_free_energy_eh,temperature_kandpressure_atm.Note the entropy is cal/mol/K, not Eh/K – the one field here whose unit is not atomic.
- property run_status: str | None¶
The archive’s place in a calculation lifecycle (spec § 3.2):
"pending"for a job container that has not yet run,"running"while the job is in flight (live checkpoint), then"converged"or"failed". None when not stated (an ordinary results archive).
- property checkpoint_info: dict[str, Any]¶
seq(monotonic),wall_time_s,written_at, optionallyscf_iteration/energy_ehon mid-SCF snapshots.- Type:
provenance.checkpoint({} when absent)
- run_record_sections()[source]¶
All
run.recordsections in run-history order.Ordered by their
sequencefield (spec § 5.8; a record without one sorts before sequenced records, keeping manifest order among themselves). The last entry is the latest run — the one whose results the archive’s other sections describe.
- run_record_position(section_id)[source]¶
(1-based position, total) of a run.record in run history.
Position
totalis the latest run.(0, 0)when the section is not a run.record of this archive.
- validation_report(*, limits=None)[source]¶
Validate the open archive with qvf; preserve its handle and edit overlay.
- manifest_warnings()[source]¶
Non-fatal findings about the manifest, made when the archive opened.
Each warning starts with its QVF warning code. The one there is today is
W_VERSION_WITHDRAWN: the manifest declares the withdrawnqvf_version2, which vibe-view reads and checks as version 1 (spec § 3.1). The archive is valid; the warning records that its producer wrote a version producers must not write. Empty for an archive with nothing to report.
- lifecycle_warnings()[source]¶
Container-lifecycle consistency warnings (spec § 3.2, § 5.9).
“Done” means a terminal
run_status(converged/failed) plus a complete latestrun.record— one that carries both itsinputandlogmembers (an empty log is complete: a run that failed before output began legitimately logged zero bytes). Returns human-readable warnings, empty when the archive is consistent. Non-terminal and unstated statuses never warn.
- section_is_partial(section_id)[source]¶
True when the producer marked this section
partial— still growing in a live checkpoint (e.g. an optimization trajectory).
- property first_structure_id: str | None¶
The archive’s first structure (QVF spec § 4.1), or None without one.
The first
structuresection thatviewer_defaults.auto_openlists, else the first section of kindstructureinsectionsorder.
- property shown_structure_id: str | None¶
The structure shown and used where none is named, or None without one.
The first structure until
show_structure()picks another.read_structure()without an id reads it, and every consumer that shows or exports “the structure” goes through that.
- property shown_structure: Section | None¶
The section of
shown_structure_id, or None.
- show_structure(section_id)[source]¶
Make
section_idthe shown structure; None returns to the first one.Raises
SectionNotFoundErrorfor an unknown id andQVFErrorfor a section of another kind, leaving the choice unchanged. An edit made on a structure stays with it (seeset_edit_overlay()). Changing the choice bumpsgeometry_revision, sinceread_structure()now returns other atoms.- Parameters:
section_id (str | None)
- Return type:
None
- structure_ref_of(section_id)[source]¶
The structure a section describes (QVF spec § 4.1), or None.
A structure describes itself. Any other section describes the structure its
structure_refnames; one without a usable reference makes no statement, and the reader keeps its usual behaviour of relating it to the first structure.
- structure_identity(section_id=None)[source]¶
The chemical identity a
structuresection object states (spec § 5.1).section_iddefaults to the shown structure. Without a structure, or for fields of the wrong type, the identity states nothing.- Parameters:
section_id (str | None)
- Return type:
- declared_charge_multiplicity(section_id=None)[source]¶
The charge and multiplicity the archive states for a structure.
Each from the structure’s identity (spec § 5.1,
section_iddefaulting to the shown structure), else fromprovenance(§ 3.2) when the archive has at most one structure section: with several, the provenance describes none of them in particular. A missing, non-integer or (for multiplicity) non-positive value is None.
- section_error(section_id)[source]¶
Return the first recorded member error for this section, or None.
- read_member_bytes(path)[source]¶
The raw bytes of zip entry
path, unverified.Every failure to read the entry is a
QVFErrornaming it: a missing entry, a CRC or deflate error, an encrypted entry or an unsupported compression method. OnlyBadZipFilewas mapped before, so the rest reached the CLI as tracebacks (#39-35).
- manifest_json()[source]¶
A fresh copy of manifest.json as parsed JSON, unknown fields included.
The reader parsed it once while opening, so this does not read the archive again (and cannot fail on it).
- stored_size(member)[source]¶
Uncompressed size in bytes of
memberin the archive, or None if absent.- Parameters:
member (MemberSpec)
- Return type:
int | None
- cached_bytes()[source]¶
Bytes of decoded binary members this reader holds, per section id.
The binary cache is where a volume’s or trajectory’s arrays live once read, so this is the figure a memory readout wants (#35-12); the wrapper objects around it are a few dozen bytes.
- drop_cached(section_id)[source]¶
Release the cached arrays of one section; return the bytes released.
The next read decodes the member from the archive again. Arrays a caller still references stay alive until the caller lets go.
- set_edit_overlay(positions, symbols, *, lattice_vectors=None, section_id=None)[source]¶
Record viewer-side edited geometry (see
_edit_overlays).positionsis an (n, 3) sequence in angstroms,symbolsthe matching element symbols. RaisesValueError, leaving the current overlay untouched, for a wrong shape, a non-finite coordinate, a symbol outside the element table, or an archive without the structure. Subsequentread_structure()calls for that structure return this geometry (with explicit bonds dropped — atom indices from the file no longer apply) instead of the archive’s.The edit belongs to
section_id, by default the shown structure, and stays with it while another structure is shown.lattice_vectorsreplaces the current edit-overlay lattice when supplied. Omitting it preserves the current lattice, which lets ordinary atom edits made after a supercell build keep that expanded cell. The lattice is reset together with the atoms byclear_edit_overlay().
- clear_edit_overlay(section_id=None)[source]¶
Drop viewer-side edits; read_structure() returns the file again.
section_iddrops only that structure’s edit; by default every structure’s edit is dropped.- Parameters:
section_id (str | None)
- Return type:
None
- property edited_structure_ids: list[str]¶
The structure sections that carry viewer-side edits, in edit order.
- set_wavefunction_overlay(section_id, wavefunction)[source]¶
Register a viewer-computed wavefunction under
section_id.The id also gets a synthetic
Sectionso the sidebar and everyreader.sectionsconsumer see it exactly like an archived one. The section carries no members: nothing will read them, becauseread_wavefunction_gto()short-circuits on the overlay first.Registering the same id twice replaces the payload and leaves the single synthetic section in place, so re-running a criterion does not accumulate sidebar rows.
- Parameters:
section_id (str)
wavefunction (WavefunctionGTOData)
- Return type:
None
- clear_wavefunction_overlays(section_ids=None)[source]¶
Drop selected (or all) viewer-computed wavefunctions and their sections.
- property wavefunction_overlay_ids: list[str]¶
Section ids currently backed by a viewer-computed wavefunction.
- read_structure(section_id=None, *, apply_edits=True)[source]¶
Read + verify a structure section. Always eager.
section_iddefaults to the shown structure (shown_structure_id, the first structure unlessshow_structure()chose another); an archive without one raisesSectionNotFoundError. Wavefunctions may reference a different structure, which callers can request explicitly so the displayed atoms, cell, and AO centres stay registered.Set
apply_edits=Falseto read the archived reference geometry, for example when constructing a displacement from a normal mode. When an edit overlay is set (set_edit_overlay()), it applies only to the structure it was made on. Its returned atoms are the edited geometry andbondsis None (auto-bonding applies). PBC/dimensionality still come from the file; the lattice comes from the overlay when an edit replaced it. The file’s biomolecular metadata does not survive an edit: the overlay atoms carry no residue, chain or B-factor fields, and the producer-supplied residues, chains and secondary structure index the replaced atom list, so they are dropped.- Parameters:
- Return type:
- read_bonds(section_id, *, n_atoms=None)[source]¶
Read explicit pairs, checking their original structure when available.
Omitted orders retain 1.0. Explicit payload images are not specified by QVF v0.1.0 §5.1; retain the existing zero-image convention.
- connectivity(structure, section_id=None)[source]¶
The bonds every surface draws for
structure.The producer’s explicit bonds when the structure carries them, otherwise the covalent-radius inference (
vibeview.bonds. structure_bonds()); inferred bonds carry order 1.0, since radii cannot recover multiplicity. When the archive has abond_orderssection for the structure sectionstructurewas read from (section_id, by default the shown structure), its per-pair orders (Mayer/Wiberg, computed from the wavefunction) replace the orders for the pairs it lists.
- read_volume_grid(section_id)[source]¶
Read a finite grid descriptor consistent with its lazy binary member.
- read_volume_data(section_id)[source]¶
Read + verify volume data, including its pairing with the grid.
- read_phonon_bands(section_id)[source]¶
Read a phonon_bands section (QVF spec §4.13).
qpathmirrors the electronic kpath (labeled segments withn_points);frequenciesis[n_qpoints, n_modes]in cm^-1.- Parameters:
section_id (str)
- Return type:
- read_phonon_dos(section_id)[source]¶
Read a phonon_dos section (QVF spec §4.13).
frequenciesanddosare[n_points];metais required producer metadata (smearing, n_atoms, …), possibly an empty object.- Parameters:
section_id (str)
- Return type:
- read_equation_of_state(section_id)[source]¶
Read an equation_of_state section (QVF spec §4.14).
volumes/energiesare the sampled V-E points (Angstrom^3 / eV);fitcarries the producer’s fitted EOS params (model,V0,E0,B0in GPa,B0_prime, optional unit strings).- Parameters:
section_id (str)
- Return type:
- read_spectra(section_id)[source]¶
Read a
spectra.*section.frequenciesandintensitiesmust be flat lists of finite numbers with one shared length; anything else is aQVFErrorrecorded against the section (#66).- Parameters:
section_id (str)
- Return type:
- read_wavefunction_gto(section_id)[source]¶
Read a wavefunction.gto section (basis + MO coefficients).
A malformed
basisormo_metadatapayload (a missing shell key, a non-object, a non-numeric value) raisesQVFErrorand is recorded against the section, never a bareKeyError(#35-3).- Parameters:
section_id (str)
- Return type:
- read_reaction_path(section_id)[source]¶
Read a reaction.path section (self-contained: frames + waypoints).
v2 archives may carry a lattice binary member + a dim integer in the metadata JSON; both surface on the returned
ReactionPathData(None on v1 / molecular).- Parameters:
section_id (str)
- Return type:
- read_reaction_waypoints(section_id)[source]¶
Read a reaction.waypoints annotation that points at a trajectory.
- Parameters:
section_id (str)
- Return type:
- read_scan_surface(section_id)[source]¶
Read a scan.surface section (2D relaxed energy grid).
- Parameters:
section_id (str)
- Return type:
- read_atom_properties(section_id)[source]¶
Read population-analysis charges and spin populations.
- Parameters:
section_id (str)
- Return type:
- read_nmr(section_id)[source]¶
Read the NMR spectrum payload from a spectra.nmr section.
The producer hands the writer an opaque dict with conventional keys (chemical_shifts, shielding_tensors, j_couplings, isotope, reference, solvent); we surface the dict as-is.
- read_epr(section_id)[source]¶
Read the EPR parameter payload from a spectra.epr section.
The producer hands the writer an opaque dict with conventional keys (g_tensor, hyperfine, zero_field_splitting); we surface it as-is.
- read_symmetry(section_id)[source]¶
Read the spglib-style symmetry summary from a structure.symmetry section.
- Parameters:
section_id (str)
- Return type:
- read_scf_history(section_id)[source]¶
Read the per-iteration SCF history from a scf_history section.
Iteration record keys are conventional (see
SCFHistoryData); the renderer tolerates missing keys.- Parameters:
section_id (str)
- Return type:
- read_citations(section_id)[source]¶
Read the BibTeX bytes from a citations section.
The writer stores them as a binary member (utf-8) per design § 1.4 / qvf.py::_write_citations_section. We decode to str here so renderers don’t need to know the on-disk encoding.
- Parameters:
section_id (str)
- Return type:
- read_run_record(section_id)[source]¶
Read a run.record section — verbatim input + full log of one program invocation (spec § 5.8).
Text members are decoded UTF-8 with
errors="replace"(the format requires UTF-8; a lenient decode keeps a slightly broken producer viewable). Attachment members are listed but not read — they can be arbitrary bytes and are only surfaced by name.- Parameters:
section_id (str)
- Return type:
- read_run_record_attachment(section_id, role, *, max_bytes=4194304)[source]¶
Decode a run.record
attachment.*member as UTF-8 text.Attachments are arbitrary bytes; this returns None (rather than raising) when the member is absent, larger than
max_bytes(uncompressed, checked from the ZIP central directory before reading), or not valid UTF-8 — the renderer then falls back to listing the attachment by name.
- ATTACHMENT_DOWNLOAD_MAX_BYTES = 67108864¶
Hard ceiling on a single attachment download. The bytes are base64-encoded into a state value and pushed over the websocket, so this bounds memory and socket pressure, not disk.
- run_record_attachments(section_id)[source]¶
Describe a run.record’s
attachment.*members for listing.Metadata only — no payload is read. Each entry carries
role, afilename(sanitised to a bare basename; the files index is producer-supplied and must never steer a write),sizein bytes, andtoo_largeagainstATTACHMENT_DOWNLOAD_MAX_BYTES.
- read_run_record_attachment_bytes(section_id, role)[source]¶
Raw bytes of one
attachment.*member, for download only.Deliberately separate from
read_run_record_attachment(), which decodes text for rendering: attachments are arbitrary bytes by spec and callers must not be tempted to put these in the DOM. Returns None when the member is absent or exceedsATTACHMENT_DOWNLOAD_MAX_BYTES(checked from the ZIP central directory before reading, so a zip bomb cannot be expanded into memory first).
- read_job_spec(section_id)[source]¶
Read a job.spec section — the declarative request the archive carries (spec § 5.9). Pair with
run_statusto tell a pending container from a settled one.- Parameters:
section_id (str)
- Return type:
- read_reaction_scheme(section_id)[source]¶
Read a
reaction.schemesection (QVF spec § 5.14).The payload relates the archive’s
structuresections as the reactants, reagents and products of each step. A participant that names nostructuresection, a repeated step id or a step without reactants or products raisesQVFError, recorded against the section. Vendorx_keys are ignored.- Parameters:
section_id (str)
- Return type:
- PREVIEW_MAX_BYTES = 4194304¶
the spec recommends at most 1 MiB, and the bytes travel to the browser as a data URL.
- Type:
Largest preview member read for display
- read_preview(section_id, role='thumbnail')[source]¶
One verified member of a
previewsection (QVF spec § 5.15).roleisthumbnailorimage. Returns None when the member is absent, declares nomedia_type, or exceedsPREVIEW_MAX_BYTES(checked from the ZIP directory before reading). The picture describes the archive and is not data: nothing reads chemistry from it, and it is never drawn in the 3D scene.- Parameters:
- Return type:
PreviewImage | None
- read_bond_orders(section_id)[source]¶
Read analysis pairs validated against original file geometry.
Edit overlays do not change the atom identities of archived analyses. Standalone analysis sections still validate without an upper bound.
- Parameters:
section_id (str)
- Return type:
- read_topology_qtaim(section_id)[source]¶
Read a topology.qtaim section (critical points + bond paths).
- read_dos(section_id)[source]¶
Read a
dos.totalordos.projectedsection.A spin-projected
[2, n_ch, n_pts]projection is summed over spin so a consumer sees one series per channel; a total DOS keeps its[2, n_pts]spin axis for the caller to split.
- read_bands_projections(section_id)[source]¶
Optional fat-band projections of a
bandssection.Returns
(projections [n_kpoints, n_bands, n_channels], channel labels), or(None, [])when the section carries none.
- read_fermi_surface(section_id)[source]¶
Read a
fermi_surfacesection: energy mesh plus its metadata.- Parameters:
section_id (str)
- Return type:
- read_json_member(section_id, member_name)[source]¶
The parsed JSON of one member, verified against the manifest.
For kinds without a typed reader (vendor sections,
wanniercentres); the typedread_*methods are preferred where one exists.