neurosnap.structure.analysis module#

General analysis helpers & physical property calculations for Neurosnap structures.

neurosnap.structure.analysis.ca_distance_matrix(structure, chain=None)[source]#

Alias for calculate_distance_matrix().

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

  • chain (Optional[str]) – Optional chain ID to restrict the calculation to.

Return type:

ndarray

Returns:

A square NumPy array of pairwise CA distances in Å.

neurosnap.structure.analysis.calculate_distance_matrix(structure, chain=None)[source]#

Calculate the CA-atom distance matrix for a single structure.

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

  • chain (Optional[str]) – Optional chain ID to restrict the calculation to.

Return type:

ndarray

Returns:

A square NumPy array of pairwise CA distances in Å.

neurosnap.structure.analysis.calculate_protein_volume(structure, chain=None)[source]#

Estimate protein volume from atom van der Waals spheres.

The calculation sums the volumes of van der Waals spheres for atoms belonging to residues classified as protein. It is therefore a simple geometric estimate rather than an excluded-volume or solvent-corrected measurement.

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

  • chain (Optional[str]) – Optional chain ID to restrict the calculation to.

Return type:

float

Returns:

Estimated protein volume in ų.

neurosnap.structure.analysis.calculate_surface_area(structure, level='R', probe_radius=1.4, n_sphere_points=96)[source]#

Estimate solvent-accessible surface area using a simple Shrake-Rupley approximation.

The returned total SASA is the same regardless of level; the parameter is kept for compatibility with the public surface-area API.

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

  • level (str) – Compatibility flag matching the historical public API. The returned total SASA is always a structure-level scalar, regardless of this value. Must be one of "A", "R", "C", "M", or "S".

  • probe_radius (float) – Solvent probe radius in Å used to inflate atom radii during the accessibility calculation.

  • n_sphere_points (int) – Number of surface points sampled per atom for the Shrake-Rupley approximation.

Return type:

float

Returns:

Estimated solvent-accessible surface area in Ų.

neurosnap.structure.analysis.extract_non_biopolymers(structure, output_dir, min_atoms=0)[source]#

Extract non-biopolymer fragments from a structure and write them as SDF files.

Biopolymer residues are removed using the same residue-name logic as the old implementation: any residue present in AA_RECORDS or STANDARD_NUCLEOTIDES is treated as part of a protein or nucleotide polymer, except UNK which is preserved. The remaining atoms are written to a temporary PDB, read into RDKit, split into disconnected fragments, and then exported as individual SDF files.

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

  • output_dir (str) – Directory where SDF files will be written. Any existing directory at that path is replaced.

  • min_atoms (int) – Minimum fragment atom count required for export.

Returns:

None. Matching fragments are written to output_dir as .sdf files.

neurosnap.structure.analysis.get_backbone(structure, chains=None, *, include_nucleotides=True)[source]#

Extract ordered backbone coordinates from a single structure.

Protein residues contribute N, CA, and C atoms. When include_nucleotides is enabled, DNA and RNA residues contribute their sugar-phosphate backbone atoms in a deterministic order. Non-polymers are ignored.

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

  • chains (Optional[Sequence[str]]) – Optional chain IDs to include. If None, all chains are used.

  • include_nucleotides (bool) – If True, include DNA and RNA backbone atoms in addition to protein backbone atoms.

Return type:

ndarray

Returns:

A NumPy array of backbone coordinates with shape (n_atoms, 3).