Abstract
NanoShaper (NS) is a widely used tool that leverages ray tracing for molecular surface triangulation, pocket detection, and supports Poisson-Boltzmann equation solvers. By retaining the established methodological framework and implementing a targeted redesign, our approach achieves performance gains of up to 12.5× and memory reductions of up to 8×, enabling the triangulation of complexes containing millions of atoms on relatively modest computational architectures in a short time. The key innovation is a patch-based ray tracing algorithm that replaces the traditional ray-sweeping approach. By iterating over surface patches rather than rays, this method enhances cache performance and removes the need for memory-intensive grids for patch localization, yielding major reductions in memory usage. Further optimizations include the parallelization of the analytical solvent-excluded surface (SES) construction and the replacement of uniform grids and octrees with bilevel grids and/or compressed buffers. We also introduce an analytical ray-torus intersection scheme based on an exact quartic solution, which improves both accuracy and computational efficiency. The updated version (v1.5) additionally provides a public C++ API for seamless integration with external tools. The tool is available at https://gitlab.iit.it/SDecherchi/nanoshaper. Results on more than 1500 structures and on a multimillion atom complex (e.g., the H1N1 virus) confirm speed and accuracy achievements.