Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b3c4733
refactor(core): Change potentials module visibility to crate-level
TKanX Sep 6, 2025
ae0b5e1
refactor(core): Change sorting module visibility to crate-level
TKanX Sep 6, 2025
a105e1b
refactor(engine): Change OptimizationState visibility to crate-level
TKanX Sep 6, 2025
abf47a4
refactor(engine): Change ELCache visibility to crate-level
TKanX Sep 6, 2025
4544a21
refactor(engine): Change context module visibility to crate-level
TKanX Sep 6, 2025
d0d5609
refactor(engine): Change energy_grid module visibility to crate-level
TKanX Sep 6, 2025
60e17be
refactor(engine): Change transaction module visibility to crate-level
TKanX Sep 6, 2025
5db7a26
refactor(engine): Change placement module visibility to crate-level
TKanX Sep 6, 2025
51b1e66
refactor(engine): Change tasks module visibility to crate-level
TKanX Sep 6, 2025
617508f
refactor(engine): Change utils module visibility to crate-level
TKanX Sep 6, 2025
bb5a931
refactor(core): Change energy module visibility to crate-level
TKanX Sep 6, 2025
e97d7ac
docs(core): Add documentation and clarify atom role classifications
TKanX Sep 6, 2025
fd464a9
docs(core): Add documentation for ResidueType and Residue structs
TKanX Sep 6, 2025
f48de62
docs(core): Add documentation for ChainType and Chain structs
TKanX Sep 6, 2025
3e46f4f
docs(core): Add documentation for BondOrder and Bond structs
TKanX Sep 6, 2025
0bf1c64
docs(core): Add documentation for MolecularSystem struct and its methods
TKanX Sep 6, 2025
30d5028
docs(core): Add module documentation for core data models
TKanX Sep 6, 2025
0357bbf
docs(core): Add documentation for MolecularFile trait with additional…
TKanX Sep 6, 2025
f006c67
docs(core): Add documentation for BgfMetadata, BgfError, and BgfFile …
TKanX Sep 6, 2025
135fcd3
docs(core): Add documentation for CanonicalAtom struct and sorting fu…
TKanX Sep 6, 2025
628c0ff
docs(core): Add module documentation for sorting utilities
TKanX Sep 6, 2025
6e51f5e
docs(core): Add module documentation for molecular file I/O functiona…
TKanX Sep 6, 2025
1ebdd86
docs(core): Add documentation for potential energy functions in force…
TKanX Sep 6, 2025
f88c16f
docs(core): Add documentation for EnergyTerm struct and its methods
TKanX Sep 6, 2025
59c9bf2
docs(core): Add documentation for force field parameters and loading …
TKanX Sep 6, 2025
92758ec
docs(core): Add documentation for energy calculation methods and erro…
TKanX Sep 6, 2025
f592f15
docs(core): Add documentation for parameterization process and error …
TKanX Sep 6, 2025
a626c32
docs(core): Add documentation for scoring errors and energy calculati…
TKanX Sep 6, 2025
6d4d729
docs(core): Add documentation for the Force Field module, including u…
TKanX Sep 6, 2025
0ca3b5f
docs(core): Update documentation for the Force Field module by removi…
TKanX Sep 6, 2025
013ce7f
docs(core): Correct import path for Scorer in usage example of Force …
TKanX Sep 6, 2025
e10959b
docs(core): Add documentation for TopologyRegistry and ResidueTopolog…
TKanX Sep 6, 2025
eec2db8
docs(core): Enhance documentation for Input/Output module with compre…
TKanX Sep 6, 2025
ae60707
docs(core): Revise and expand documentation for Core Models module, e…
TKanX Sep 6, 2025
ff7aa0c
docs(core): Add detailed documentation for Topology module, including…
TKanX Sep 6, 2025
68cb860
docs(core): Enhance RotamerAtomData and RotamerData structs with addi…
TKanX Sep 6, 2025
d833e6b
docs(core): Expand documentation for RotamerLibrary and LibraryLoadEr…
TKanX Sep 6, 2025
b320955
docs(core): Add comprehensive documentation for Rotamers module, incl…
TKanX Sep 7, 2025
61cb420
docs(core): Add documentation for Core Module, detailing overview, ar…
TKanX Sep 7, 2025
daa623b
docs(engine): Enhance EngineError enum with additional error variants…
TKanX Sep 7, 2025
84b9f28
docs(engine): Expand configuration structs and enums with detailed do…
TKanX Sep 7, 2025
bbb2ad6
docs(engine): Add detailed documentation for OptimizationContext and …
TKanX Sep 7, 2025
7dda4ff
docs(engine): Add documentation for InitialState, SolutionState, and …
TKanX Sep 7, 2025
b14b02e
docs(engine): Add documentation for Progress enum and ProgressReporte…
TKanX Sep 7, 2025
cf9c3b1
docs(engine): Add documentation for ELCache struct methods and functi…
TKanX Sep 7, 2025
1bd922f
docs(engine): Add documentation for EnergyGrid and MoveDelta structs,…
TKanX Sep 7, 2025
809f5ee
docs(engine): Add documentation for SystemView struct, including new …
TKanX Sep 7, 2025
3c808b2
docs(engine): Add documentation for rotamer placement functions and e…
TKanX Sep 7, 2025
1257890
docs(engine): Documents Boltzmann sampling and errors
TKanX Sep 7, 2025
7370a36
docs(engine): Add documentation for sidechain and environment atom fu…
TKanX Sep 7, 2025
3bd3bf8
docs(engine): Add documentation for utility functions in the engine
TKanX Sep 7, 2025
860341b
docs(engine): Add documentation for ClashPair struct and clash detect…
TKanX Sep 7, 2025
347ba0c
docs(engine): Add documentation for doublet optimization and add erro…
TKanX Sep 7, 2025
5ce110f
docs(engine): Add documentation for EL energy computation functions a…
TKanX Sep 7, 2025
2526841
docs(engine): Add documentation for fixed energy calculations and fix…
TKanX Sep 7, 2025
7c6a82e
docs(engine): Add documentation for interaction energy calculation an…
TKanX Sep 7, 2025
ae54fa8
docs(engine): Add module documentation for tasks related to side-chai…
TKanX Sep 7, 2025
b69423e
docs(engine): Add module documentation with detailed architecture and…
TKanX Sep 7, 2025
4505cb1
docs(workflows): Add documentation for side-chain placement workflow …
TKanX Sep 7, 2025
d7bd861
docs(workflows): Add documentation for workflows module with detailed…
TKanX Sep 7, 2025
4378443
docs(project): Update module documentation to include architecture ov…
TKanX Sep 7, 2025
27c2f0f
docs(workflows): Clarify documentation for PlacementResult struct by …
TKanX Sep 7, 2025
e98be7b
docs(cli): Create comprehensive user manual for SCREAM++ CLI with set…
TKanX Sep 7, 2025
debb418
docs(cli): Add complete configuration file template for SCREAM++ CLI
TKanX Sep 7, 2025
f284447
ci(project): Include CLI usage documentation files in release artifacts
TKanX Sep 7, 2025
10014f3
docs(core): Enhance documentation for Residue struct to clarify cachi…
TKanX Sep 8, 2025
4f195e0
docs(project): Add foundational architecture and core data models doc…
TKanX Sep 8, 2025
9567b96
docs(project): Add detailed documentation for forcefield and energy c…
TKanX Sep 8, 2025
10caad8
docs(project): Add comprehensive documentation for algorithms and wor…
TKanX Sep 8, 2025
1c84878
docs(project): Add performance and memory optimization strategies doc…
TKanX Sep 8, 2025
18f1b4e
docs(project): Clarify energy update complexity explanation and enhan…
TKanX Sep 8, 2025
70deb41
docs(project): Add comprehensive developer documentation for scream-c…
TKanX Sep 8, 2025
854cd0a
docs(project): Revise developer documentation for clarity and structure
TKanX Sep 8, 2025
d80a73e
docs(cli): Add comprehensive developer documentation for scream-cli c…
TKanX Sep 8, 2025
34a5c88
docs(project): Enhance README with detailed usage instructions and fu…
TKanX Sep 8, 2025
27488ab
docs(project): Revise library documentation for clarity and architect…
TKanX Sep 8, 2025
15e36d9
docs(core): Enhance flat-bottom potential function documentation for …
TKanX Sep 8, 2025
6ff2eb5
docs(workflows): Improve documentation for side-chain placement workf…
TKanX Sep 8, 2025
a998be9
docs(engine): Enhance documentation for EnergyGrid struct to clarify …
TKanX Sep 8, 2025
22b1ccf
docs(engine): Improve documentation for SystemView struct to clarify …
TKanX Sep 8, 2025
fd8deb9
docs(cli): Clarify the importance of downloading data files as a mand…
TKanX Sep 8, 2025
842628a
docs(cli): Clarify note on s-factor optimization and rotamer library …
TKanX Sep 8, 2025
b980d9a
docs(cli): Update configuration file template for clarity and complet…
TKanX Sep 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
SOURCE_PATH="target/${{ matrix.target }}/release/$BINARY_NAME"

cp "$SOURCE_PATH" "$ARTIFACT_DIR/$BINARY_NAME"
cp LICENSE README.md "$ARTIFACT_DIR/"
cp LICENSE README.md docs/cli/USAGE.md docs/cli/config.template.toml "$ARTIFACT_DIR/"

cd $ARTIFACT_DIR

Expand Down
116 changes: 110 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,120 @@ The core mission of SCREAM++ is to provide a robust, reliable, and easy-to-use t
- **Flexible Optimization Modes**: Supports both global side-chain optimization and focused refinement within a defined **binding site** or region of interest.
- **Modern Tooling**: Managed by Cargo for simple, reproducible builds and dependency management.
- **Multiple Interfaces**:
- **Standalone CLI**: An easy-to-use command-line interface for standard prediction tasks.
- **Python Package**: A user-friendly Python API (via PyO3) for scripting, integration, and advanced workflows.
- **C-Compatible Library**: A C FFI layer for integration with C, C++, and other programming languages.
- **Native Rust Crate**: A core Rust library (`screampp`) available on crates.io for direct use in other Rust-based scientific computing projects.
- **Standalone CLI**: A powerful and easy-to-use command-line interface for all prediction tasks.
- **Native Rust Crate**: The core library (`screampp`) is available on [crates.io](https://crates.io/crates/screampp) for direct use in other Rust-based scientific computing projects.
- **Python Package (Future)**: A user-friendly Python API (via PyO3) for scripting and integration is planned for future releases.
- **C-Compatible Library (Future)**: A C FFI layer for integration with C, C++, and other languages is planned for future releases.

## Getting Started

There are two main ways to use SCREAM++: as a standalone command-line tool or as a library in your own Rust project.

### 1. Using the Command-Line Interface (CLI)

This is the recommended method for most users.

#### Step 1: Download the executable

Go to the [**GitHub Releases page**](https://github.com/caltechmsc/screampp/releases) and download the pre-compiled binary for your operating system (Linux, macOS, Windows). Unzip the archive.

#### Step 2: Download the required data files

The first time you run the CLI, you must download the necessary forcefield and rotamer library files. This is a one-time setup.

```bash
# On Linux/macOS
./scream data download

# On Windows (Command Prompt)
scream.exe data download
```

This command will fetch and unpack the data to a default location on your system.

#### Step 3: Run a prediction

You are now ready to run a side-chain placement job.

```bash
# Optimize all side-chains in input.bgf and save the result
./scream place -i path/to/input.bgf -o path/to/output.bgf
```

For detailed instructions on all commands, options, and advanced configuration, please refer to the [**CLI User Manual**](docs/cli/USAGE.md).

### 2. Using as a Rust Library

If you are a Rust developer, you can add `screampp` as a dependency to your project.

#### Step 1: Add to `Cargo.toml`

```toml
[dependencies]
screampp = "0.5.0"
```

#### Step 2: Use in your code

You can now use the high-level `workflows` API to perform side-chain placement programmatically.

```rust
use screampp::core::io::bgf::BgfFile;
use screampp::engine::config::{PlacementConfigBuilder, ResidueSelection, ConvergenceConfig};
use screampp::engine::progress::ProgressReporter;
use screampp::workflows::place;

fn run_placement() -> Result<(), Box<dyn std::error::Error>> {
let (system, metadata) = BgfFile::read_from_path("path/to/input.bgf")?;

let config = PlacementConfigBuilder::new()
.forcefield_path("path/to/data/forcefield/dreiding-lj-12-6-0.4.toml")
.delta_params_path("path/to/data/delta/delta-rmsd-1.0.csv")
.s_factor(1.1)
.rotamer_library_path("path/to/data/rotamers/charmm@rmsd-1.0.toml")
.topology_registry_path("path/to/data/topology/registry.toml")
.residues_to_optimize(ResidueSelection::All)
.max_iterations(100)
.num_solutions(1)
.include_input_conformation(true)
.final_refinement_iterations(2)
.convergence_config(ConvergenceConfig {
energy_threshold: 0.01,
patience_iterations: 5,
})
.build()?;

let reporter = ProgressReporter::new(); // Or provide a callback for progress updates
let result = place::run(&system, &config, &reporter)?;

if let Some(best_solution) = result.solutions.first() {
println!("Best energy: {:.2} kcal/mol", best_solution.total_energy);
}

Ok(())
}
```

## Documentation

Comprehensive documentation is available for both users and developers.

- **For Users**:

- [**CLI User Manual**](docs/cli/USAGE.md): A complete guide to installing and using the `scream` command-line tool, including detailed explanations of all commands, configuration options, and practical examples.

- **For Developers**:

- [**Rust Library API Docs (docs.rs)**](https://docs.rs/screampp): The official, versioned API documentation for the `scream-core` (`screampp`) crate, generated by `rustdoc`. This is the best resource for understanding the public API of the library.
- **Developer Documentation**: In-depth documentation covering the architecture, data models, algorithms, and design philosophy of the entire project. This is essential reading for anyone looking to contribute to or deeply understand the internals of SCREAM++.
- [**`scream-core` Developer Docs**](docs/dev/core/README.md): Details the internal architecture, data models, and algorithms of the `scream-core` library.
- [**`scream-cli` Developer Docs**](docs/dev/cli/README.md): Provides a comprehensive technical breakdown of the `scream-cli` crate, including execution flow, configuration handling, and data management.

## Tech Stack

- **Language**: Rust
- **Supported Languages**: Rust, Python (via PyO3), C/C++ (via FFI)
- **Core Language**: Rust
- **Build System**: Cargo
- **Planned Interfaces**: Python (via PyO3), C/C++ (via FFI)

## License

Expand Down
77 changes: 77 additions & 0 deletions crates/scream-core/src/core/forcefield/energy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,59 @@ use crate::core::models::ids::ResidueId;
use std::f64::consts::PI;
use thiserror::Error;

/// Represents errors that can occur during energy calculations in the force field.
///
/// This enum encapsulates various error conditions that may arise when computing
/// interaction energies between atoms, providing detailed context for debugging
/// and error handling in molecular simulations.
#[derive(Debug, Error)]
pub enum EnergyCalculationError {
/// Indicates that an atom lacks the necessary parameters for van der Waals energy calculation.
///
/// This error occurs when attempting to compute VDW interactions for atoms that have
/// not been parameterized with appropriate force field parameters (e.g., Lennard-Jones
/// or Buckingham parameters).
#[error(
"Atom '{atom_name}' in residue {residue_id:?} is not parameterized for VDW calculation"
)]
UnparameterizedAtom {
/// The name of the atom that is missing parameters.
atom_name: String,
/// The ID of the residue containing the unparameterized atom.
residue_id: ResidueId,
},
}

/// Provides static methods for calculating various types of molecular interaction energies.
///
/// This struct serves as a utility for computing energy contributions from different
/// force field terms, including van der Waals, electrostatic, and hydrogen bonding
/// interactions. All methods are designed to work with the SCREAM++ molecular
/// data structures and follow standard force field conventions.
pub struct EnergyCalculator;

impl EnergyCalculator {
/// Calculates the van der Waals interaction energy between two atoms.
///
/// This method computes the VDW energy using either Lennard-Jones 12-6 or Buckingham
/// exponential-6 potentials, depending on the parameterization of the atoms. It combines
/// parameters from both atoms using standard mixing rules and applies a flat-bottom
/// modification based on the atoms' delta values to handle close contacts.
///
/// # Arguments
///
/// * `atom1` - The first atom participating in the interaction
/// * `atom2` - The second atom participating in the interaction
///
/// # Return
///
/// Returns the calculated VDW energy in kcal/mol. Positive values indicate repulsive
/// interactions, negative values indicate attractive interactions.
///
/// # Errors
///
/// Returns `EnergyCalculationError::UnparameterizedAtom` if either atom lacks
/// VDW parameters.
pub fn calculate_vdw(atom1: &Atom, atom2: &Atom) -> Result<f64, EnergyCalculationError> {
let extract_params = |atom: &Atom| match atom.vdw_param {
CachedVdwParam::LennardJones { radius, well_depth } => Ok((radius, well_depth, 0.0)),
Expand All @@ -37,6 +76,7 @@ impl EnergyCalculator {

let dist = (atom1.position - atom2.position).norm();

// Combine delta values to determine the flat-bottom cutoff distance
let total_delta = (atom1.delta.powi(2) + atom2.delta.powi(2)).sqrt();
let r_min_combined = (r_min1 + r_min2) / 2.0;
let well_depth_combined = (well_depth1 * well_depth2).sqrt();
Expand All @@ -54,11 +94,46 @@ impl EnergyCalculator {
Ok(energy)
}

/// Calculates the electrostatic Coulomb interaction energy between two atoms.
///
/// This method computes the electrostatic energy using Coulomb's law with a distance-
/// dependent dielectric constant. The calculation assumes point charges and does not
/// include any cutoff or screening effects beyond the dielectric.
///
/// # Arguments
///
/// * `atom1` - The first atom participating in the interaction
/// * `atom2` - The second atom participating in the interaction
/// * `dielectric` - The dielectric constant of the medium (dimensionless)
///
/// # Return
///
/// Returns the calculated Coulomb energy in kcal/mol. The sign depends on the
/// charges: positive for like charges, negative for opposite charges.
pub fn calculate_coulomb(atom1: &Atom, atom2: &Atom, dielectric: f64) -> f64 {
let dist = (atom1.position - atom2.position).norm();
potentials::coulomb(dist, atom1.partial_charge, atom2.partial_charge, dielectric)
}

/// Calculates the hydrogen bonding interaction energy between donor, hydrogen, and acceptor atoms.
///
/// This method implements the Dreiding hydrogen bond potential with a 12-10 distance
/// dependence and an angular term based on the donor-hydrogen-acceptor angle. The
/// potential is zero for angles ≤ 90° and includes a flat-bottom modification for
/// close contacts based on the atoms' delta values.
///
/// # Arguments
///
/// * `donor` - The donor atom in the hydrogen bond
/// * `hydrogen` - The hydrogen atom attached to the donor
/// * `acceptor` - The acceptor atom in the hydrogen bond
/// * `r_hb` - The equilibrium hydrogen bond distance in Å
/// * `d_hb` - The well depth of the hydrogen bond potential in kcal/mol
///
/// # Return
///
/// Returns the calculated hydrogen bond energy in kcal/mol. Negative values indicate
/// favorable hydrogen bonding interactions.
pub fn calculate_hbond(
donor: &Atom,
hydrogen: &Atom,
Expand All @@ -71,10 +146,12 @@ impl EnergyCalculator {
let v_hd = donor.position - hydrogen.position;
let angle_ahd_deg = v_ha.angle(&v_hd).to_degrees();

// Hydrogen bonds are only considered for angles > 90°
if angle_ahd_deg <= 90.0 {
return 0.0;
}

// Combine delta values for flat-bottom cutoff
let total_delta = (acceptor.delta.powi(2) + donor.delta.powi(2)).sqrt();
let distance_potential_fn =
|d: f64| -> f64 { potentials::dreiding_hbond_12_10(d, r_hb, d_hb) };
Expand Down
41 changes: 39 additions & 2 deletions crates/scream-core/src/core/forcefield/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
pub mod energy;
//! # Force Field Module
//!
//! This module provides the core functionality for molecular mechanics force field calculations
//! in the SCREAM++ protein side-chain placement library. It implements energy evaluation,
//! parameter management, and scoring algorithms for molecular interactions.
//!
//! ## Overview
//!
//! The force field module is responsible for computing interaction energies between atoms
//! and molecular groups using classical molecular mechanics potentials. It supports:
//!
//! - **Van der Waals interactions** using Lennard-Jones and Buckingham potentials
//! - **Electrostatic interactions** with Coulomb's law and distance-dependent dielectric
//! - **Hydrogen bonding** using specialized 12-10 potentials
//! - **Energy weighting** based on atom roles (backbone vs sidechain)
//! - **Parameter management** for different force field types and atom types
//!
//! ## Key Components
//!
//! - [`params`] - Force field parameter structures and configuration
//! - [`scoring`] - High-level energy scoring interface for molecular systems
//! - [`term`] - Energy term aggregation and reporting
//! - [`parameterization`] - Automatic assignment of force field parameters to atoms
//!
//! ## Usage
//!
//! The main entry point for energy calculations is the [`scoring::Scorer`] struct,
//! which provides methods to compute interaction energies between atom groups while
//! properly handling bonded exclusions and energy weighting.
//!
//! ```ignore
//! use screampp::core::forcefield::scoring::Scorer;
//!
//! let scorer = Scorer::new(&system, &forcefield);
//! let energy = scorer.score_interaction(query_atoms, environment_atoms)?;
//! ```

pub(crate) mod energy;
pub mod parameterization;
pub mod params;
pub mod potentials;
pub(crate) mod potentials;
pub mod scoring;
pub mod term;
Loading