neurosnap.structure.prepare module#

Structure-preparation helpers.

This module provides small structure-level preparation utilities plus thin wrappers around the existing PDB2PQR preparation backend.

The wrappers intentionally do not reimplement that engine. They expose a structure-oriented API while delegating the underlying chemistry logic to the existing algorithm module.

neurosnap.structure.prepare.add_hydrogens_with_pdb2pqr(structure, *, forcefield='PARSE', ffout=None, neutraln=False, neutralc=False, debump=True)[source]#

Add hydrogens using the PDB2PQR preparation backend.

This wrapper delegates to neurosnap.algos.pdb2pqr.assign_pqr() with assign_only=False and optimize=False. PDB2PQR may still perform its internal water-specific hydrogen handling, but it skips the full optimization path used by optimize_hydrogens_with_pdb2pqr().

The returned structure is the PDB2PQR-rebuilt structure, so it also carries any charge/radius annotations and provenance metadata that backend emits.

Return type:

Structure

neurosnap.structure.prepare.add_terminal_capping_groups(structure, *, chains=None, n_terminal=True, c_terminal=True)[source]#

Return a copy with ACE/NME caps added to protein chain termini.

Adds an ACE heavy-atom cap to each selected chain N-terminus and an NME heavy-atom cap to each selected chain C-terminus. Coordinates are placed from terminal backbone geometry and should be relaxed by a molecular mechanics tool before downstream workflows that require optimized cap conformations.

Parameters:
  • structure (Structure) – Input single-model structure.

  • chains (Optional[Sequence[str]]) – Optional chain IDs to cap. If None, all protein-containing chains are considered.

  • n_terminal (bool) – Whether to add N-terminal ACE caps.

  • c_terminal (bool) – Whether to add C-terminal NME caps.

Return type:

Structure

Returns:

New Structure containing the original atoms plus cap atoms and covalent cap bonds.

neurosnap.structure.prepare.has_hydrogens(structure)[source]#

Return True if the structure currently contains hydrogen atoms.

Parameters:

structure (Structure) – Input single-model structure.

Return type:

bool

Returns:

True when any atom has element H after simple normalization.

neurosnap.structure.prepare.optimize_hydrogens_with_pdb2pqr(structure, *, forcefield='PARSE', ffout=None, neutraln=False, neutralc=False, debump=True)[source]#

Add and optimize hydrogens using the PDB2PQR preparation backend.

This wrapper delegates to neurosnap.algos.pdb2pqr.assign_pqr() with assign_only=False and optimize=True.

The returned structure is the PDB2PQR-rebuilt structure, so it also carries any charge/radius annotations and provenance metadata that backend emits.

Return type:

Structure

neurosnap.structure.prepare.remove_altlocs_and_duplicate_atoms(structure)[source]#

Return a copy with one atom retained for each residue atom site.

Atom sites are identified by chain ID, residue ID, insertion code, residue name, hetero flag, and atom name. When multiple atoms share a site, the atom with the highest occupancy is retained. Ties prefer a blank alternate location, then alternate location A, then the first atom in input order.

Neurosnap’s PDB/mmCIF parsers already collapse alternate locations while loading. This helper is mainly useful for structures built manually or from workflows that add an altloc-style annotation column.

Parameters:

structure (Structure) – Input single-model structure.

Return type:

Structure

Returns:

New Structure with duplicate atom sites removed. If an optional alternate-location annotation column is present, it is removed from the returned structure.

neurosnap.structure.prepare.strip_hydrogens(structure)[source]#

Return a copy of the structure with hydrogen atoms removed.

Atom-level connectivity tables are subsetted and remapped automatically via Structure.select(), so both bonds and interactions remain consistent with the returned atom table.

Parameters:

structure (Structure) – Input single-model structure.

Return type:

Structure

Returns:

New Structure without hydrogen atoms.