RK4 solver
A visual designer and simulator for genetic circuits. Draw your circuit as blocks, press Play, and watch it evolve while you tune every parameter live. No code required.
Our goal
Alongside the models, simulations and plugins shown elsewhere on this wiki, we built a standalone application. In short, this application can be described as a genetic circuit designer and simulator that, without requiring any coding skills, allows you to interact with the circuit parameters live and see their effect.
The idea came up while working on our own iGEM project. We were developing the simulation of the biocontainment model (check the Biocontainment page for more) and we realised that it would be much easier if a simple tool for turning a circuit drawing or diagram into a working simulation existed. It would make modelling circuits much faster and more efficient, and corrections would be easier to implement. For future iGEM teams, this can be a major help, since most of them do not have a lot of time to develop the project, and with the app a circuit can be designed, simulated and corrected in minutes.
But that is not our only target: we also think that an app like this could potentially ease the process of understanding how genetic circuits are modelled, the influence of the parameters, or the general logic of gene interaction.
Overall, this app is designed to lower the entry barrier and flatten the learning curve for people who study genetic circuits and need to design and simulate them, but who can't code, know very little coding, or aren't interested in learning it. For this reason, this app is aimed at future iGEM teams, at high school students and at undergraduate students.
It is also important to be clear about what this app is not supposed to do. It is not intended to replace any of the existing software tools like COPASI or SimBiology and it is not intended to solve any system parameters or do any kind of estimation: it is an interactive design and simulation tool for beginners.
State of the art
Several well-established tools already simulate biological networks. They are powerful, but most of them expect you either to describe the system as chemical reactions with rate laws or to write code, which does not fit in our target niche and our main objectives.
COPASI1 is the reference tool in the field, and the one our app connects to. It has been developed since 2004 by an international team (Mendes, Kummer and colleagues). The user needs to type reactions and their rate laws into tables, and COPASI generates the equations. It offers:
- deterministic, stochastic and hybrid simulation
- steady-state analysis and parameter scans
- parameter estimation from experimental data
- sensitivity and metabolic control analysis
- full SBML support
It is free, open source and cross-platform. To model a genetic circuit in COPASI you first have to translate your drawing into a list of reactions, choose or write the rate laws (such as Hill functions), and find your way around an interface built for expert analysis. That is a steep start for a first contact with circuit modelling.
| Tool | How you build a model | Strengths | Main audience | Access |
|---|---|---|---|---|
| COPASI1 | Reactions and rate laws in tables | Deterministic, stochastic and hybrid simulation; parameter estimation; sensitivity analysis | Systems biology and biochemistry researchers | Free, open source; GUI, command line, Python (basiCO) |
| Tellurium2 | Text model (Antimony) run from Python | Fast libRoadRunner engine, reproducible workflows, SBML and SED-ML | Modellers who are comfortable coding | Free, open source |
| CellDesigner3 | Draw a process diagram (SBGN) | Detailed network maps, native SBML, simulates through COPASI or SBML ODE Solver | Systems biologists building pathway maps | Free |
| iBioSim4 | Graphical genetic circuit editor | Genetic circuit design, SBOL and SBML, ODE and stochastic simulation, multicellular models | Synthetic biology researchers | Free, open source |
| SimBiology5 | Block diagram builder or MATLAB code | Parameter estimation, sensitivity analysis, dosing (PK/PD) | Pharmacology and drug development | Commercial, requires MATLAB |
| Cello6 | Logic described in Verilog | Compiles logic into DNA using a library of characterised gates | Genetic circuit engineers | Free, open source |
| RK4 solver (ours) | Draw the circuit with genetic circuit blocks | Live parameter sliders, built-in guide and examples, SBML import and export to the tools above | Students and iGEM teams with no coding background | Free, open source; Windows, macOS, Linux |
TinkerCell,7 a visual CAD tool for synthetic biology built from parts, was a close precedent but is no longer maintained.
Where we fit. RK4 solver doesn't compete with these tools and it is not intended to. It covers the first step and smooths the transition: going from a hand-drawn circuit to a working simulation in minutes. If a project needs more (parameter estimation, stochastic simulation, steady-state analysis), you can export the circuit in SBML format (Systems Biology Markup Language, a free, open, and machine-readable data format based on XML for exporting biological models) and open it in COPASI or Tellurium and complete it there, and vice versa.
What our solution offers
-
Intuitive design
Blocks inspired by how circuits are drawn on paper, with icons based on SBOL Visual8 (Synthetic Biology Open Language).
-
Fast implementation
Place a block with one key, link blocks by dragging, and the equations are generated automatically.
-
Live tuning
Every parameter has a slider that takes effect while the simulation runs.
-
Easy import and export
Readable JSON (personalised format), or SBML Level 39 for COPASI, Tellurium and other tools.
-
Guided learning
A detailed user guide with pictures, plus ready-made example circuits, including a version of our biocontainment circuit.
-
Built-in safety net
Diagnostics, warnings and connection rules stop you from building an incorrect circuit and ensure that every link is deliberate.
Development
The program is made of three partially independent modules: the graphical user interface (GUI), the compiler and the solver.
The app has two screens:
- Results screen: where circuits are simulated and plotted and parameters are tuned.
- Editor screen: where the circuit is designed and prepared for the simulation. Split into three tabs.
- Circuit: the board where blocks are placed and linked. The flow of the circuit is designed here.
- Environment: set the external inputs, initial concentrations and review the selected block options.
- Animation: choose the solver, time step and stop time.
1. Graphical user interface
The GUI is the most important link in the chain, since it is the part users interact with, and their only way of talking to the program. It needs to be highly intuitive, easy to use, and represent the blocks as naturally as possible, as well as being able to guide users towards building correct circuits in a natural way. This is done through diagnostics, warnings, errors, and through block design choices. First, let's see the most important parts: the blocks.
1.1 The blocks
Let's see what a block is:
Each block is composed of a title, a series of input and output pins, and an icon. Each icon represents the type of block it is, so that if the block is collapsed, one can still identify the type. Furthermore, most blocks feature an entry, for the user to insert the name of the species, and others feature a dropdown, to select the dynamics of that process.
The input pins are always on the left side of the block, and can vary in quantity, from zero to two. The output pins are always on the right side, and can also vary from zero to two.
Eight blocks are fully implemented. Each one represents a process that creates or transforms species and adds terms to the differential equations of the full model. Some blocks add different terms depending on what is connected to them or which option is selected. Combining them, you can build a wide range of circuits.
Now, let's see which blocks were implemented and what is their composition and structure. Click the icons to see each block's image and information.
Block name (shortcut key)
Production P
Has no options menu. Its behaviour depends on what is wired to its Hill terminals. With nothing connected, it is constitutive production, α. With an activator and/or a repressor connected, it becomes β·Hact·Hrep, where:
- Hrep (repression): Kn / (Kn + Rn)
- Hact (activation): An / (Kn + An)
Degradation D
First-order decay, −δ·X. It can only connect to the dedicated degradation pin.
Complex formation B
n1·A + n2·B ⇌ C, with adjustable stoichiometric coefficients. It has two modes:
- Rapid equilibrium: for binding that is much faster than everything else (quasi-equilibrium approximation). The complex is solved from KD at every step.
- Kinetic: v = kon·An1·Bn2 − koff·C.
Extracellular species E
Represents a molecule in the medium. It is the model's only boundary condition, so it has the most options: bolus at t = 0, constant infusion, pulse (a step between two times), linear ramp, sinusoid (periodic injection) and decaying dose.
Cell entry I
Moves a species from the medium into the cell by simple diffusion, facilitated diffusion or active transport. It takes into account the cell-to-medium volume ratio.
Export O
The same transport modes, from the cell out to the medium.
Catalysis C
It can be used to simulate DNA cleavage, enzymatic reactions and other special interactions. Saturable (Michaelis-Menten, kcat·E·S / (Km + S)) or non-saturable (mass action). The substrate is consumed.
Link probe L
Monitors an intermediate term, or simply checks what is travelling through a link. It doesn't change the model.
Custom term K coming soon
Already designed and present in the app. It will hold any term of the differential equations that the other blocks don't cover. It also represents a process: all its terms are defined inside the block, and you choose explicitly which derivative each one goes to.
We developed the GUI through several rounds of design, implementation, testing and redesign. The blocks started as hand-drawn sketches inspired by circuit diagrams, were implemented in Python with the Dear PyGUI library and adapted to its limits, and were then tested by teammates and friends with no background in genetic circuits. After a short introduction to the notation, testers built and tuned a toggle switch in 5 to 20 minutes, and built their second circuit much faster.
Their feedback made the blocks simpler: fewer parameters inside each block, icons based on SBOL Visual,8 an option to collapse blocks, a separate degradation pin and connection rules that prevent incorrect links.
For the full design process, the user tests and the feedback behind each change, check dry lab cycle 3 on our Engineering page.
2. The solver
The solver is independent of both the GUI and the compiler, so you can use it from Python without drawing anything on screen. Since genetic models run on differential equations (ODEs) and a large number of them are not solvable, we need an approximation method to solve the system.
The solver needs to be able to do two processes:
- Compute slopes of every species at a given time, that is, evaluate the derivative with the concentrations available at time t.
- Compute the new state of the system using the chosen approximation method and the evaluations at different times.
2.1 Computing the slopes
To evaluate the derivative (or to compute the slope), the algorithm defines a step list. That is an ordered list of simple mathematical instructions called operators. Some are basic (sum, sign change, product, division, power) and some are more complex (sine, pulse…). Furthermore, the get operator reads from the variables, and the set operator stores the results into them.
The operators inside the step list reflect the differential equations of the model, one for each of the defined species.
At every timestep, the algorithm runs through the step list, using a working list (stack) to hold temporary values. Example 1 in 2.3 shows step by step how the operators move values through it.
2.2 Completing the approximation
Once the solver knows how to evaluate the derivatives, it computes the state at the next time step.
The solver is modular in this sense. It accepts different approximation methods, so that anyone could take the base of the solver, add a new method and run the code without changing anything else. We implemented Euler's method and 4th order Runge-Kutta's method.
Euler's method offers a simple way of approximation and an easy way of validating the results, since it is easily solvable by hand. It consists of adding, in every timestep, the computed derivative value scaled by the time step to the previous value:
A(t + Δt) = A(t) + Δt·dA/dt
Nevertheless, its error accumulates with every step, and it can become unstable when the time step is too large.11
On the other hand, 4th order Runge-Kutta's method (RK4, for short), provides much higher accuracy, at the cost of simplicity. This method consists of evaluating the slope four times, from different starting slopes, and adding them in a weighted sum to approximate the final result.12 In the app, this means running the same operator list four times per step (once at t, twice at t + Δt/2 and once at t + Δt) and combining the four slopes with weights 1, 2, 2, 1.
2.3 Example
Example 1: constitutive production with first-order degradation (shown with Euler for simplicity)
dA/dt = αA − δA·A
As operators: get(α_A), get(δ_A), get(A), prod(), sign(), sum(), set_der(A)
| Operator | What it does | Stack after |
|---|---|---|
get(α_A) | pushes α_A | [α_A] |
get(δ_A) | pushes δ_A | [α_A, δ_A] |
get(A) | pushes the current A | [α_A, δ_A, A] |
prod() | multiplies the last two values | [α_A, δ_A·A] |
sign() | flips the sign of the last value | [α_A, −δ_A·A] |
sum() | adds the last two values | [α_A − δ_A·A] |
set_der(A) | pops the result and stores it as dA/dt | [ ] |
Each get pushes a stored value onto the stack. The value can be a parameter, a state variable or an intermediate variable. Arithmetic operators take the last values on the stack and leave their result in their place. Finally, set_der pops the one value left and stores it as the derivative of its species.
Once all the derivatives are known, the solver calculates the new state with the chosen method, as described in 2.2.
3. The compiler
The compiler is closely tied to the GUI. Its job is to translate the circuit on screen into the operator list that the solver runs.
Because of how the solver works, every derivative has to be a block of summed terms closed by its own set_der(species). Terms from different equations can't be mixed, or the solver would add up things that don't belong together.
The compiler has two parts: the translator and the block compiler. The translator could be seen as an orchestra's conductor: it commands how the other musicians will express their part.
In this case, the musicians are the blocks, which have a list of steps they add to the general step list aforementioned, and they add a term depending on the way they are called. The conductor is the translator: it reads the circuit diagram and calls the different blocks in the way they are supposed to, in order to add the correct term to the list.
In the first iteration of the design, the translator grouped terms by the block's species. The following example shows how this iteration of the compiler worked.
Example 2: toggle switch. Two species, A and B, repress each other, and each has first-order degradation.
dA/dt = Hill_rep(A, B) − δA·A
dB/dt = Hill_rep(B, A) − δB·B
Here Hill_rep(A, B) is the production of A repressed by B. It is shorthand for all the get, pow, sum and div operators inside it (full expressions are in our repository10).
The translator visits blocks in the order they were built. Say both productions were placed first and the degradations afterwards. If the translator did not group the species before compiling each block, the terms would be added as Hill_rep(A, B), Hill_rep(B, A), −δ_A·A, −δ_B·B, mixing the two equations. So the translator first sorts the terms by species and then calls the compilation of every block:
A problem we found: species consumed by other blocks. This first version sorted blocks by the species they belong to. That works for simple circuits, but as we added more blocks we saw it wasn't enough. A species can be used up by processes other than degradation, for example binding, where two species join to form a third. If A and B bind to form C, the binding block belongs to C. The first translator therefore added the negative terms of A and B into dC/dt, which is wrong.
So we redesigned the translator. Instead of sorting blocks by species, it now sorts the contribution of each block by the species it points to.
Example 3: complex formation. A and B are produced constitutively and degraded with first-order kinetics. A and B bind to form C, which also degrades the same way.
| Block (in build order) | Contribution | Target |
|---|---|---|
| Production A | +α_A | A |
| Degradation A | −δ_A·A | A |
| Production B | +α_B | B |
| Degradation B | −δ_B·B | B |
| Complex formation | +v | C |
| Complex formation | −v | A |
| Complex formation | −v | B |
| Degradation C | −δ_C·C | C |
The translator collects every contribution, sorts them by target and calls the block compiler as needed, i.e., as positive or negative contributions:
dA/dt = αA − δA·A − v
dB/dt = αB − δB·B − v
dC/dt = v − δC·C, where v = kon·A·B − koff·C
This way, the translator is able to interpret the diagram and build the expressions, and then, each block will compile, generating the steps for that block and adding them to the general step list. The translator also adds the sum operators between terms and closes each species' expression with the set_der operator. This way, the block compiler is only in charge of adding its own calculations, and the translator coordinates them all.
Working example
This app was also validated with the biocontainment model we had already developed. In short, the design consists of two genetic circuits that ensure that the bacteria can not live without a specific substance (resveratrol). We will focus on the toxin-antitoxin circuit. This circuit is designed to continuously produce a toxin, mazF, and the antitoxin is only produced when the signalling substance, resveratrol, is present. Check the whole model on the biocontainment model page.
Modelled in the app, the circuit looks like this:
Ideally, if the circuit worked, in the presence of resveratrol, the levels of mazF in the bacteria would be small, and the levels of FEF (the complex of mazF and mazE, metabolically inactive) would be high, preventing the cell from dying. On the contrary, in the absence of resveratrol, the levels of mazF would be high, while FEF levels would drop, leading to cellular death.
If we simulate this circuit plotting internal resveratrol, mazF and FEF levels, with a sinusoidal production of resveratrol, we can see that this is exactly what happens.
The same happens in the biocontainment simulation, with bacteria that travel away from the root: as they travel away, the resveratrol decreases and mazF starts to grow progressively (seconds from 45 to 70 in the picture), until the resveratrol is so low that mazF is high enough to kill the bacteria (from 70 until 100 seconds).
Validation against COPASI
To check that the app solves its equations correctly, we exported the three example circuits that come with it (the biocontainment circuit, an inducible GFP circuit and the toggle switch) to SBML9 and simulated them in COPASI1 under the same conditions: the same parameters, initial concentrations and simulation time. COPASI integrated the models with LSODA,13 an adaptive solver that switches automatically between methods for stiff and non-stiff systems, while the app used RK4. The tables compare the concentration of each species at the end of the simulation. The error is the relative difference:
Error (%) = |app − COPASI| / COPASI × 100
Case 1: biocontainment circuit. This is the largest of the three models, with transport across the membrane and two binding steps.
| Species | RK4 solver | COPASI | Error (%) |
|---|---|---|---|
| mazF | 8.6559 | 9.99955 | 13.44 |
| mazE | 0.01 | 0.685393 | 98.54 |
| FEF | 0.6718 | – | – |
| ttgR | 2.995 | 2.9895 | 0.18 |
| Resv | 2.34 | 2.34489 | 0.21 |
| RR | 7.001 | 7.01005 | 0.13 |
| mazF_tot (mazF + 2·FEF) | 9.9996 | 9.99955 | < 0.01 |
| mazE_tot (mazE + FEF) | 0.6848 | 0.685393 | 0.09 |
| ttgR_tot | 10.00 | 9.99955 | < 0.01 |
| Resv_tot | 9.34 | 9.35494 | 0.16 |
| Resv_ext | 5.3926 | 5.40147 | 0.16 |
Every species agrees within 0.21% except free mazF and mazE, which differ by 13.4% and 98.5%. This is not an integration error but a difference in how the app labels and solves rapid equilibrium. The app binds mazF and mazE into the FEF complex with the rapid equilibrium option: at every step it takes the total amount of each protein, splits it into a free and a bound part using KD, and reports the free parts as mazF and mazE and the bound part as FEF. COPASI has no separate FEF species, so its mazF and mazE are the total concentrations. Adding the bound part back to the app's values (mazF + 2·FEF and mazE + FEF, since each FEF complex holds two mazF and one mazE) gives 9.9996 and 0.6848, which match COPASI within 0.01% and 0.09%.
Case 2: inducible GFP circuit. All three species agree within 0.01%.
| Species | RK4 solver | COPASI | Error (%) |
|---|---|---|---|
| AHLin | 4.0420 | 4.04196 | < 0.01 |
| GFP | 8.9268 | 8.92648 | < 0.01 |
| AHL | 4.8439 | 4.84366 | < 0.01 |
Case 3: toggle switch. Both species give the same values to the four decimal places recorded.
| Species | RK4 solver | COPASI | Error (%) |
|---|---|---|---|
| A | 3.3641 | 3.3641 | 0.00 |
| B | 1.1587 | 1.1587 | 0.00 |
Conclusions. Across the three circuits, every quantity that means the same thing in both tools agrees with COPASI within 0.21%, and most agree within 0.01%. The largest differences (0.1 to 0.2%) appear in the biocontainment circuit, the largest model, and are far smaller than the uncertainty in any biological parameter. This shows that the compiler builds the right equations, that the fixed-step RK4 integrates them accurately, and that SBML export carries the model to other tools without loss. The one point to keep in mind is rapid-equilibrium binding: when comparing the app with another tool, compare total concentrations (free plus bound), not the free forms alone.
Limitations and future work
The app was designed to keep growing after iGEM, and its unfinished parts are clearly marked inside it. Current limitations:
- Simulation is deterministic only (ODEs): there are no random events.
- SBML import is limited by the number of features implemented into our app, so other functionalities are ignored and marked as warnings in the diagnostics area.
- Numerical instabilities can appear in some specific cases. RK4 might be insufficient for certain circuits.
- The custom block is still not implemented, which limits the number of circuits that can be done.
- The GUI design is still not as intuitive as we would like; further work is needed.
Feature roadmap
-
Immediate
- Adding the Custom block.
- With the custom block, a mathematical expression parser should be developed, independent of the rest of the software.
- Personalised input expression for extracellular blocks.
-
Mid term
- New integrator methods: adding adaptive RK4 and other approximation algorithms to ensure the correct integration and numeric accuracy.
- Stochastic events added to the temporal simulation. This includes the development of a hybrid integration method.
- Integration with the iGEM Registry through SBOL, for parts and parameters:
SourceThe Registry fills in each part's parameters (strength, half-life, etc.).Default valueIf a part has no data, the model uses a generic value and shows a warning.OverrideThe user can change any value, and it is marked as "overwritten" so it stays traceable.
-
Long term
- Population-level, multicellular simulation. This adds two spatial dimensions to time. It would also bring new parts of the program to life:
- an environment builder and a boundary-condition builder
- a 2D+t view where you can change parameters live, and "click" any cell to follow its concentrations over time, as the app does now. This was the original goal of the application, inspired by our interactive biocontainment model.
- Different populations of cells should be able to run in the same environment, so interactions between cells can be modelled.
- Population-level, multicellular simulation. This adds two spatial dimensions to time. It would also bring new parts of the program to life:
References
- Hoops S, et al. COPASI: a COmplex PAthway SImulator. Bioinformatics. 2006;22(24):3067–3074.
- Choi K, et al. Tellurium: an extensible Python-based modeling environment for systems and synthetic biology. Biosystems. 2018;171:74–79.
- Funahashi A, et al. CellDesigner 3.5: a versatile modeling tool for biochemical networks. Proc IEEE. 2008;96(8):1254–1265.
- Watanabe L, et al. iBioSim 3: a tool for model-based genetic circuit design. ACS Synth Biol. 2019;8(7):1560–1563.
- MathWorks. SimBiology. https://www.mathworks.com/products/simbiology.html
- Nielsen AAK, et al. Genetic circuit design automation. Science. 2016;352(6281):aac7341.
- Chandran D, Bergmann FT, Sauro HM. TinkerCell: modular CAD tool for synthetic biology. J Biol Eng. 2009;3:19.
- SBOL Visual glyphs. https://sbolstandard.org/visual-glyphs/
- Keating SM, et al. SBML Level 3: an extensible format for the exchange and reuse of biological models. Mol Syst Biol. 2020;16:e9110.
- UPF Barcelona 2026 software repository. https://gitlab.igem.org/2026/software/upf-barcelona/upf-software
- Butcher JC. Numerical Methods for Ordinary Differential Equations. 3rd ed. Chichester: Wiley; 2016.
- Press WH, Teukolsky SA, Vetterling WT, Flannery BP. Numerical Recipes: The Art of Scientific Computing. 3rd ed. Cambridge: Cambridge University Press; 2007.
- Petzold L. Automatic selection of methods for solving stiff and nonstiff systems of ordinary differential equations. SIAM J Sci Stat Comput. 1983;4(1):136–148.