# *simbODE* - Simbolic Differential Equations

*simbODE* is the function implemented to determine the differential equation system related to a biological system. These equations are used to compute the system output. The funcion determine the simbolic form of the equations, so their variables have to be replace for their actual values at the time when the differential equation system is used to compute the system output.

The implementation of this function was done mainly using sympy, which it is the main Python library for symbolic mathematic.


```
#packages required
import numpy as np
import sympy as sp
```

**Define biological system**
To define a biological system is necessary to set the names of the molecular species that are considered. Also, it should be defined a variable meant to represent the system input "u". The name of each species together with the names of the kinetic variables are converted to a sympy class. This class allows to manipulate each variable in a simbolic way. Also, the way how the reactions take place and the species interact with each other is represented by the reagent and product matrices. The first one represents the count for every species while it is performing as a reagent. In the other hand, the product matrix represents the count for every species while it is performing as a product. In both matrices, each reaction is reprenseted as a column, while each species is a row from the matrices.


```
#molecular species
species = ['x1', 'x2']
species = sp.var(species)

#system input
inp = ['u']
uh = sp.var(inp)
ruh = 0  #reaction that it is affected by the input 0 = first reaction

#reagent and product matrices
#"1" represents that a specific species is changing in a certain reactin
                      #r1,r2,r3,r4
reactants = np.array([[0, 1, 1, 0],
                      [0, 0, 0, 1]])
products = np.array([[1, 0, 1, 0],
                     [0, 0, 1, 0]])

#kinetic parameters
pars = ['c1', 'c2', 'c3', 'c4']
parsValues = sp.var(pars)
#parsValues = [4.0, 0.010, 1.0, 0.006] #to use numeric parameters uncomment this
#line and comment the two previous ones
```

To identify the differential equations system from the previous defined data, first it has to be calculated a general soichiometric matrix. This matrix is equal to the difference between the product and the reagent matrices. The equations of the system are found using a propensity function. This function has the expressions corresponding to each interaction between the species in a certain reaction. Each value of the propensity function is multiplied by its respective value in the stoichiometric matrix.


```
#stoichiometric matrix
V = products - reactants

#pre-propensity function
aPro = parsValues
aPro[ruh] = aPro[ruh]*uh[0]  # adds input to the corresponding reaction

#reaction network dimentions
Sn, Rm = V.shape

#propensity function vector
for r in range(0,Rm):
    for s in range(0, Sn):
        #determine species interactions simbolically
        for a in range(0, reactants[s,r]):
            aPro[r] *= species[s]
        #end for a
    #end for s
#end for r
            
#differential equations system
odeX = []
for s in range(0,Sn):
    temp = 0
    #define each equation of the system
    for r in range(0, Rm):
        temp += V[s,r]*aPro[r]
    #end for r
    
    #set of equations
    odeX.append(temp)
#end for s
```

**Differential Equations System** Each differential equation represents a different species and how it interacts with the other species. Usually, the last equation serves as the equation to compute the gene expression in a certain biological system.


```
#Shows the differential equations system
for s in range(0, Sn):
    print(f'd{species[s]}/dt:', odeX[s])
```

    dx1/dt: c1*u - c2*x1
    dx2/dt: c3*x1 - c4*x2


ed3d7919e1d22473297ebcb0d8fd2f3e96a4d713
ipynb
Jupyter Notebook
Single_Units/simbODE.ipynb
Jebrayam/systemsbiology
65041a2bf6c5e06842042a0bdf5f7528c778fe3f
MIT
Single_Units/simbODE.ipynb
Jebrayam/systemsbiology
65041a2bf6c5e06842042a0bdf5f7528c778fe3f
MIT
2020-10-16T03:30:51.000Z
2020-10-16T03:33:01.000Z
Single_Units/simbODE.ipynb
Jebrayam/systemsbiology
65041a2bf6c5e06842042a0bdf5f7528c778fe3f
MIT
Qwen/Qwen-72B
1. YES
2. YES