Skip to content

cvc::mol: molecules from PDB, PQR and XYZR files (TexMol M0 part 1) - #1427

Merged
transfix merged 2 commits into
masterfrom
tmol/m0-molecules
Nov 21, 2026
Merged

transfix merged 2 commits into
masterfrom
tmol/m0-molecules

Conversation

@transfix

@transfix transfix commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

The first TexMol port: roadmap phase M0 in docs/roadmap/TEXMOL-F2DOCK-ARISRV-ROADMAP.md. It is also the first step toward a skeleton demo on molecular data instead of the bunny. Joe, 2026-11-21: "i believe skeletonization was meant for molecular data". The plan from here:

  1. A PDB file is read into atoms with radii (this PR).
  2. T1's blur turns the atoms into a density.
  3. The density's isosurface becomes the surface mesh_lab skeletonizes.

What it adds

  • inc/cvc/mol/molecule.h: a flat molecule model.

    • Atoms with serial, name, alternate location, residue, chain, insertion code, position, occupancy, B factor, element, HETATM flag, model, radius, charge and table row.
    • HELIX, SHEET and TURN residue ranges, HEADER's id and TITLE.
    • bounds() and structure_of(atom).
  • Readers:

    • PDB, by its fixed columns. It reads v3.3 and also the older files whose columns 73-80 hold the entry and a line number. Elements come from columns 77-78, or from the atom name by the PDB's convention.
    • PQR, by whitespace, with charge and radius from the file.
    • XYZR.
    • A malformed line is an error naming the file and line. TexMol's parser read such lines as zeros.
  • Each app's own file handlers. molecule_handlers(app) lives in an app slot, as point_classes does, and read_molecule dispatches by extension. Nothing is process-wide.

  • molecule_read_params, a param_table:

    • which model to read;
    • whether to keep HETATM records, water, hydrogens and alternate locations;
    • van der Waals or solvent-enlarged radii;
    • the radius of an atom the table lacks.

    The defaults keep what TexMol's PDBParser kept.

  • residue_atom_table.inc: PDBParser's ElementInformation table, all 410 rows, generated from TexMol ed20eae (LGPL-2.1 since TexMol#7). It holds the radii and charges a PDB file lacks.

    • TexMol gave an atom missing from the table its occupancy as its radius, because of addAtom's argument order.
    • Here such an atom gets unknown_radius, 2.0 by default, which is TexMol's defaultInformation value.
  • molecule_test, a port test, so it runs natively and in the wasm-mt lane. It covers:

    • the table;
    • every record kind and filter;
    • the older columns and CRLF lines;
    • PQR and XYZR;
    • each reader's errors;
    • two apps keeping separate handlers;
    • PDB entry 1GRL, a GroEL subunit. The test checks 4,186 atoms, 757 hydrogens, one heavy atom missing from the table (OXT), 19 helices and 11 sheet strands.
  • examples/data/molecules/1grl.pdb (PDB data, CC0) with a README and its notice. It lives in examples/data because the skeleton demo reads it too. Also the TexMol roadmap's progress section.

Not in this part

  • M0 part 2: the group tree, torsions, writers, CLI, pycvc and intrinsics.
  • The A/B against TexMol's parser. It comes with T1's blur, in tools/texmol-goldens/.

Testing

  • molecule_test: 12 of 12 pass natively (MSVC Release) and as wasm-mt under node 22.
  • clang-format: changed lines only (git-clang-format).

…ue-atom table (TexMol M0 part 1)

The first TexMol port (docs/roadmap/TEXMOL-F2DOCK-ARISRV-ROADMAP.md, M0), and the first step
toward a skeleton demo on molecular data: a PDB file read into atoms with radii, which T1's blur
turns into a density and its isosurface into the surface mesh_lab skeletonizes.

- inc/cvc/mol/molecule.h: a flat molecule (atoms with serial, name, alternate location,
  residue, chain, insertion code, position, occupancy, B factor, element, HETATM, model, radius,
  charge and table row; HELIX, SHEET and TURN residue ranges; HEADER's id and TITLE), its
  bounds, and the structure an atom's residue lies in.
- Readers: PDB by its fixed columns (v3.3, and the older files whose columns 73-80 hold the
  entry and a line number; elements from columns 77-78 or the atom name, by the PDB's own
  convention), PQR by whitespace (charge and radius from the file), XYZR. A malformed line is an
  error naming the file and line, where TexMol's parser read it as zeros.
- Each app's own file handlers (molecule_handlers(app), an app slot, as point_classes), and
  read_molecule by extension.
- molecule_read_params, a param_table: which model, HETATM, water, hydrogens, alternate
  locations, van der Waals or solvent-enlarged radii, and the radius of an atom the table
  lacks. The defaults keep what TexMol's PDBParser kept.
- residue_atom_table.inc: PDBParser's ElementInformation table (TexMol ed20eae, LGPL-2.1 since
  TexMol#7), all 410 rows, generated from it: radii, colours, hydrophobicities, interface
  propensities, solvent-enlarged radii and charges, looked up by atom and residue name without
  blanks. TexMol gave an atom the table lacks its occupancy as its radius (addAtom's argument
  order); here it gets unknown_radius, 2.0 by default, TexMol's defaultInformation.
- molecule_test (a port test: natively and in the wasm-mt lane): the table, every record kind
  and filter, the older columns and CRLF lines, PQR and XYZR, each reader's errors, two apps'
  handlers, and PDB entry 1GRL, a GroEL subunit: 4,186 atoms, 757 hydrogens, one heavy atom the
  table lacks (OXT), 19 helices and 11 sheet strands.
- src/cvc/tests/data/mol/1grl.pdb (the PDB, CC0) and its notice; the TexMol roadmap's progress.

Not in this part: the group tree, torsions, writers, CLI, pycvc and intrinsics (M0 part 2), and
the A/B against TexMol's parser, which comes with T1's blur in tools/texmol-goldens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant