Skip to main content

TopologyColumns

Struct TopologyColumns 

Source
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:

ColumnTypeEncoding
atom.elementu8atomic number
atom.alt_locu32Unicode scalar, NO_ALT_LOC if absent
atom.formal_chargei8charge, NO_FORMAL_CHARGE if absent
residue.ins_codeu32Unicode scalar, NO_INS_CODE if absent
residue.groupu8RESIDUE_GROUP_POLYMER / RESIDUE_GROUP_NON_POLYMER
residue.label_seq_idi32MISSING_SEQ_ID if absent
string fieldsu32 codesStringDictionary

§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

Source

pub fn encode(hierarchy: &Arc<AtomicHierarchy>) -> Result<Self, BoundaryError>

Validate hierarchy and encode its columns.

Source

pub fn from_model(model: &Model) -> Result<Self, BoundaryError>

Encode the topology of model.

Source

pub fn hierarchy(&self) -> &Arc<AtomicHierarchy> ⓘ

The hierarchy this snapshot was built from (and keeps alive).

Source

pub fn is_current_for(&self, model: &Model) -> bool

Whether model still uses the exact hierarchy this snapshot describes.

Source

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.

Source

pub fn n_atoms(&self) -> u32

Number of atoms.

Source

pub fn n_residues(&self) -> u32

Number of residues.

Source

pub fn n_chains(&self) -> u32

Number of chains.

Source

pub fn n_bonds(&self) -> u32

Number of bonds.

Source

pub fn atom_name(&self) -> &StringDictionary

atom.name (label_atom_id).

Source

pub fn auth_atom_name(&self) -> &StringDictionary

atom.auth_name (auth_atom_id).

Source

pub fn element(&self) -> &[u8] ⓘ

atom.element as atomic numbers.

Source

pub fn alt_loc(&self) -> &[u32]

atom.alt_loc as Unicode scalars (NO_ALT_LOC if absent).

Source

pub fn formal_charge(&self) -> &[i8]

atom.formal_charge (NO_FORMAL_CHARGE if absent).

Source

pub fn comp_id(&self) -> &StringDictionary

residue.comp_id (label_comp_id).

Source

pub fn auth_comp_id(&self) -> &StringDictionary

residue.auth_comp_id.

Source

pub fn label_seq_id(&self) -> &[i32]

residue.label_seq_id (borrowed from the hierarchy).

Source

pub fn auth_seq_id(&self) -> &[i32]

residue.auth_seq_id (borrowed from the hierarchy).

Source

pub fn ins_code(&self) -> &[u32]

residue.ins_code as Unicode scalars (NO_INS_CODE if absent).

Source

pub fn residue_group(&self) -> &[u8] ⓘ

residue.group codes.

Source

pub fn label_asym_id(&self) -> &StringDictionary

chain.label_asym_id.

Source

pub fn auth_asym_id(&self) -> &StringDictionary

chain.auth_asym_id.

Source

pub fn entity_id(&self) -> &StringDictionary

chain.entity_id.

Source

pub fn residue_atom_offsets(&self) -> &[u32]

CSR offsets grouping atoms into residues (n_residues + 1 entries).

Source

pub fn chain_residue_offsets(&self) -> &[u32]

CSR offsets grouping residues into chains (n_chains + 1 entries).

Source

pub fn bond_atom_a(&self) -> &[u32]

First atom of each bond, sorted ascending.

Source

pub fn bond_atom_b(&self) -> &[u32]

Second atom of each bond.

Source

pub fn bond_order(&self) -> &[u8] ⓘ

Bond order of each bond.

Source

pub fn atom_bond_offsets(&self) -> &[u32]

CSR offsets grouping bonds by atom_a (n_atoms + 1 entries).

Source

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.

Source

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.

Source

pub fn residue_of( &self, atom: AtomHandle, ) -> Result<ResidueHandle, BoundaryError>

Residue containing atom.

Source

pub fn chain_of( &self, residue: ResidueHandle, ) -> Result<ChainHandle, BoundaryError>

Chain containing residue.

Source

pub fn atoms_of( &self, residue: ResidueHandle, ) -> Result<Range<u32>, BoundaryError>

Atom rows belonging to residue.

Source

pub fn residues_of( &self, chain: ChainHandle, ) -> Result<Range<u32>, BoundaryError>

Residue rows belonging to chain.

Trait Implementations§

Source§

impl Clone for TopologyColumns

Source§

fn clone(&self) -> TopologyColumns

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TopologyColumns

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.