Skip to main content

Module script

Module script 

Source
Expand description

Script loader: parse molpack’s .inp input format and turn it into a configured Molpack plus a list of Targets.

Two front-end shapes are supported:

  • Native (feature io) — [Script::build] reads template files via molrs-io and returns a ready-to-run [BuildResult]:

    use std::path::Path;
    use molpack::script;
    
    let src = std::fs::read_to_string("mixture.inp")?;
    let script = script::parse(&src)?;
    let built = script.build(Path::new("."))?;
    
    let frame = built.packer.pack(&built.targets, built.nloop)?;
    script::write_frame(&built.output, &frame)?;
  • Embedding hosts (any feature set)Script::lower returns a ScriptPlan with file paths resolved but unread. The caller loads each StructurePlan::filepath with its own frame loader, builds a Target, and stamps restraints via StructurePlan::apply. This is what the PyO3 wheel uses, so it does not have to statically link molrs-io.

Parsing, lowering, and I/O are kept separate so embedders can intercept any stage — e.g. mutate the parsed Script before lower, attach a custom Handler to the packer, or route output through a different writer.

Structs§

AtomGroup
One atoms … end atoms sub-block.
PbcSpec
Periodic-boundary box declared at the top level via pbc.
Script
A fully parsed packing script.
ScriptPlan
Loader-agnostic lowering of a Script: paths resolved, restraints kept as parsed RestraintSpecs, no filesystem access yet.
Structure
One structure … end structure block.
StructurePlan
Per-structure lowering: resolved file path plus the restraints / pose hints that apply to its Target.

Enums§

RestraintSpec
AtomRestraint as it appears in the script, before being mapped to a concrete AtomRestraint implementation.
ScriptError
Errors produced by the script module — from parsing, file loading, or the downstream pack() call invoked by a script-driven run.

Functions§

parse
Parse a script from its textual source.