Skip to main content

Choosing CLI vs Python

zsasa provides two main interfaces. The right choice depends on your input data and workflow.

Decision Guide

Your situationTypical inputRecommended
Pre-processed structureAlphaFold predictions, clean PDB/mmCIF (single model, no ligands, no altloc)CLI
Structure needs processingExperimental structures with altloc, ligands, waters, multiple modelsPython integrations
Combining with other toolsBioPython, Gemmi, MDAnalysis pipelinesPython integrations
Batch processing of clean filesDirectory of AlphaFold/ESMFold structuresCLI
MD trajectory (quick analysis)XTC/DCD files, no atom selection neededCLI traj
MD trajectory (atom selections)Trajectories requiring select="protein" etc.Python (MDAnalysis/MDTraj)

CLI: Pre-processed Structures

The CLI works best with clean, simple structures that need no pre-processing:

  • AlphaFold/ESMFold predicted structures (single model, protein only)
  • Pre-cleaned PDB/mmCIF files
  • Batch processing of many files
# Single structure
zsasa calc structure.cif output.json

# With classifier
zsasa calc --classifier=naccess structure.cif output.json

# Batch: process all files in a directory
zsasa batch structures/ results/

The CLI supports basic filtering (--chain, --model, --include-hetatm, --include-hydrogens), but has limitations:

  • Altloc — uses the first conformer encountered (no manual selection)
  • HETATM — all-or-nothing (--include-hetatm), no granular control (e.g., keep ligands but remove waters)
  • No programmatic control — cannot combine with other analysis libraries

Python Integrations: Structure Processing Required

Use Python integrations when your structures need pre-processing or you're combining zsasa with other analysis tools.

Structure pre-processing (Gemmi, BioPython, Biotite)

These integrations parse structure files through their respective libraries, which handle:

  • Altloc selection — choose specific conformers
  • HETATM filtering — include/exclude ligands, waters, ions
  • Model selection — pick specific models from NMR ensembles
  • Chain/residue selection — analyze specific parts of a structure
from zsasa.integrations.gemmi import calculate_sasa_from_structure

# Basic usage (handles altloc, HETATM automatically)
result = calculate_sasa_from_structure("complex.cif")

# Exclude ligands and hydrogens
result = calculate_sasa_from_structure(
"complex.cif",
include_hetatm=False,
include_hydrogens=False,
)

MD trajectory analysis (MDAnalysis, MDTraj)

For molecular dynamics trajectories with atom selections:

import MDAnalysis as mda
from zsasa.mdanalysis import SASAAnalysis

u = mda.Universe("topology.pdb", "trajectory.xtc")
sasa = SASAAnalysis(u, select="protein and not resname HOH")
sasa.run()

Combining with other tools

When zsasa is part of a larger analysis pipeline:

import gemmi
from zsasa.integrations.gemmi import calculate_sasa_from_model

# Load and manipulate structure with Gemmi
st = gemmi.read_structure("complex.cif")
st.remove_ligands_and_waters()

# Then calculate SASA
result = calculate_sasa_from_model(st[0])

Quick Reference

ScenarioRecommendedWhy
AlphaFold structuresCLIPre-processed, no cleanup needed
Batch processing (clean files)CLIFast, scriptable
PDB with ligands/watersPython (Gemmi)Granular HETATM control (keep ligands, remove waters)
NMR ensemble (specific model)CLI or PythonCLI: --model=N, Python: model_index parameter
MD trajectoryCLI traj or PythonCLI for quick analysis, Python for selections
Integration with BioPython pipelinePython (BioPython)Native object passing
Biotite/AtomWorks workflowPython (Biotite)Native AtomArray support

Available Integrations

IntegrationLibraryFormatsBest For
GemmigemmimmCIF, PDBFast parsing, large files
BioPythonBioPythonPDB, mmCIFExisting BioPython workflows
BiotiteBiotitePDB, mmCIF, BinaryCIFAtomWorks compatibility
MDAnalysisMDAnalysisXTC, TRR, DCD, etc.MD trajectory + selections
MDTrajMDTrajXTC, TRR, DCD, etc.Drop-in for mdtraj.shrake_rupley