Skip to main content

Algorithms

zsasa provides two SASA calculation algorithms.

Recommendation

Use Shrake-Rupley (SR) for most use cases. It is the default algorithm, faster, and produces results within 0.05% of Lee-Richards.

Use Lee-Richards (LR) only when you need to compare results with other LR implementations or require arc-based geometric rigor.

Comparison

PropertyShrake-Rupley (SR)Lee-Richards (LR)
MethodTest point samplingSlice/arc integration
SpeedFast~4x slower
DefaultYes (--algorithm=sr)No (--algorithm=lr)
Precision control--n-points (default: 100)--n-slices (default: 20)
Recommended forGeneral useComparison with LR implementations

Performance (1A0Q, 3,183 atoms, 4 threads)

AlgorithmTimevs FreeSASA C
SR (100 points)2.6ms1.7x faster
LR (20 slices)9.9ms1.6x faster

Accuracy

Both algorithms produce nearly identical results on the same structure:

AlgorithmSASA (Ų)
SR (100 points)19,211.19
LR (20 slices)19,201.26
Difference0.05%

Usage

# Shrake-Rupley (default)
zsasa calc structure.cif output.json

# Lee-Richards
zsasa calc --algorithm=lr structure.cif output.json

# SR with more test points (higher precision)
zsasa calc --n-points=200 structure.cif output.json

Precision vs Speed

Shrake-Rupley: --n-points

PointsPrecisionRelative Time
50Low0.5x
100Medium (default)1.0x
200High2.0x
1000Very high10.0x

Lee-Richards: --n-slices

SlicesPrecisionRelative Time
10Low0.5x
20Medium (default)1.0x
50High2.5x
100Very high5.0x

Bitmask LUT Optimization

The Shrake-Rupley algorithm supports an optional bitmask lookup table (LUT) optimization that significantly improves performance, especially for large structures and MD trajectories. This approach is inspired by Lahuta, which demonstrated the effectiveness of bitmask-based neighbor occlusion for SASA calculations.

How It Works

In standard SR, each neighbor's occlusion of test points is computed individually by distance checks. The bitmask LUT approach replaces this with precomputed bitmask patterns:

  1. Precompute: For each possible neighbor geometry (distance, relative orientation), a bitmask encodes which test points on the sphere are occluded
  2. Lookup: During calculation, the appropriate bitmask is fetched from the LUT based on neighbor position
  3. Combine: Neighbor occlusion masks are combined using bitwise OR — a single CPU instruction processes all test points simultaneously

This converts the inner loop from per-point floating-point comparisons to bulk bitwise operations, yielding ~2x speedup on large systems.

Performance

Bitmask mode provides the largest benefit on large structures and long trajectories:

Use CaseSpeedup vs StandardDetails
Single file (100k+ atoms)~1.2xSingle-file benchmarks
Batch proteome processing~1.5–2xBatch benchmarks
MD trajectory (33k atoms, 1k frames)~2.1xMD benchmarks

Memory usage is minimal — the LUT adds only ~2 MB overhead for CLI mode.

Accuracy

Bitmask introduces a small systematic offset due to the LUT discretization:

MetricStandard SRBitmask
R² vs FreeSASA1.0000000.9997
Mean error< 0.001%~0.7%
Max error< 0.02%~2.5%

The offset is constant regardless of n_points (unlike standard SR where error decreases with more points). However, for MD trajectory analysis, the frame-to-frame changes (ΔR²) are nearly identical between standard and bitmask (> 0.99 at 500+ points) — the systematic offset cancels out in differences.

For detailed accuracy analysis, see SASA Validation.

Constraints

  • SR algorithm only — not available for Lee-Richards
  • Supported n_points: 1–1024
  • Lahuta uses n_points=128 fixed; zsasa supports any value in range

When to Use

ModeBest For
Standard (default)Maximum accuracy, small structures, single calculations
BitmaskMD trajectories, batch processing, large structures, memory-constrained environments

Usage

# Bitmask with 128 test points (recommended)
zsasa calc --use-bitmask --n-points=128 structure.cif output.json

# Trajectory with bitmask
zsasa traj --use-bitmask --n-points=128 trajectory.xtc topology.pdb

# Batch with bitmask
zsasa batch --use-bitmask --n-points=128 input_dir/ output_dir/

References

  • Shrake, A.; Rupley, J. A. Environment and Exposure to Solvent of Protein Atoms. J. Mol. Biol. 1973, 79(2), 351-371.
  • Lee, B.; Richards, F. M. The Interpretation of Protein Structures: Estimation of Static Accessibility. J. Mol. Biol. 1971, 55(3), 379-400.
  • Lahuta — Bitmask LUT approach for SASA neighbor occlusion.