Source-linked AI summary
FreeSASA: An open source C library for solvent accessible surface area calculations
Simon Mitternacht
TL;DR
Existing SASA tools include command-line programs and other implementations, but FreeSASA targets a simple, tool-chain-integrable open-source alternative. It combines established SASA approximations with configurable interfaces and performs as fast as or faster than legacy programs, including additional multicore speedup.
Problem
SASA calculation has many available tools, but a simple free-standing open-source program designed for easy tool-chain integration is lacking.
Method
FreeSASA provides command-line, C, and Python interfaces, implements Lee and Richards' and Shrake and Rupley's approximations, and supports configurable calculation parameters.
Results
Performance tests show FreeSASA is as fast as or faster than legacy programs on a single CPU core, with additional speedup from multicore parallelization.
Takeaways & Limitations
FreeSASA offers a documented, thread-safe SASA library with minimal dependencies, sensible defaults, and detailed control for tool-chain integration.
Abstract
from arXiv · showhide
Calculating solvent accessible surface areas (SASA) is a run-of-the-mill calculation in structural biology. Although there are many programs available for this calculation, there are no free-standing, open-source tools designed for easy tool-chain integration. FreeSASA is an open source C library for SASA calculations that provides both command-line and Python interfaces in addition to its C API. The library implements both Lee and Richards' and Shrake and Rupley's approximations, and is highly configurable to allow the user to control molecular parameters, accuracy and output granularity. It only depends on standard C libraries and should therefore be easy to compile and install on any platform. The source code is freely available from http://freesasa.github.io/. The library is well-documented, stable and efficient. The command-line interface can easily replace closed source legacy programs, with comparable or better accuracy and speed, and with some added functionality.
Background
FreeSASA addresses the need for an open-source, tool-chain-friendly SASA calculator by combining established approximations with configurable interfaces and minimal dependencies. It is documented, efficient, and designed to match or exceed legacy-tool performance.
- Motivation: SASA measures molecular contact area with solvent and supports comparisons between molecules, conformations, and oligomerization-buried surfaces.Its quantitative relation to free energy remains elusive.
- Method: FreeSASA implements the Lee and Richards slice approximation and the Shrake and Rupley test-point approximation, with precision adjustable by resolution.SASA is defined using a spherical probe rolled over the molecular surface.
- Contribution: FreeSASA provides an open-source command-line tool that can be integrated into tool chains, alongside C and Python APIs.It is intended to fill the niche occupied by simple command-line programs such as NACCESS.
- Design: The library offers sensible defaults for casual users while allowing full control over calculation parameters and requiring only standard C and GNU libraries to compile.It is also thread-safe, designed to handle errors gracefully, and accompanied by thorough documentation.
- Performance: Performance tests show that FreeSASA is as fast as or faster than legacy programs on a single CPU core, with additional speed from multicore parallelization.The performance claim is reported for the tested legacy-program comparisons.
Implementation
FreeSASA combines two established SASA algorithms with linear-time contact handling, configurable atomic parameters, and command-line controls for structures, chains, selections, and output.
- Algorithms: Both SASA algorithms identify contacting atoms and calculate overlap independently for each atom, making each stage O(N) and the second stage trivially parallelizable.FreeSASA uses cell lists for contact detection.
- Lee and Richards: Lee and Richards uses atom-specific slicing, with the number of slices per atom determining resolution and giving larger atoms thicker slices than smaller atoms.The passage states that small atoms have thinner slices than large atoms.
- Shrake and Rupley: Shrake and Rupley test points are generated efficiently with a Fibonacci spiral, while FreeSASA does not implement the second test-point lattice of the double cubic lattice optimization.The Fibonacci spiral supports arbitrary numbers of approximately even spherical points.
- Validation: Implementation correctness was checked visually, analytically for two atoms, across high-precision independent algorithms, and against NACCESS at matching resolution and radii.The NACCESS comparison produced identical results under those matched settings.
- Command-line interface: The command-line interface reports algorithm parameters, input structure details, total, polar, apolar, and per-chain SASA values.For 3wbm.pdb, the example uses Lee and Richards with a 1.400 probe radius, 2 threads, and 20 slices.
- Command-line interface: Command-line options support stdin processing, configurable slices, suppressed logging, PDB filtering, chain-group analysis, and atom selection using a subset of PyMOL syntax.Selections can report the SASA contribution of user-defined atom groups such as specified RNA bases.
C API
FreeSASA exposes SASA calculations through a C API and Python bindings, supporting structure files as well as coordinate-and-radius inputs with default or customized parameters.
- C API: The C API reads a PDB structure and calculates its SASA with default parameters through structure-parsing and structure-calculation functions.The example prints the total surface area and notes that classifier and calculation parameters can be supplied instead of NULL arguments.
- Coordinate input: The API also calculates SASA directly from coordinates paired with atomic radii and can return individual-atom areas.The example uses atoms at (1,1,1) and (2,2,2) with radii 2 and 3, respectively.
- Python bindings: Python bindings export most of the C API and support structure loading, SASA calculation, result classification, and reporting total, polar, and apolar areas.The Python example performs the same structure-based calculation as the C example and additionally reports polar and apolar areas.
Performance
Across 88 proteins, FreeSASA’s two algorithms show a resolution-dependent speed trade-off, while L&R closely matches NACCESS and gains substantially from parallelization. POPS is fast only as a coarse-grained approximation and exhibits O(N^2) scaling.
- Experimental setup: The performance study used 88 randomly selected PDB files spanning size intervals, with repeated fastest runs to reduce variation in short calculations.The largest structure had over 30,000 atoms.
- FreeSASA algorithms: At low resolution, S&R is considerably faster than L&R; at high resolution, L&R is faster, with a crossover at 1000 test points or 20 slices per atom.Twenty slices per atom is FreeSASA’s default setting.
- Comparison with existing tools: POPS has a reported average error of 2.6 Å^2 per atom, while its measured mean error is lower because that error is measured over total SASA rather than atom by atom.A fit found that POPS runs in O(N^2) time, helping explain its relatively long mean calculation time per atom.
- Comparison with existing tools: FreeSASA using L&R is almost indistinguishable from NACCESS in single-threaded mode but significantly faster with 2 or 4 threads.The comparison used NACCESS as a reference-compatible L&R implementation.
- Parallelization: More than one thread provides a significant performance benefit only in the high-resolution limit because cell-list generation is not parallelized.The default was consequently set to two threads.
Summary
FreeSASA is an efficient SASA library for protein, RNA, and DNA structures. It matches or exceeds the speed of some popular tools at a given resolution and can be accelerated through parallelization.
- FreeSASA is an efficient library for calculating SASA for protein, RNA, and DNA structures.
- The library is open source, configurable, and available as a command-line tool, C library, and Python module.
- Tests show that FreeSASA runs as fast as or faster than some popular tools at a given resolution and can be further boosted by parallelizing the calculation.
Appendix
The appendix demonstrates a basic FreeSASA C workflow: read a structure from PDB input, calculate SASA and class areas, print results, and release resources. It also includes error handling at each stage.
- Basic calculation: A basic C example reads a molecular structure from standard input before calculating its SASA.The structure is parsed with freesasa_structure_from_pdb, then passed to the calculation routine.
- Error handling: The example checks whether structure, result, and class-area objects are available before proceeding to subsequent operations.Conditional checks route failures to an error message rather than continuing with invalid resources.
- Basic calculation: The calculation returns a result object whose total SASA is printed alongside per-class areas such as polar and apolar contributions.Class areas are computed after the main result is available and printed conditionally.
- Resource management: Allocated structure, result, and class-area resources are explicitly freed before program termination.The cleanup calls release each object created during the workflow.