biocrnpyler.mechanisms.Dilution
- class biocrnpyler.mechanisms.Dilution(name='global_degradation_via_dilution', mechanism_type='dilution', filter_dict=None, default_on=True, recursive_species_filtering=True)[source]
Bases:
GlobalMechanismGlobal mechanism for species dilution or degradation.
A ‘dilution’ mechanism that removes species from the system at a rate proportional to their concentration. This models dilution due to cell growth, continuous flow in a bioreactor, or general degradation processes.
The dilution reaction for each species is
\[{\text{S}} \rightarrow \emptyset \]where S is any species and the rate is determined by ‘kdil’.
- Parameters:
name (
str, default'global_degradation_via_dilution') – Name identifier for this mechanism instance.mechanism_type (
str, default'dilution') – Type classification of this mechanism.filter_dict (
dict, optional) – Dictionary for filtering which species undergo dilution. If None, all species are affected based on default_on.default_on (
bool, defaultTrue) – If True, dilution applies to all species not explicitly filtered out. If False, dilution applies only to explicitly filtered species.recursive_species_filtering (
bool, defaultTrue) – If True, filters based on all subspecies within ComplexSpecies. If False, filters only the ComplexSpecies itself.
- Attributes:
name (
str) – Name of the mechanism instance.mechanism_type (
str) – Type classification (‘dilution’).filter_dict (
dict) – Dictionary for filtering species.default_on (
bool) – Default behavior for unfiltered species.recursive_species_filtering (
bool) – Whether to filter ComplexSpecies recursively.
See also
AntiDilutionConstitutiveCreationCounter-mechanism for constant concentration.
GlobalMechanismBase class for global mechanisms.
Notes
This mechanism generates a single irreversible mass-action reaction for each species that passes the filter, with rate constant ‘kdil’. By default, it applies to all species (default_on=True) unless specific species are excluded via the filter_dict.
Common applications include:
Modeling cell growth and dilution in batch cultures
Continuous flow bioreactor systems
Simplified degradation for all cellular components
Washout effects in chemostats
Required parameters for this mechanism:
‘kdil’ : Dilution rate constant (per species if needed)
The mechanism can be selectively applied using filter_dict. For example, to exclude specific species from dilution, set filter_dict={‘notdiluted’: False} and tag those species with the ‘notdiluted’ attribute.
Examples
Apply dilution to all species in a mixture:
>>> dilution_mech = bcp.Dilution(default_on=True) >>> mixture = bcp.Mixture( ... components=[bcp.Protein('A'), bcp.Protein('B')], ... mechanisms={'dilution': dilution_mech}, ... parameters={'kdil': 0.01} ... )
Apply dilution only to proteins, excluding DNA:
>>> dilution_mech = bcp.Dilution( ... filter_dict={'protein': True, 'dna': False}, ... default_on=False ... ) >>> mixture = bcp.Mixture( ... components=[bcp.Protein('P'), bcp.DNA('gene')], ... mechanisms={'dilution': dilution_mech}, ... parameters={'kdil': 0.01} ... )
Methods
Determine if the global mechanism should act on a species.
Retrieve a parameter value from the mixture for a given species.
Generate dilution reaction for a single species.
Apply mechanism's
update_reactionsto filtered species in a list.Generate new species for a global mechanism acting on one species.
Apply mechanism's update_species to filtered species in a list.
- apply_filter(s: Species)[source]
Determine if the global mechanism should act on a species.
Checks the species’s material_type, attributes, and name against the filter dictionary to decide if the mechanism should be applied.
- Parameters:
s (
Species) – The species to check against the filter dictionary.- Returns:
True if the mechanism should act on this species, False otherwise.
- Return type:
bool
Notes
The filtering logic follows this hierarchy:
Checks all attributes and material_type of the species (and subspecies if recursive_species_filtering is True)
If any match is found in filter_dict, uses that boolean value
If conflicts occur (different attributes give different results), issues a warning and uses default_on
If no match is found, uses default_on
- get_parameter(species, param_name, mixture)[source]
Retrieve a parameter value from the mixture for a given species.
- Parameters:
- Returns:
The parameter value retrieved from the mixture.
- Return type:
Parameterorfloat- Raises:
ValueError – If no parameter matching the (mechanism, species, param_name) combination can be found.
- update_reactions(s: Species, mixture)[source]
Generate dilution reaction for a single species.
Creates an irreversible mass-action reaction that removes the species from the system at rate ‘kdil’.
- update_reactions_global(species_list: List[Species], mixture, compartment=None)[source]
Apply mechanism’s
update_reactionsto filtered species in a list.Iterates through all species in the list, applies the filter to determine which species the mechanism acts upon, and calls
update_reactionsfor each applicable species.- Parameters:
species_list (
listofSpecies) – List of all species to potentially act upon.mixture (
Mixture) – The mixture containing parameters and other context.compartment (
Compartment, optional) – If provided, assigns this compartment to species that have the default compartment before generating reactions.
- Returns:
List of all new reactions generated by the mechanism.
- Return type:
listofReaction
- update_species(s: Species, mixture)[source]
Generate new species for a global mechanism acting on one species.
This is a template method that should be overridden by subclasses to define the species generated by the mechanism.
- Parameters:
- Returns:
List of new species generated by the mechanism. Default implementation returns an empty list.
- Return type:
listofSpecies
Notes
All GlobalMechanism subclasses should implement this method if they need to generate new species (e.g., enzyme-substrate complexes for degradation mechanisms).
- update_species_global(species_list: List[Species], mixture, compartment=None)[source]
Apply mechanism’s update_species to filtered species in a list.
Iterates through all species in the list, applies the filter to determine which species the mechanism acts upon, and calls update_species for each applicable species.
- Parameters:
species_list (
listofSpecies) – List of all species to potentially act upon.mixture (
Mixture) – The mixture containing parameters and other context.compartment (
Compartment, optional) – If provided, assigns this compartment to any new species that have the default compartment.
- Returns:
List of all new species generated by the mechanism.
- Return type:
listofSpecies