pub struct TopologyColumns { /* private fields */ }Expand description
Boundary-ready, frame-independent topology columns.
Built once per Arc<AtomicHierarchy> and reused for every frame that shares
it (see Self::frame). Columns whose in-memory representation is already
a plain numeric array (sequence ids, segment offsets, bonds) are borrowed
from the hierarchy; everything else is encoded into owned buffers:
| Column | Type | Encoding |
|---|---|---|
atom.element | u8 | atomic number |
atom.alt_loc | u32 | Unicode scalar, NO_ALT_LOC if absent |
atom.formal_charge | i8 | charge, NO_FORMAL_CHARGE if absent |
residue.ins_code | u32 | Unicode scalar, NO_INS_CODE if absent |
residue.group | u8 | RESIDUE_GROUP_POLYMER / RESIDUE_GROUP_NON_POLYMER |
residue.label_seq_id | i32 | MISSING_SEQ_ID if absent |
| string fields | u32 codes | StringDictionary |
§Ownership and invalidation
The snapshot holds a clone of the Arc<AtomicHierarchy> it was built from.
While it is alive, that hierarchy cannot be mutated in place: Arc::get_mut
fails and Arc::make_mut clones. So the snapshot never silently goes out of
date — a model whose hierarchy was replaced or copied-on-write simply stops
matching, which Self::is_current_for and Self::frame detect by
pointer identity.
Implementations§
Source§impl TopologyColumns
impl TopologyColumns
Sourcepub fn encode(hierarchy: &Arc<AtomicHierarchy>) -> Result<Self, BoundaryError>
pub fn encode(hierarchy: &Arc<AtomicHierarchy>) -> Result<Self, BoundaryError>
Validate hierarchy and encode its columns.
Sourcepub fn from_model(model: &Model) -> Result<Self, BoundaryError>
pub fn from_model(model: &Model) -> Result<Self, BoundaryError>
Encode the topology of model.
Sourcepub fn hierarchy(&self) -> &Arc<AtomicHierarchy> ⓘ
pub fn hierarchy(&self) -> &Arc<AtomicHierarchy> ⓘ
The hierarchy this snapshot was built from (and keeps alive).
Sourcepub fn is_current_for(&self, model: &Model) -> bool
pub fn is_current_for(&self, model: &Model) -> bool
Whether model still uses the exact hierarchy this snapshot describes.
Sourcepub fn frame<'m>(
&self,
model: &'m Model,
) -> Result<FrameColumns<'m>, BoundaryError>
pub fn frame<'m>( &self, model: &'m Model, ) -> Result<FrameColumns<'m>, BoundaryError>
Borrow the per-frame columns of model, checking it shares this topology.
Fails with StaleTopology if it does not.
Sourcepub fn n_residues(&self) -> u32
pub fn n_residues(&self) -> u32
Number of residues.
Sourcepub fn atom_name(&self) -> &StringDictionary
pub fn atom_name(&self) -> &StringDictionary
atom.name (label_atom_id).
Sourcepub fn auth_atom_name(&self) -> &StringDictionary
pub fn auth_atom_name(&self) -> &StringDictionary
atom.auth_name (auth_atom_id).
Sourcepub fn alt_loc(&self) -> &[u32]
pub fn alt_loc(&self) -> &[u32]
atom.alt_loc as Unicode scalars (NO_ALT_LOC if absent).
Sourcepub fn formal_charge(&self) -> &[i8]
pub fn formal_charge(&self) -> &[i8]
atom.formal_charge (NO_FORMAL_CHARGE if absent).
Sourcepub fn comp_id(&self) -> &StringDictionary
pub fn comp_id(&self) -> &StringDictionary
residue.comp_id (label_comp_id).
Sourcepub fn auth_comp_id(&self) -> &StringDictionary
pub fn auth_comp_id(&self) -> &StringDictionary
residue.auth_comp_id.
Sourcepub fn label_seq_id(&self) -> &[i32]
pub fn label_seq_id(&self) -> &[i32]
residue.label_seq_id (borrowed from the hierarchy).
Sourcepub fn auth_seq_id(&self) -> &[i32]
pub fn auth_seq_id(&self) -> &[i32]
residue.auth_seq_id (borrowed from the hierarchy).
Sourcepub fn ins_code(&self) -> &[u32]
pub fn ins_code(&self) -> &[u32]
residue.ins_code as Unicode scalars (NO_INS_CODE if absent).
Sourcepub fn residue_group(&self) -> &[u8] ⓘ
pub fn residue_group(&self) -> &[u8] ⓘ
residue.group codes.
Sourcepub fn label_asym_id(&self) -> &StringDictionary
pub fn label_asym_id(&self) -> &StringDictionary
chain.label_asym_id.
Sourcepub fn auth_asym_id(&self) -> &StringDictionary
pub fn auth_asym_id(&self) -> &StringDictionary
chain.auth_asym_id.
Sourcepub fn entity_id(&self) -> &StringDictionary
pub fn entity_id(&self) -> &StringDictionary
chain.entity_id.
Sourcepub fn residue_atom_offsets(&self) -> &[u32]
pub fn residue_atom_offsets(&self) -> &[u32]
CSR offsets grouping atoms into residues (n_residues + 1 entries).
Sourcepub fn chain_residue_offsets(&self) -> &[u32]
pub fn chain_residue_offsets(&self) -> &[u32]
CSR offsets grouping residues into chains (n_chains + 1 entries).
Sourcepub fn bond_atom_a(&self) -> &[u32]
pub fn bond_atom_a(&self) -> &[u32]
First atom of each bond, sorted ascending.
Sourcepub fn bond_atom_b(&self) -> &[u32]
pub fn bond_atom_b(&self) -> &[u32]
Second atom of each bond.
Sourcepub fn bond_order(&self) -> &[u8] ⓘ
pub fn bond_order(&self) -> &[u8] ⓘ
Bond order of each bond.
Sourcepub fn atom_bond_offsets(&self) -> &[u32]
pub fn atom_bond_offsets(&self) -> &[u32]
CSR offsets grouping bonds by atom_a (n_atoms + 1 entries).
Sourcepub fn columns(&self) -> Vec<Column<'_>>
pub fn columns(&self) -> Vec<Column<'_>>
Every numeric topology column, including dictionary codes, by stable name.
Dictionary value tables are not listed; fetch them from the matching
StringDictionary accessor.
Sourcepub fn bond_line_indices(&self) -> GpuBuffer<'static>
pub fn bond_line_indices(&self) -> GpuBuffer<'static>
Bonds as an interleaved [atom_a, atom_b] u32 index buffer, ready to
use as a GPU line-list index buffer. Always an owned copy.
Sourcepub fn residue_of(
&self,
atom: AtomHandle,
) -> Result<ResidueHandle, BoundaryError>
pub fn residue_of( &self, atom: AtomHandle, ) -> Result<ResidueHandle, BoundaryError>
Residue containing atom.
Sourcepub fn chain_of(
&self,
residue: ResidueHandle,
) -> Result<ChainHandle, BoundaryError>
pub fn chain_of( &self, residue: ResidueHandle, ) -> Result<ChainHandle, BoundaryError>
Chain containing residue.
Sourcepub fn atoms_of(
&self,
residue: ResidueHandle,
) -> Result<Range<u32>, BoundaryError>
pub fn atoms_of( &self, residue: ResidueHandle, ) -> Result<Range<u32>, BoundaryError>
Atom rows belonging to residue.
Sourcepub fn residues_of(
&self,
chain: ChainHandle,
) -> Result<Range<u32>, BoundaryError>
pub fn residues_of( &self, chain: ChainHandle, ) -> Result<Range<u32>, BoundaryError>
Residue rows belonging to chain.
Trait Implementations§
Source§impl Clone for TopologyColumns
impl Clone for TopologyColumns
Source§fn clone(&self) -> TopologyColumns
fn clone(&self) -> TopologyColumns
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TopologyColumns
impl RefUnwindSafe for TopologyColumns
impl Send for TopologyColumns
impl Sync for TopologyColumns
impl Unpin for TopologyColumns
impl UnsafeUnpin for TopologyColumns
impl UnwindSafe for TopologyColumns
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more