The script uses os to manage directories and file paths. It creates an output folder for simulation results, builds paths for CSVs and figures, and reads environment variables to determine whether plots should be displayed. It also prints relative file paths when saving outputs, making the logs user-friendly. We utilize datetime to generate a timestamp, which ensures that output folders and files have unique names corresponding to the time of execution.
For plotting and visualization, matplotlib and its submodules play a central role. The backend is managed to allow headless operation when GUI plots are disabled. The pyplot library is used to create all figures, including stacked panels, overlays, and gallery plots, with dual y-axes for mRNA and protein data. The library also handles figure layout, axes, titles, grids, and optional log scales. PdfPages is used to collect all figures into a single multi-page PDF. Custom legends are implemented using Line2D, and helper functions ensure that color-coded legends and line styles are displayed cleanly in separate panels.
We utilize numpy for numerical computation and array handling. It is used to generate time arrays, simulate mRNA and protein dynamics, compute decay rates, binding probabilities, and translation kinetics. It also assists in interpolation for first-passage time calculations (t50) and numerical operations in sequence scoring and translation efficiency calculations.
The script relies on pandas for data organization and storage. Simulation results are stored in dataframes, grouped by promoter, and used to compute summary metrics. The pandas library handles sorting and filtering of data for plotting, as well as exporting results to CSV files for promoter dynamics and summary statistics.
Overall, the libraries integrate seamlessly within the workflow. The numpy library handles numerical simulation, pandas organizes and stores the resulting data, matplotlib generates figures and PDFs, and os and datetime manage file organization and naming. Together, these libraries enable a full pipeline from promoter sequence and translation analysis to simulation, summary, and high-quality visual output.
The goal of the AHL induction simulation is to estimate the intensity of light emitted by sfGFP in E. coli containing the Metlock system. The amount of sfGFP in the system is simulated by calculating a chain of precursors in the system. Each timestep, each piece of the chain is calculated and added to the environment, remaining there until it is used to produce something else or decays.
An amount of LuxR mRNA is added to the system based on the amount of bacteria present. This plasmid is always active and producing mRNA.
An amount of LuxR is created and added to the system based on the amount of LuxR mRNA and the amount of available ribosomes.
At certain OD600 thresholds, an amount of AHL is added to the system to activate LuxR.
AHL in the system activates LuxR, creating activated LuxR. The amount of LuxR activated is calculated based off of the expected number of collisions between LuxR and AHL and an activation percentage. The expected number of particle collisions is proportional to the amount of AHL, the amount of LuxR, the cross-sectional area of their collision, their relative speed, and the size of the container. Our values for the cross-sectional area, the relative speed of AHL and LuxR, and the chance that a collision results in an activation are all estimates.
Activated LuxR in the system binds to sfGFP-producing plasmids, activating them and causing them to produce sfGFP mRNA. Similar to the activation of LuxR, the amount of plasmids that begin producing sfGFP mRNA is based off the expected collisions between the sfGFP producing plasmids and activated LuxR. As with activating LuxR, the cross-sectional area of the collision, the relative speed of the plasmid to activated LuxR, and the interaction ratio are estimates.
An amount of sfGFP is produced based on the amount of sfGFP mRNA and the available ribosomes.
The intensity of the produced light is a scalar multiple of the amount of sfGFP in the system.
All mRNA, LuxR, AHL, and sfGFP have a half-life, and an appropriate amount decays at each timestep. Additionally, the bacteria split, creating more bacteria at this time.
The model produced a curve in line with our expectations of how the system should behave. As bacteria grow and AHL is added into the system, the intensity of light grows quickly and then stabilizes at a maximum. This maximum is where the rate of decay of sfGFP and the cells' ability to produce sfGFP are in equilibrium. After a short while, the supply of AHL runs out and the remaining sfGFP decays quickly, quieting the system.
Plot2Curve is a single Python script that produces a full pipeline from simulation to publication-ready figures:
sim_results_YYYYmmdd_HHMMSS/) and print relative paths for readable logs.HEADLESS=1 saves figures without opening windows.THROTTLE=0/1 toggles ribosome resource sharing.K_R=<number> sets the resource budget scale.CDS_SEQ=<DNA or path> supplies a custom coding sequence (validated).PdfPages bundles all figures into one PDF; a helper renders a right-side legend panel that never collides with axes.Goal: Predict how bright each construct gets and how fast it becomes visible, so we can pick promoter swaps and schedule plate-reader windows before wet lab.
States per promoter: (1) mRNA, (2) immature protein (non-fluorescent), (3) mature protein (fluorescent).
Main outputs: a ranked k_tx ladder, a one-row-per-promoter summary (k_tx, m_eq, protein_eq), and timing metrics (t80 and detection time).
CDS_SEQ (string/FASTA/path). The parser checks frame and stop codon.β = min(k_init_max · P_bind, v_nt/footprint).dt from decay, growth, and maturation rates keeps Euler stable.dm/dt = k_tx − δ_m m, with k_tx = k_tx_baseline × promoter_strength.k_mat; growth dilution applies.β_eff(t) = β / (1 + M_tot/K_R) shares ribosomes across constructs.δ_m = ln(2)/360 s⁻¹α = ln(2)/1800 s⁻¹k_mat = ln(2)/420 s⁻¹aa_per_sec = 20, footprint_nt = 30, k_init_max = 1.0t_max = 5000 s; dt auto-selected for stabilityk_tx, m_eq, protein_eq, plus t80, detection time, maturation lag.