Expand description
A batteries-included structural bioinformatics engine.
This crate is the composition layer, and it is the whole 1.0 contract: what
is reachable from the root or from prelude is curated and stable, and
everything else — the raw storage engine — lives under engine,
documented there as the uncurated, lower-stability door. The default feature
set includes mmCIF and PDB; callers opt into analysis domains independently.
§What the root carries
The root namespace is curated, not a mirror of the workspace. It holds the
curated structure handles (Structure, Selection, StructureEditor,
the Chains/Residues/Atoms/Models collections), the reading and
writing verbs, and the policy and diagnostic vocabulary.
Everything else is module-only. molframe::analysis::hydrogen_bonds, never a
flat molframe::hydrogen_bonds; molframe::chemistry::vdw_radius, never
molframe::vdw_radius; molframe::interop::AtomTable, never
molframe::AtomTable. geometry, analysis, compare, sequence,
surface, validation, trajectory, crystal, motif, chemistry,
spatial, query, ic, interop, audit and adapters are all reached
that way, so the root stays a page a reader can hold. The four structure
formats live under formats.
§Reading, and saying what was wrong with the file
use molframe::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let (structure, findings) =
read_bytes(PDB.into(), Some("1abc.pdb"), &ReadOptions::new())?;
println!("{} atoms in {} chains", structure.atom_count(), structure.chain_count());
for finding in &findings {
eprintln!("{}", Rendered::new(finding));
}
Ok(())
}read_with_diagnostics is the honest form and is what a pipeline should
use: the findings say what was wrong with the file, and a file that parses is
not the same as a file that is right. read discards them for convenience.
Both return Findings, which is an Error — hence the
? above, and hence anyhow::Result or Box<dyn Error> at a main without
a match anywhere.
§Navigating and editing
use molframe::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let (structure, _) = read_bytes(PDB.into(), Some("1abc.pdb"), &ReadOptions::new())?;
for chain in structure.chains() {
println!("chain {:?}: {} residues", chain.label(), chain.residues().count());
}
let mut editor = structure.edit();
editor
.rename_chain(molframe::ChainIndex::new(0), "B")
.map_err(Findings::from)?;
let renamed = editor.finish().map_err(Findings::from)?;
assert_eq!(renamed.chain_at(0).and_then(|chain| chain.label()), Some("B"));
Ok(())
}§Examples are owed, not owed everywhere
The in-memory paths above run as doctests. The remaining public items follow the reference documentation of the crate that owns them rather than repeating it here; the rule that every public item carry an example is not yet met for the facade’s format writers, which is a known debt.
Re-exports§
pub use molframe_chem as chemistry;pub use molframe_spatial as spatial;pub use molframe_query as query;
Modules§
- engine
- The uncurated, low-level door onto the storage engine.
- formats
- The structure formats, grouped by the crate that reads and writes them.
- prelude
- The names most programs want in scope.
Structs§
- Aabb
- An axis-aligned bounding box.
- Algorithm
Id - Stable name and version of the algorithm that produced a result.
- AltId
- An alternate-location label.
- Analysis
- An outcome, and everything needed to judge it.
- Analysis
Policy - Every semantic decision an analysis depends on.
- Anisotropic
Displacement - One anisotropic displacement ellipsoid before it is packed into columns.
- Anisotropy
Index - Position of an anisotropic displacement row in the anisotropy table.
- Anisotropy
Table - A compact, immutable anisotropic displacement table sorted by atom.
- Anisotropy
Table Builder - Deterministic anisotropy-table construction with atom deduplication.
- Annotation
Column - One immutable typed annotation column with three-state validity.
- Application
Configuration - Strict top-level configuration shared by library-backed applications.
- Assumption
- One decision made on the caller’s behalf.
- Atom
Annotations - Custom per-atom columns, ordered by name for deterministic iteration.
- Atom
Index - Position of an atom row in the structure’s flat atom order.
- AtomRef
- One atom.
- Atoms
- Every atom of a structure, in structure order.
- Atoms
Iter - Every atom of a structure, in structure order.
- Batch
Continuity - Whether hierarchy rows continue across adjacent batches.
- Batch
Demand - Maximum work a consumer is prepared to accept from one pull.
- Batch
Lease - A batch whose retained bytes are charged to an execution context.
- Bond
Adjacency - A compressed sparse row view of an undirected bond graph.
- Bond
Index - Position of a bond in the bond table.
- Bond
Inference - Parameters for explicitly requested geometric bond inference.
- Bond
Inference Report - A new connectivity snapshot and atoms lacking a covalent radius.
- Bond
Record - One bond before it is packed into columns.
- Bond
Table - A compact, immutable edge table.
- Bond
Table Builder - Deterministic bond-table construction with endpoint deduplication.
- Byte
Span - A half-open byte range within a source file, with the start’s line and column.
- Cancellation
Token - A cheap, thread-safe cooperative cancellation handle.
- Chain
Index - Position of a chain in the chain table.
- Chain
Ref - One chain.
- Chains
- Every chain of a structure, in structure order.
- Chains
Iter - Every chain of a structure, in structure order.
- Chemistry
Configuration - Explicit chemistry resources; merely loading configuration performs no I/O.
- Code
- A stable diagnostic code, rendered as
MOLFRAME-E1103orMOLFRAME-W3011. - Compiled
Workflow - A validated, optimized workflow reusable across input sets.
- Completion
Item - One supported completion candidate.
- Completion
Result - Completion response with a byte-addressed replacement range.
- Context
Item - A named piece of supporting detail attached to a finding.
- Coordinate
Editor - A private coordinate copy that becomes a new structure only on commit.
- Coordinate
Sample - A topology-aligned linear sample of two retained coordinate columns. Periodic reconstruction and alignment belong to the caller before sampling.
- Coverage
- How much of what an analysis meant to use it actually used.
- Diagnostic
- One finding about the data.
- Diagnostics
- A growing list of findings that keeps itself in reproducible order.
- Dictionary
Version - The version of a body of reference data.
- Element
- A chemical element, represented by its atomic number.
- Entity
Index - Position of an entity in the entity table.
- Entry
Metadata - What the entry as a whole says about itself.
- Execution
Context - Shared controls passed through every stage of an out-of-core operation.
- Explanation
- Logical and physical views of a compiled workflow.
- Extension
Store - Cold, typed metadata owned by a structure snapshot.
- Findings
- The findings an operation produced, as a finished set.
- Fingerprint
- A fast, stable 64-bit fingerprint of a policy, a record or a cache entry.
- Input
Buffer - Bytes to read, however they were obtained.
- Instance
Id - Identifier of one generated copy of an assembly’s contents.
- Limits
- Ceilings that turn hostile input into diagnostics rather than exhaustion.
- Measured
Impact - The measured effect of one decision on one analysis.
- Memory
Budget - A validated upper bound for memory retained by one execution context.
- Metadata
Difference - Entry-level metadata changes.
- Missing
Residue - One canonical residue absent from the observed structure.
- Model
Index - Position of a model in the model table.
- Model
Ref - One model of a structure.
- Models
- Every model of a structure.
- Models
Iter - Every model of a structure, in structure order.
- Node
- A typed immutable expression node.
- Operation
Metadata - Static information used by compilation, explanation and memory admission.
- Output
- A typed named workflow output handle.
- Output
Configuration - Output preferences that an application may apply before explicit flags.
- Output
Options - Working-memory policy for incremental output.
- Physical
Node - One node in a compiled physical explanation.
- Policy
Overrides - String vocabulary accepted by policy files and command-line overrides.
- Policy
Parse Error - A named choice (a policy decision, a spatial backend, a file format) was spelled with a word outside its vocabulary.
- Position
- A point in a source file.
- Profile
Id - The name and version of a policy profile.
- Provenance
- Everything needed to reproduce a result.
- Query
- A parsed and reusable selection plan.
- Query
Aliases - An ordered set of named query definitions.
- Query
Fingerprint - Stable identity of a normalized molecular query.
- Read
Options - What a read should and should not bother doing.
- Reference
Alignment - One canonical-to-reference interval from
_struct_ref_seq. - Reference
Sequence - One database sequence named by
_struct_ref. - Rendered
- A finding prepared for display.
- Residue
Index - Position of a residue in the residue table.
- Residue
Ref - One residue.
- Residues
- Every residue of a structure, in structure order.
- Residues
Iter - Every residue of a structure, in structure order.
- Scratch
Policy - Upper bound for reusable in-memory scratch owned by one stage.
- Secondary
Assignment - One residue’s state together with where it came from.
- Select
All - A filter that writes everything.
- Selection
- A zero-copy subset of a
Structure’s atoms. - Sequence
Mapping - One observed residue’s correspondence across sequence namespaces.
- Sequence
References - Typed reference sequence metadata attached to a structure.
- Structure
- An immutable structure snapshot.
- Structure
Atom Record - One atom row accepted by
StructureBatchBuilder. - Structure
Batch - Bounded structure rows in a format-neutral layout.
- Structure
Batch Builder - Incremental builder that interns each distinct identifier once per batch.
- Structure
Difference - Complete semantic difference summary for two normalised structures.
- Structure
Difference Options - Explicit controls for semantic structure comparison.
- Structure
Editor - A transactional structural edit, scoped to one snapshot.
- Symbol
Id - An interned identifier.
- Tolerance
- How close two floating-point values must be to count as equal.
- Topology
- The whole hierarchy.
- Unit
Cell - The crystallographic cell.
- Value
Difference - A value before and after a semantic change.
- Workflow
- A symbolic computation graph under construction.
- Workflow
Inputs - Owned values supplied to a compiled workflow by input name.
- Workflow
Results - Named, owner-backed values returned by one workflow execution.
- Write
Options - The decisions a write makes: which identifiers the projection invents, per format family, plus the output working-memory policy.
Enums§
- Alignment
Policy - How two structures are put into correspondence before comparison.
- Altloc
Policy - How to resolve alternate conformations.
- Ambiguous
Residue Boundary Policy - Policy for adjacent mmCIF atom groups whose residue identifiers are identical.
- Assembly
Choice - Which arrangement of the contents to analyse.
- Assumption
Source - Where a decision came from.
- Atom
Annotation - The supported physical types for a custom atom annotation.
- Backpressure
- Outcome of one non-blocking batch pull.
- Bond
Order - The chemical order assigned to a bond.
- Bond
Provenance - Where a bond assignment came from.
- Category
Filter - Which optional categories (mmCIF/BinaryCIF) or records (PDB) a read keeps.
- Class
- The class of problem a code’s leading digit names.
- Completion
Kind - The category of a completion item.
- Compression
- How a stream of bytes was compressed.
- Contact
Definition - What counts as a contact.
- Context
Error - Inconsistent execution policies supplied to a context builder.
- Continuity
Level - Deepest hierarchy level that continues across one batch boundary.
- Coordinate
Sample Error - Invalid coordinate-sample metadata.
- Cost
- The data-movement cost attached to an input or operation.
- Difference
Error - Why a structure comparison could not be performed.
- Entity
Kind - What kind of chemical species an entity is.
- Equivalence
Policy - How two atoms are decided to correspond.
- Format
- A format molframe can read or write.
- Hydrogen
Policy - How hydrogens enter a calculation.
- Impact
- How much a decision changed the answer, where that is known.
- Indeterminacy
- Why no defensible answer exists under a policy.
- Input
Digest - Whether a read records a digest of the bytes it parsed.
- Input
Kind - The storage that backs an input byte slice.
- Kind
- Whether a code denotes a failure or an observation.
- Memory
Budget Error - Failure to construct or reserve an execution-memory budget.
- Missing
Element Policy - Policy for atom rows whose format-specific element field is absent or invalid.
- Missing
Policy - What to do about atoms a component should have but the model does not.
- Model
Choice - Which model to analyse.
- Namespace
- Which identifier namespace an unqualified selector means.
- Occupancy
Policy - Policy for atoms whose recorded occupancy lies outside zero to one.
- Outcome
- A value, or the reason there is none.
- Parameter
Value - A typed, deterministic result-affecting algorithm parameter.
- Parse
Mode - How much irregularity a read tolerates, and what it does about it.
- Perception
- Whether a read infers bonds, components and secondary structure afterwards.
- Periodic
Policy - How periodic boundaries are handled.
- Plddt
Band - One of the four pLDDT confidence bands.
- Policy
Config Error - Failure while loading a declarative analysis policy.
- Policy
Field - Which field of a policy something refers to.
- Polymer
Kind - What kind of polymer a chain is, where it is one.
- Precision
- The width accumulation runs at.
- Presence
- What a column says about one position.
- Quality
- How complete a determinate answer is.
- Radii
Set - Which published set of van der Waals radii to use.
- Secondary
Source - Where a residue’s secondary-structure state came from.
- Secondary
Structure - A residue-level structural assignment, in the DSSP vocabulary.
- Severity
- How bad a finding is, independent of how the caller wants to react.
- Source
Ref - Where an input came from.
- Status
- How far an analysis got.
- Strictness
- How much irregularity the caller is willing to accept.
- Structure
Batch Error - Failure shared by bounded structural batch readers and collectors.
- Structure
Batch Reader - One linked structural batch reader selected by content or explicit format.
- Symmetry
Policy - Whether symmetry copies participate.
- Temp
Storage Policy - Policy controlling whether and where execution may spill temporary data.
- Workflow
Build Error - Graph-construction errors detected before compilation.
- Workflow
Error - Workflow compilation or execution failure.
Constants§
- AROMATIC_
ATOM_ ANNOTATION - Aromatic-atom flag assigned from a chemical component definition.
- ATOM_
RADIUS_ ANNOTATION - Conventional custom column name for per-atom PQR radii.
- AUTODOCK_
TYPE_ ANNOTATION - Conventional custom column name for
AutoDockatom types. - COMPONENT_
KIND_ ANNOTATION - Component role assigned from a chemical component definition.
- DEFAULT_
BOND_ RADIUS_ SCALE - Default multiplier applied to the sum of two CCD covalent radii.
- DEFAULT_
MINIMUM_ BOND_ DISTANCE - Default minimum accepted interatomic distance in angstroms.
- FORMAL_
CHARGE_ ANNOTATION - Formal charge assigned from a chemical component definition.
- HBOND_
ACCEPTOR_ ANNOTATION - Hydrogen-bond acceptor role perceived from CCD connectivity and protonation.
- HBOND_
DONOR_ ANNOTATION - Hydrogen-bond donor role perceived from CCD connectivity and protonation.
- INSTANCE_
ID_ ANNOTATION - Per-atom stable identifier of the materialised chain copy an atom belongs to.
- MISSING_
BAND_ CODE - Code written for an atom that has no recorded score.
- PAE_
ANNOTATION - Conventional custom column name for per-atom predicted aligned error.
- PARTIAL_
CHARGE_ ANNOTATION - Conventional custom column name for partial atomic charge.
- PLDDT_
ANNOTATION - Conventional custom column name for per-atom predicted confidence.
- POLYMER_
ATOM_ ROLE_ ANNOTATION - Explicit polymer atom role assigned from a CCD-aware or caller-supplied profile.
- SEGMENT_
ID_ ANNOTATION - Conventional custom column name for atom segment identifiers.
- SEQUENCE_
REFERENCES_ EXTENSION - Stable extension key for database sequence references and alignments.
- STEREO_
CONFIGURATION_ ANNOTATION - Modelled stereochemical configuration anchored to component coordinates.
Traits§
- Batch
Source - A pull source whose live workspace is governed by an
ExecutionContext. - Chain
Sequence Ext - Sequence views carried by a hierarchy chain handle.
- Query
Structure - Selection methods implemented by immutable structure snapshots.
- Reader
- A reader for one format.
- Select
- Which parts of a structure a write should include.
- Structure
Values - Lent, structure-derived completion values.
Functions§
- altloc_
compatible - Whether two atoms with these alternate labels can be present together.
- collect_
structure - Materialises a bounded snapshot from a structural batch source.
- complete
- Computes completion using a UTF-8 byte cursor.
- infer_
bonds - Infers bonds by covalent-radius distance using the shared spatial planner.
- open_
component_ dictionary - Opens a Chemical Component Dictionary that lowers components on demand.
- open_
structure_ batches - Opens a structural file without reserving memory proportional to file size.
- perceive
- Applies the default chemistry perception pass to a caller-created structure.
- perceive_
in perceiveon the worker budget ofcontext.- read
- Reads a structure, discarding what was wrong with the file.
- read_
buffer - Reads a structure from an already-acquired buffer, without a further copy.
- read_
buffer_ in read_bufferon the budgets ofcontext.- read_
bytes - Reads a structure from bytes already in hand.
- read_
bytes_ in read_byteson the budgets ofcontext.- read_
component_ dictionary - Reads a Chemical Component Dictionary file as a versioned provider.
- read_
configuration - Loads a strict application configuration without accessing referenced resources.
- read_
document - Reads a document, preserving everything the file held.
- read_
policy - Loads and validates a complete policy document from JSON or TOML.
- read_
with_ diagnostics - Reads a structure and everything that was wrong with the file it came from.
- read_
with_ options - Reads a structure under explicit options.
- read_
with_ options_ in read_with_optionson the worker budget, memory budget and cancellation ofcontext.- structure_
difference - Reports how two snapshots differ.
- write
- Writes a structure in the format named by the destination.
- write_
as - As
write_with_options, in the stated format instead of the one the destination’s name selects. A.gzor.zstsuffix still applies its compression. - write_
mmcif - Renders a structure as valid, self-consistent mmCIF in memory.
- write_
mmcif_ with_ findings - Renders mmCIF like
write_mmcif_with_optionsand also reports what the write rewrote or could not carry. - write_
mmcif_ with_ options - Renders mmCIF in memory with explicit identifier decisions.
- write_
pdb - Writes a structure in the legacy fixed-column format, or explains why it cannot be written.
- write_
pdb_ with_ findings - Writes a structure like
write_pdband also reports what the format could not carry. - write_
pdbqt_ with_ findings - Writes a rigid PDBQT model and reports what the format could not carry.
- write_
pqr_ with_ findings - Writes PQR and reports what the format could not carry.
- write_
with_ options - Streams a structure under explicit projection and memory decisions.
Type Aliases§
- Analysis
Parameters - Sorted algorithm parameters that participate in provenance fingerprints.
- Count
Difference - A row count before and after a structural change.
- Input
- A typed named workflow input.
- Read
Result - A structure and everything that was wrong with the file it came from.