Skip to main content

Structure

Struct Structure 

Source
pub struct Structure(/* private fields */);
Expand description

An immutable structure, shared by reference.

Cloning one is a reference count, not a copy, so passing a structure to another thread or holding several versions at once is cheap.

§Examples

use molframe_core::structure::{Structure, StructureData};

let structure = Structure::new(StructureData::empty());
assert_eq!(structure.atom_count(), 0);
assert_eq!(structure.model_count(), 1);

Implementations§

Source§

impl Structure

Source

pub fn new(data: StructureData) -> Self

Wraps structure data for sharing.

Source

pub fn with_input( self, name: Option<Box<str>>, digest: Option<ContentDigest>, ) -> Self

Returns this structure recording the input it was read from.

The digest is of the bytes the reader parsed, after any decompression.

Source

pub fn data(&self) -> &StructureData

The data behind the reference.

Source

pub fn shared(&self) -> Arc<StructureData> ⓘ

The shared handle, for a view that must outlive this reference.

Source

pub fn atom_count(&self) -> u32

The number of atoms in one model.

Source

pub fn atom(&self, atom: AtomIndex) -> Option<AtomRef<'_>>

A lightweight handle on one atom.

Source

pub fn model(&self, model: ModelIndex) -> Option<ModelRef<'_>>

A lightweight handle on one model.

Source

pub fn model_snapshot(&self, model: ModelIndex) -> Option<(Self, ModelIndex)>

The structure and local model position that represent one model.

Dense models share this structure and retain their position. Ragged models are independent single-model structures, so their local position is zero. This keeps callers from padding unlike topologies.

Source

pub fn chain(&self, chain: ChainIndex) -> Option<ChainRef<'_>>

A lightweight handle on one chain.

Source

pub fn residue(&self, residue: ResidueIndex) -> Option<ResidueRef<'_>>

A lightweight handle on one residue.

Source

pub fn model_count(&self) -> usize

The number of models.

Source

pub fn ragged_models(&self) -> Option<&[Self]>

The independent model structures when topology differs between models.

Source

pub fn chain_count(&self) -> usize

The number of chains.

Source

pub fn residue_count(&self) -> usize

The number of residues.

Source

pub fn entity_count(&self) -> usize

The number of distinct chemical species.

Source

pub fn positions(&self) -> &[[f32; 3]]

The positions of the first model, contiguously.

This slice is the buffer itself, not a copy of it, which is what makes handing coordinates to a numeric array free.

Source

pub fn model_positions(&self, model: ModelIndex) -> Option<&[[f32; 3]]>

The positions of one model.

Source

pub fn generation(&self) -> CoordinateGeneration

How many times the positions have changed.

Source

pub fn annotations(&self) -> &AtomAnnotations

Structure-local typed columns aligned to atom rows.

Source

pub fn secondary_structure(&self) -> &[SecondaryStructure]

Secondary-structure assignments aligned to residue rows.

Source

pub fn secondary_source(&self) -> &[SecondarySource]

Where each residue’s secondary-structure state came from, aligned to Self::secondary_structure.

Source

pub fn extensions(&self) -> &ExtensionStore

Cold, typed domain metadata attached to this snapshot.

Source

pub fn with_extension<T>(&self, key: &'static str, value: T) -> Self
where T: Any + Send + Sync + RefUnwindSafe,

Returns a new snapshot with one typed domain extension attached.

Source

pub fn without_extensions(&self) -> Self

Returns a new snapshot without domain extensions.

Source

pub fn resolve(&self, symbol: SymbolId) -> Option<&str>

The string an interned identifier names.

Source§

impl Structure

Source

pub fn resolve_altlocs( &self, policy: &AnalysisPolicy, ) -> Analysis<AtomSelection>

Selects atom rows under the policy’s alternate-conformation rule.

Blank-labelled atoms are retained under every rule because they belong to every conformation. The stored structure is never changed.

§Panics

This function does not intentionally panic when an internal selector reports an impossible cardinality; such a result is returned as an indeterminate analysis instead.

Source§

impl Structure

Source

pub fn resolved_atoms( &self, policy: &AnalysisPolicy, ) -> Result<(AtomSelection, Vec<Diagnostic>), Diagnostic>

The atoms an altloc policy selects, with the findings that came with them.

For callers that cannot do anything with a refusal: it becomes the diagnostic that explains it. Code that can carry an indeterminate result should use Structure::resolve_altlocs and keep the outcome.

§Errors

Returns the first finding, or Code::E3001, when the policy selects no consistent set of atoms.

Source§

impl Structure

Source

pub fn edit_coordinates( &self, context: &ExecutionContext, ) -> Result<CoordinateEditor, MemoryBudgetError>

Starts a scoped coordinate edit under the shared execution account.

Coordinate storage is copied for the new snapshot; topology and atom annotations remain untouched. Call CoordinateEditor::commit to validate and publish the new snapshot. Shared topology remains borrowed. Direct coordinate frames detach under the supplied account, and their reservations follow the copied backing buffers through committed snapshots and clones.

§Errors

Returns before publishing an editor when all coordinate copies cannot fit.

Source§

impl Structure

Source

pub fn merge(structures: &[Self]) -> Result<Self, Vec<Diagnostic>>

Concatenates compatible structures into one immutable system.

Atom, residue, chain and entity order follows input order. Dense inputs must have equal frame counts; their corresponding frames are concatenated. Dictionary identifiers, bonds and symbolic annotations are remapped rather than compared by structure-local integer value.

§Errors

Returns diagnostics for invalid inputs, ragged or unequal model axes, incompatible same-named annotation types, or representational overflow.

Source§

impl Structure

Source

pub fn edit(&self) -> StructureEditor

Starts a transactional structural edit.

Source

pub fn materialize( &self, selection: &AtomSelection, ) -> Result<Structure, Vec<Diagnostic>>

Copies a selected atom set into a compact, independent structure.

Empty residues, chains and unreferenced entities are removed. Secondary states and their provenance follow the retained residue rows; unavailable columns stay unavailable. Dense frames share the compacted hierarchy. Bonds retain their order and provenance when both endpoints survive. Domain extensions are discarded because their topology-aligned contents cannot remain valid after materialisation.

§Errors

Returns diagnostics for an out-of-range atom, a ragged ensemble, or an invalid source hierarchy.

Source§

impl Structure

Source

pub fn view(&self) -> StructureView

A view of every atom.

Source

pub fn view_of(&self, selection: AtomSelection) -> StructureView

A view of the atoms in selection.

Trait Implementations§

Source§

impl Clone for Structure

Source§

fn clone(&self) -> Self

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 Structure

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Structure

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<StructureData> for Structure

Source§

fn from(data: StructureData) -> Self

Converts to this type from the input type.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.