Skip to content

EnzymeML/enzymeml-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงช EnzymeML-Rust

License: MIT Status: In Development Crates.io

The official EnzymeML toolkit for Rust - Powerful enzyme kinetics modeling and simulation

โš ๏ธ This library is currently under development and is not yet ready for production use.

โœจ Features

  • ๐Ÿ“„ EnzymeML Document Management - Create, parse, and manipulate EnzymeML documents
  • ๐Ÿงฎ Simulation - Simulate enzyme kinetics through ODE systems with various solvers
  • ๐Ÿ“Š Optimization - Parameter estimation and model fitting with multiple algorithms
  • โœ… Validation - Ensure models are consistent and correct
  • ๐Ÿ“‹ Data Handling - Read/write measurement data in various tabular formats
  • ๐Ÿ“ˆ Visualization - Beautiful plots for simulation results and experimental data
  • ๐ŸŒ WebAssembly Support - Use in web applications

๐Ÿš€ Installation

cargo add enzymeml

Or add to your Cargo.toml:

[dependencies]
enzymeml = "0.1.0"

๐Ÿ” Usage Examples

๐Ÿงช Creating an EnzymeML Document

use enzymeml::prelude::*;

let mut enzmldoc = EnzymeMLDocumentBuilder::default();

// Create small molecules
let substrate = SmallMoleculeBuilder::default()
    .id("s1")
    .name("Substrate")
    .build()?;
let product = SmallMoleculeBuilder::default()
    .id("s2")
    .name("Product")
    .build()?;

enzmldoc.to_small_molecules(substrate);
enzmldoc.to_small_molecules(product);

// Create a reaction
let reaction = build_reaction!(
    "r1",
    "Reaction",
    true,
    "s1" => -1.0,
    "s2" => 1.0
);

enzmldoc.to_reactions(reaction);

// Create an equation
let equation = EquationBuilder::default()
    .species_id("s1")
    .equation("v_max * s1 / (k_m + s1)")
    .build()?;

enzmldoc.to_equations(equation);

// Serialize the document
let enzmldoc = enzmldoc.build()?;
let serialized = serde_json::to_string_pretty(&enzmldoc)?;

println!("{}", serialized);

๐Ÿ“ฅ Deserializing an EnzymeML Document

use enzymeml::prelude::*;
use std::path::Path;

let path = Path::new("model.json");
let enzmldoc: EnzymeMLDocument = read_enzmldoc(path).unwrap();

println!("{:#?}", enzmldoc);

๐Ÿงฎ Simulating Enzyme Kinetics

use enzymeml::prelude::*;
use plotly::{Layout, Plot};

// Create an EnzymeML document with Michaelis-Menten kinetics
let doc = EnzymeMLDocumentBuilder::default()
    .name("Michaelis-Menten Simulation")
    .to_equations(
        EquationBuilder::default()
            .species_id("substrate")
            .equation("-v_max * substrate / (K_M + substrate)")
            .equation_type(EquationType::Ode)
            .build()?,
    )
    .to_equations(
        EquationBuilder::default()
            .species_id("product")
            .equation("v_max * substrate / (K_M + substrate)")
            .equation_type(EquationType::Ode)
            .build()?,
    )
    .to_parameters(
        ParameterBuilder::default()
            .name("v_max")
            .id("v_max")
            .symbol("v_max")
            .value(2.0)
            .build()?,
    )
    .to_parameters(
        ParameterBuilder::default()
            .name("K_M")
            .id("K_M")
            .symbol("K_M")
            .value(100.0)
            .build()?,
    )
    .to_measurements(/* Define initial concentrations */)
    .build()?;

// Extract initial conditions from measurements
let measurement = doc.measurements.first().unwrap();
let initial_conditions: InitialCondition = measurement.into();

// Create an ODE system from the EnzymeML document
let system: ODESystem = doc.try_into().unwrap();

// Configure simulation parameters
let setup = SimulationSetupBuilder::default()
    .dt(0.1)
    .t0(0.0)
    .t1(200.0)
    .build()?;

// Run the simulation
let result = system.integrate::<SimulationResult>(
    &setup,
    &initial_conditions,
    None,  // Optional new parameters
    None,  // Optional specific time points
    RK5,   // Numerical solver
    Some(Mode::Regular),
);

// Visualize the results
if let Ok(result) = result {
    let mut plot: Plot = result.into();
    plot.set_layout(
        Layout::default()
            .title("Michaelis-Menten Simulation")
            .show_legend(true),
    );
    plot.show();
}

๐Ÿงฉ Available Features

Enable specific features in your Cargo.toml:

enzymeml = { version = "0.1.0", features = ["optimization", "simulation"] }
Feature Description
simulation ๐Ÿงฎ ODE simulation capabilities
optimization ๐Ÿ“Š Parameter estimation and model fitting
tabular ๐Ÿ“‹ Reading/writing tabular data
llm ๐Ÿค– Large language model integration
wasm ๐ŸŒ WebAssembly support

๐Ÿ“š Documentation

For complete documentation, check out the API docs.

๐Ÿ“œ License

This project is licensed under the MIT License.

About

๐Ÿงฌ - Data management and modeling framework based on EnzymeML.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages