A GMP-compliant command-line tool for calculating required volumes of stock solutions and diluent (solvent) when preparing buffer solutions. It accepts a JSON recipe describing multiple components with their stock and target concentrations, plus a final volume, and outputs a clear preparation table with exact volumes to add. Designed with pharmaceutical GMP environments in mind, it includes timestamps, optional batch IDs, and robust error checking.
- JSON recipe input – define multiple components with names, stock concentrations, and target concentrations
- Concentration unit support – M, mM, µM, nM; automatic conversion to base units
- Volume unit selection – L, mL, µL; output in the same unit
- Solvent volume calculation – automatically computes the amount of diluent needed to reach the final volume
- GMP-friendly output – timestamp, batch ID, clear preparation table
- Error prevention – alerts if a stock solution is too dilute, or if the sum of stock volumes exceeds the total volume
- Zero external dependencies – uses only Python standard library (pytest needed for development)
Requires Python 3.8 or later. No additional packages are needed to run the calculator.
git clone https://github.com/your-username/buffer-prep-calculator.git
cd buffer-prep-calculatorFor development and running tests, install the test dependencies:
pip install -r requirements.txtpython buffer_prep.py --recipe recipe.json --volume 1000 --unit mL [--batch BATCH123]{
"components": [
{
"name": "Tris-HCl",
"stock_conc": 1.0,
"stock_unit": "M",
"target_conc": 0.05,
"target_unit": "M"
},
{
"name": "EDTA",
"stock_conc": 500,
"stock_unit": "mM",
"target_conc": 1,
"target_unit": "mM"
}
]
}Buffer Preparation Record
=========================
Date: 2026-04-10 15:42:00
Batch ID: BATCH001
Final Volume: 1000.000 mL
Component Stock Conc Target Conc Volume to Add (mL)
---------------------------------------------------------------------------
Tris-HCl 1.000 M 0.050 M 50.000
EDTA 0.500 M 0.001 M 2.000
Solvent (diluent) --- --- 948.000
- If a stock concentration is lower than the target concentration, the tool exits with an explanatory message.
- If the sum of required stock volumes exceeds the final volume, an error is raised.
- Invalid JSON, missing fields, or unsupported units are reported clearly.
MIT License – see LICENSE file.
Collins Amatu Gorgerat