biomol.core.IndexTable#

class IndexTable(atom_to_res, res_to_chain, res_atom_indptr, res_atom_indices, chain_res_indptr, chain_res_indices)[source]#

Bases: object

Index mapping between structural levels.

This class stores forward parent mappings and reverse CSR mappings to efficiently move between atoms, residues, and chains.

Parameters:
  • atom_to_res (NDArray[np.integer]) – 1D array mapping each atom index to its parent residue index.

  • res_to_chain (NDArray[np.integer]) – 1D array mapping each residue index to its parent chain index.

  • res_atom_indptr (NDArray[np.integer]) – CSR index pointer array for residues to atoms mapping.

  • res_atom_indices (NDArray[np.integer]) – CSR indices array for residues to atoms mapping.

  • chain_res_indptr (NDArray[np.integer]) – CSR index pointer array for chains to residues mapping.

  • chain_res_indices (NDArray[np.integer]) – CSR indices array for chains to residues mapping.

Examples

>>> table = IndexTable.from_parents(
...     atom_to_res=np.array([0, 0, 1, 1, 2]),
...     res_to_chain=np.array([0, 0, 1]),
... )

>>> table.atoms_to_residues(np.array([0, 2, 4]))
array([0, 1, 2])

>>> table.residues_to_chains(np.array([0, 2]))
array([0, 1])

>>> table.chains_to_residues(np.array([0, 1]))
array([0, 1, 2])

Attributes

atom_to_res

1D array mapping each atom index to its parent residue index.

res_to_chain

1D array mapping each residue index to its parent chain index.

res_atom_indptr

CSR index pointer array for residues to atoms mapping.

res_atom_indices

CSR indices array for residues to atoms mapping.

chain_res_indptr

CSR index pointer array for chains to residues mapping.

chain_res_indices

CSR indices array for chains to residues mapping.

Methods

atoms_to_chains

Map atom indices to chain indices.

atoms_to_residues

Map atom indices to residue indices.

chains_to_atoms

Map chain indices to concatenated atom indices.

chains_to_residues

Map chain indices to concatenated residue indices.

convert

Convert indices between structural levels.

copy

Create a deep copy of the IndexTable.

from_dict

Create IndexTable from a dictionary.

from_parents

Create IndexTable from forward parent mappings.

residues_to_atoms

Map residue indices to concatenated atom indices.

residues_to_chains

Map residue indices to chain indices.

to_dict

Convert IndexTable to a JSON-serializable dictionary.