BioNetGen FAQ
From BioNetWiki
Contents |
General questions
What units does BioNetGen use? How do I convert experimentally measured parameters into these units?
Questions on Species
How do I specify a species with a fixed concentration?
To fix the concentration of a user-defined species, simply prepend a '$' to the species declaration as shown in the following example in which the concentration of the species A(a) is declared to be fixed.
begin parameters
1 kp1 1
2 km1 100
end parameters
begin molecule types
1 A(a)
2 B(b)
end molecule types
begin species
1 $A(a) 1
2 B(b) 1
end species
begin reaction rules
A(a) + B(b) -> A(a!1).B(b!1) kp1
end reaction rules
generate_network({overwrite=>1});
simulate_ode({t_end=>10,n_steps=>20});
The species A(a) will not be depleted, even though the amount of the A.B complex will increase. Note that the total concentration of A molecules will increase.
Questions on Patterns
Questions on Reaction Rules
What is the proper way to allow for degradation of a species?
There are a number of subtle points here, and for those who aren't interested in the details I provide a few recipes. A more complete description follows these. Please feel free to add examples. Note also that these examples all use first order rate processes.
Degradation of the entire species in which a molecule appears. To specify the degradation of all species containing the molecule A, you would write
A() -> Trash() k1
where Trash is a dummy molecule defined in the Molecule types list. Any reactant molecule that is not referenced on the product side of the reaction is automatically deleted, along with any associated bonds, when the reaction is generated. Here, the only molecule in the reactant pattern is deleted, so the entire species containing the molecule A will be deleted. If there are complexes in the model in which multiple A molecules appear and the number of A's doesn't affect the degradation rate you should add the MatchOnce qualifier as follows
{MatchOnce}A() -> Trash() k1
Degrading a molecule in a specific complex. The specify the degradation of the molecule A in a complex containing A and B, you would write
A().B() -> B() k2
Note that if the deletion of A from the complex leaves behind molecules that are not connected to B, the reaction will not be made, because the number of products will not match that specified by the rule. If you wish to allow A to be deleted and any number of products to result, you can add the keyword DeleteMolecules after the rate law
A().B() -> B() k2 DeleteMolecules
which will allow A to be deleted from this complex, leaving behind B and whatever other species.
Degrading a molecule in a generic complex. The DeleteMolecules keyword can also be used in rules of the first type to specify the deletion of only matching molecules from a complex, as in
A() -> Trash() k1 DeleteMolecules
which produces reactions that delete any instance of A in a complex.
A BNGL file that illustrates all three types is shown below
begin parameters
k1 1
k2 2
k3 3
end parameters
begin molecule types
CELL()
Ste2(Pheromone_site,Gpa1_site,Sst2_site,Yck_site,S338_S339~none~PO4)
Pheromone(Ste2_site)
end molecule types
begin species
Pheromone(Ste2_site!1).Ste2(Pheromone_site!1,Gpa1_site,Sst2_site,Yck_site,S338_S339~PO4) 1
end species
begin reaction rules
Ste2(S338_S339~PO4) -> CELL() k1
Ste2(S338_S339~PO4).Pheromone() -> Pheromone() k2
Ste2(S338_S339~PO4) -> CELL() k3 DeleteMolecules
end reaction rules
generate_network({overwrite=>1,max_iter=>1});
How do I delete only free A?
This is a trick question from a BNG master...but it's also something you might want to do and it reveals a slight shortcoming in the current syntax of the language, i.e. that there is currently no simple way to refer to the binding state of a whole molecule. Here's what you would do now to delete a free molecule A with components a, b, and c.
A(a,b,c) -> Trash() k1
All components of A must be specified to guarantee that each is not bound. This is problematic, because if I now add a component d to A that can bind components of other molecules, I must change the rule to make sure that d is also not bound. As a language extension, I would propose that the binding state of a molecule be queryable and that the '!' character act as a NOT wildcard, as in
A!!() -> Trash() k1 # PROPOSED, not implemented
where the first pattern selects species in which the molecule A is not bound to anything, i.e. free A.
What is the proper way to specify production of a species?
Questions on Performing Simulations
Is there a way to load a generated network in a bngl file, so that I don't have to run generate_network every time I want to run a simulation?
There are currently two ways of doing this depending on your needs.
Method I. Use the readFile command to read a previously generated network file into BNG. The following example uses the .net file generated by running BNG on the toy-jim.bngl file provided in the Models2 directory of the distribution.
readFile({prefix=>"run_toy",file=>"toy-jim.net"});
# Equilibration
setConcentration("L(r)",0);
simulate_ode({suffix=>"equil",t_end=>1000,n_steps=>10,sparse=>1,steady_state=>1});
# Kinetics
# Add the ligand
setConcentration("L(r)","L_tot");
simulate_ode({suffix=>"kinetics",t_end=>120,n_steps=>12});
This example also illustrates how the simulate_ode command can be used with the steady_state to equilibrate a model. The concentration of the ligand is set to zero using the setConcentration command, and then restored prior to second simulate_ode command.
Method II. Use the netfile flag to the simulate command to direct the simulation program (run_network) to read the .net file directly.
simulate_ode({netfile=>"toy-jim.net",prefix=>"run_toy2",t_end=>120,n_steps=>12});
Method II gives faster performance, but does not permit the model parameters to be changed in BNG, since the model is never actually read into the BNG program. Instead the file name is passed to the simulation program.
