batss.crn

Module for expressing population protocols using CRN notation. Ideas and much code taken from https://github.com/enricozb/python-crn.

The general syntax is

a, b, u = species('A B U')
approx_majority = [
    a + b >> 2 * u,
    a + u >> 2 * a,
    b + u >> 2 * b,
]
n = 10 ** 5
init_config = {a: 0.51 * n, b: 0.49 * n}
sim = Simulation(init_config=init_config, rule=approx_majority)

In other words, a list of reactions is treated by the batss library just like the other ways of specifying population protocol transitions (the rule parameter in the constructor for batss.simulation.Simulation, which also accepts a dict or a Python function).

More examples given in https://github.com/UC-Davis-molecular-computing/batss/tree/main/examples

Functions

catalyst_specie()

concentration_to_count(concentration, volume)

convert_to_uniform(crn, volume)

Convert a CRN to an equivalent uniform CRN.

convert_unimolecular_to_bimolecular_and_flip_reactant_order(...)

Process all reactions before being added to the dictionary.

extra_species()

gillespy2_format(init_config, rxns[, volume])

Create a gillespy2 Model object from a CRN description.

gpac_format(rxns, init_config)

Create a gpac CRN in the form of equivalent initial configuration and list of gpac Reaction objects.

reactions_to_dict(reactions, n, volume)

Returns dict representation of reactions, transforming unimolecular reactions to bimolecular, and converting rates to probabilities, also returning the max rate so the ppsim.simulation.Simulation knows how to scale time.

replace_reversible_rxns(rxns)

species(sp)

Create a list of Specie (Single species Expression's), or a single one.

species_in_rxns(rxns)

stochkit_format(rxns, init_config[, volume, ...])

waste_specie()

write_stochkit_file(filename, rxns, init_config)

Write stochkit file :type filename: str :param filename: name of file to write :type rxns: Iterable[Reaction] :param rxns: reactions to translate to StochKit format :type init_config: dict[Specie, int] :param init_config: dict mapping each Specie to its initial count :type volume: float :param volume: volume in liters :type name: str :param name: name of the CRN

Classes

CRN(reactions, species)

Representation of a CRN, a set of reactions.

Expression(species)

Class used for very basic symbolic manipulation of left/right hand side of stoichiometric equations.

RateConstantUnits(*values)

Reaction(reactants, products[, k, r, ...])

Representation of a stoichiometric reaction using a pair of Expressions, one for the reactants and one for the products.

Specie(name[, is_special_specie])