Skip to content

SecondaryStructures port (TexMol T5): helices and sheets from a surface's medial axis - #1440

Merged
transfix merged 5 commits into
masterfrom
tfx/tmol-t5-secondary
Nov 23, 2026
Merged

transfix merged 5 commits into
masterfrom
tfx/tmol-t5-secondary

Conversation

@transfix

@transfix transfix commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

The second half of TexMol roadmap item T5. It ports VolumeRover's SecondaryStructures, which finds a protein's helices and sheets from a density map's isosurface through the surface's medial axis. The port is a headless cvc:: core with a resumable stepper, tests natively and in wasm-mt, and an A/B against the legacy library.

The core

cvc::find_secondary_structures(app, surface, params) lives in inc/cvc/geometry/secondary_structures.h, with its parameter table in secondary_structures_params.h.

What it reuses. It builds on the shared cocone core, and changes none of its files. The triangulation and Tight Cocone are the core's, in src/cvc/geometry/cocone/ since #1439. U1 and U2 are the skeleton's (src/cvc/geometry/skeleton/skeleton_stages.h). SecondaryStructures' copies of those files were near-copies of Skeletonization's; a token-level diff found only the U2 return value and the cosmetics changed.

Its own stages are in src/cvc/geometry/secondary/:

  • secondary_axis.cpp:
    • the inner medial axis: every inside Voronoi facet, peeled from its free boundary down to the facets the angle and ratio conditions tag;
    • the skeleton graph (legacy add_u1_to_skel / add_u2_to_skel). It is rebuilt from the core's U2 graph, and the legacy cell-base fields live in side arrays indexed by cell id.
  • secondary_select.cpp:
    • sheets: components by area, polygons drawn by width;
    • helices: U2 edges in the width window, clustered within 4 Å, split into runs of one direction, and a principal axis fitted to each run (LAPACK's dsyev becomes a 3x3 Jacobi);
    • the cylinder, sheet and skeleton geometries.
  • secondary_structures.cpp: secondary_stepper (a result_job, with phases checking through output), find_secondary_structures_job, and select_secondary_structures.

The result keeps the skeleton graph. select_secondary_structures re-runs only the selection with new windows and counts, as the legacy GUI's sliders did.

State and I/O.

  • The output geometries are made with the app the call names.
  • There are no statics or singletons, and no singleton_scan allowlist lines were added.
  • There are no file writes and no exit().

Fixed on the way in. Each fix is also a recorded patch of the legacy build, so the A/B compares like with like:

  • A chain step between cells with no common facet got a squared circumradius as its width; it now gets the circumradius.
  • An isolated candidate point made an empty run, which the fit divided by zero for; empty runs are skipped.
  • Three CGAL_assertion(get_eid(...)) calls had side effects that release builds compiled out, which wrote before the edge array; the lookups now always run.
  • The legacy std::map dropped helices of equal length; all are kept.
  • An axis along z gave a cylinder of NaNs; it now gets the identity rotation.
  • The debug files, rand() colours and the Robust Cocone path (whose output the second triangulation never read) are gone.

The A/B (tools/volrover-goldens)

The legacy build. secondary_legacy builds the library from the pinned volrover sha:

  • patches: the eight side-effect assertions, the infinite-cell cospherical test, the two port fixes, the VLA, and CGAL 6's dual();
  • shims: dsyev_, cvcgeom_t, HistogramData, and a forced HUGE, because the UCRT and glibc treat the legacy -DHUGE differently.

make_goldens.py runs it by default, so CI's existing volrover goldens job runs --check on it.

Two committed inputs:

Case Port vs legacy
helices_and_sheet: three tubes and a slab (make_inputs.py) Exact: all 2,208 polygons, 6,153 edges and 17 component areas; all 363 + 2,208 histogram widths; the 3 helix axes to 2e-9; all 1,662 sheet polygons
1grl: PDB 1GRL's blur-map isosurface (blobbiness -0.3, 2 Å, isovalue 12, 9,581 points) Statistical: 99% of the polygon widths, every helix width, 65 of 69 component areas, 17 of 20 helix axes within 3 Å at both ends, every sheet polygon

Why 1GRL is statistical. On 1GRL the core's Tight Cocone already differs a little from the legacy's: 19,166 surface facets against 19,154. P1's own skeleton matches 98.5% of the legacy Skeletonization's segments on the same surface. So the residual difference comes from the shared core, through cell order and Voronoi-vertex rounding, and is not in the SecondaryStructures stages.

The 1GRL input's provenance. The surface is cvc::mol::blur (#1428, now on master) plus cvc::iso, rounded to 1/64 Å. The1GRLInputIsItsBlurMapsIsosurface makes it again on native builds: all 9,581 points are identical on MSVC, and the test allows 1% to move across a rounding step on another compiler.

The molecule check

FindsTheHelicesOf1GRL reads the committed surface and examples/data/molecules/1grl.pdb:

  • 18 of the 20 helix axes found lie on HELIX residues;
  • 15 of the file's 19 helices have an axis through them.

How the settings were chosen. A sweep picked blobbiness -0.3, 2 Å, isovalue 12. The skeleton lab's -0.2 / 2 Å / 10 map is too blobby for the legacy 2–3 Å window: it finds one helix there. The result is sensitive to the isovalue, because the window is the legacy's.

Tests

secondary_structures_test has 12 tests. It is in CVC_PORT_TESTS, so it runs natively and in the wasm-mt ports lane:

  • the legacy A/B (both cases);
  • 1GRL against its PDB records;
  • the committed 1GRL surface remade from the PDB (native only: the wasm lane has no isosurfacing);
  • known shapes: tube, slab, too-wide tube, too-thick slab;
  • point order (bit for bit) and rigid motion;
  • a mesh read by its faces;
  • bad input that throws: fewer than four points, plane, line, NaN, a face index past the points, invalid parameters, a bad skeleton for re-selection;
  • degenerate input;
  • two apps at once on two threads;
  • the T7 resumable harness;
  • re-selection equals a run with those parameters;
  • the parameter table on the state tree.

Local runs on the head with #1439 merged in, against the Linux goldens:

  • MSVC Release: 12/12, with pocket_tunnel_test 15/15, skeleton_test 11/11 and tet_complex_test 10/10.
  • wasm-mt under node: 11 pass and the provenance test is skipped; pocket_tunnel_test 14 and skeleton_test 11 pass.

The goldens are Linux's. CI's first Linux --check (run 44957679986) made different bytes from the Windows build, so the committed goldens are that run's upload, as the skeleton's are:

  • helices_and_sheet: the same counts, and the same values to 4e-13, some in another order;
  • 1grl: the legacy finds 22 candidate runs on Linux, 21 on Windows, and draws 20 on both.

The port passes against either set: helices_and_sheet exactly; on 1grl, 15 of 20 axes within 1 Å at both ends against Linux's goldens and 13 against Windows', with 17 within 3 Å against both. tools/volrover-goldens/README.md records this. A Windows --check now fails, as the skeleton's does.

Docs

  • docs/roadmap/TEXMOL-F2DOCK-ARISRV-ROADMAP.md: §2.2's row records the licence ruling ("It is also LGPL-2.1 like the rest", 2026-11-21) and points at the port; §2.6 gets a "built" note; T5's "needs" no longer waits on the licence.
  • THIRD_PARTY_NOTICES.md records the ruling, and the derived 1GRL surface and goldens under PDB entry 1GRL.
  • tools/volrover-goldens/README.md gets a SecondaryStructures section.
  • The VolumeRover roadmap's helix-window note points here.

Follow-ups

  • The CLI, pycvc, DSL intrinsics and a mesh_lab request or demo.
  • SuperSecondaryStructures.

After #1439

#1439 (PocketTunnel) merged first and moved the cocone core to src/cvc/geometry/cocone/. Master is merged in here:

…ce's medial axis

cvc::find_secondary_structures (inc/cvc/geometry/secondary_structures.h) ports VolumeRover's
SecondaryStructures onto P1's cocone core as it is: the triangulation, Tight Cocone, U1 and U2
come from src/cvc/geometry/skeleton unchanged. Its own stages are in src/cvc/geometry/secondary:
- the inner medial axis, peeled from its free boundary down to the facets the angle and ratio
  conditions choose;
- the skeleton graph (U1's polygons, U2's chains), each with its width;
- the selection: sheets by component area and polygon width, helices by U2 width, clustered into
  runs of one direction, with a principal axis fitted to each run.

The stepper is a result_job and the parameters are a param_table. The result keeps the skeleton
graph, so select_secondary_structures re-chooses the helices and sheets as the legacy GUI's sliders
did. The output geometries belong to the app the call names. No statics, no file writes, no exit().
Fixed on the way in, as patches of the legacy build:
- a chain step's width was a squared circumradius;
- the fit of an empty run divided by zero;
- three assertions with side effects were compiled out.

The A/B in tools/volrover-goldens builds the legacy library at the pinned volrover sha, with
shims for LAPACK's dsyev and its geometry and histogram types. It has two committed inputs:
- three tubes and a slab, which the port matches exactly;
- 1GRL's blur-map isosurface, matched statistically: 99% of the polygon widths, every helix
  width, 17 of 20 helix axes within 3 A. The core's Tight Cocone differs slightly there already,
  as does P1's skeleton against the legacy Skeletonization.

Against PDB 1GRL's own records, 18 of the 20 helix axes found lie on HELIX residues, and 15 of
its 19 helices are found. secondary_structures_test passes natively and as wasm-mt under node.

Licence: SecondaryStructures is UT LGPL-2.1 like the rest (Joe, 2026-11-21), recorded in the
TexMol roadmap's §2.2 row and THIRD_PARTY_NOTICES.md.
…'s isosurface

With #1428's cvc::mol::blur on master, the test makes 1GRL's surface again: the
isosurface at 12 of its heavy atoms' blur map (blobbiness -0.3, a 2 A grid), rounded to 1/64 A.
It then compares the result with tools/volrover-goldens/inputs/secondary/1grl.pts. On MSVC all
9,581 points are the same; the test allows 1% to move across a rounding step on another compiler.
It runs natively only, because the wasm ports lane has no isosurfacing.

1grl.json now names master's commit instead of a local copy of the blur. The goldens' ss.txt
files are unchanged.
…made

CI's first Linux --check of the legacy SecondaryStructures (run 44957679986) made other bytes
than the Windows build: on helices_and_sheet the same values to 4e-13, some in another order;
on 1grl 22 candidate runs to Windows' 21, 20 drawn on both. These are that run's goldens, as
the skeleton's are. The port passes against either set (helices_and_sheet exactly; on 1grl 15
of 20 axes within 1 A at both ends against Linux's, 13 against Windows').
…-secondary

#1439 moved the cocone core to src/cvc/geometry/cocone and the skeleton's U1/U2 declarations to
skeleton/skeleton_stages.h, so secondary.h now includes that. The eight conflicts are adjacent
additions, and both sides are kept: the build lists, the goldens tool (CMakeLists, make_goldens.py,
make_inputs.py, README) and the TexMol roadmap. The shared cvcgeom.h shim is #1439's plus line_t
and lines(). With that shim, the legacy SecondaryStructures makes the same bytes as before.
@transfix
transfix merged commit 96b2702 into master Nov 23, 2026
32 checks passed
@transfix
transfix deleted the tfx/tmol-t5-secondary branch November 23, 2026 01:11
transfix added a commit that referenced this pull request Nov 23, 2026
…-segment

volume_grid_quad.png conflicted (both sides re-rendered it); kept ours until
CI renders the merged panel.
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