biocrnpyler.components.Integrase_Enumerator
- class biocrnpyler.components.Integrase_Enumerator(name: str, int_mechanisms=None)[source]
Bases:
GlobalComponentEnumeratorGlobal enumerator for integrase-mediated DNA recombination products.
An
Integrase_Enumeratorsystematically enumerates all possible DNA constructs that can result from integrase-mediated recombination reactions. Examines all components for integrase attachment sites and generates products for all allowed site pairs.- Parameters:
name (
str) – Name identifier for the enumerator.int_mechanisms (
dict, optional) – Dictionary mapping integrase names (str) to IntegraseRule objects. Default: {‘int1’: IntegraseRule()}
- Attributes:
int_mechanisms (
dict) – Dictionary of integrase rules.
See also
GlobalComponentEnumeratorBase class for global enumeration.
IntegraseRuleDefines integrase recombination rules.
IntegraseSiteDNA part for attachment sites.
Polymer_transformationTemplate for DNA rearrangements.
Notes
Enumeration process:
Identify all integrase attachment sites in components
Group sites by integrase type
For each integrase:
Find all valid site pairs (from reactive_sites)
Check if pair can react (reaction_allowed)
Perform integration to generate products
Store transformation templates in sites
Return list of new DNA constructs
This is a global enumerator because integrase reactions can occur between sites on different constructs (intermolecular reactions). Access to all components is necessary.
Integrase Types Supported:
Serine integrases (attB/attP \(\rightarrow\) attL/attR)
Tyrosine recombinases (Cre, Flp with homotypic sites)
Invertases (inversion only)
Resolvases (deletion only)
Custom integrase rules
The
find_dna_constructmethod is used to detect duplicates including circular permutations and reversals, preventing redundant construct generation.Examples
Create an integrase enumerator:
>>> phi_c31 = bcp.IntegraseRule( ... name='PhiC31', ... reactions={ ... ('attB', 'attP'): 'attL', ... ('attP', 'attB'): 'attR' ... } ... ) >>> enumerator = bcp.Integrase_Enumerator( ... name='integrase_enum', ... int_mechanisms={'PhiC31': phi_c31} ... )
Use in a mixture:
>>> mixture = bcp.Mixture( ... components=[plasmid1, plasmid2], ... global_component_enumerators=[enumerator] ... ) >>> # Enumerator automatically called during compilation >>> crn = mixture.compile_crn()
Manual enumeration:
>>> constructs = [plasmid_with_attB, plasmid_with_attP] >>> new_constructs = enumerator.enumerate_components(constructs) >>> # new_constructs contains integrated plasmids
Methods
Enumerate all possible integrase-mediated DNA configurations.
Find matching construct in list (handles permutations/reversals).
List all integrase attachment sites in a construct.
Reset linked_sites attribute in all attachment sites.
- enumerate_components(components=None, previously_enumerated=None, **kwargs)[source]
Enumerate all possible integrase-mediated DNA configurations.
Systematically generates all DNA constructs that can result from integrase recombination between attachment sites in the input components.
- Parameters:
- Returns:
List of newly created DNA constructs from all allowed integrase reactions.
- Return type:
listofConstruct
Notes
Enumeration algorithm:
Extract all DNA_construct components
List all integrase sites by integrase type
For each integrase in int_mechanisms:
Get all attachment sites for that integrase
Find reactive site types from IntegraseRule
Generate all site pairs (combinations)
For each valid pair:
Check if reaction_allowed
Perform
integrateto generate productsAdd new constructs to output list
Return all newly generated constructs
Depending on the
IntegraseRulesettings, the following reaction types are generated:Inversions (same construct, opposite directions)
Deletions (same construct, same direction)
Integrations (different constructs, at least one circular)
Recombinations (two linear constructs)
The
integratemethod checks existing_dna_constructs (includes both previously_enumerated and newly created constructs) to avoid generating duplicates.Examples
Enumerate integration products:
>>> enumerator = bcp.Integrase_Enumerator( ... name='enum', ... int_mechanisms={'PhiC31': phi_c31_rule} ... ) >>> plasmids = [donor_plasmid, target_plasmid] >>> products = enumerator.enumerate_components(plasmids) >>> # products contains integrated plasmids
- classmethod find_dna_construct(construct: Construct, conlist: List[Construct])[source]
Find matching construct in list (handles permutations/reversals).
Searches for a construct equivalent to the input, accounting for circular permutations and reversals.
- Parameters:
- Returns:
If found: (matched_construct, index_function), where index_function maps old indexes to (new_index, direction). If not found: None.
- Return type:
tupleof(Construct,callable)orNone- Raises:
KeyError – If construct matches multiple constructs in list (should not happen with proper generation order).
Notes
For circular constructs, the following matching logic is used:
Try all circular permutations
For each permutation, try forward and reverse orientations
For linear constructs, the following matching logic is used:
Try forward orientation
Try reverse orientation
Uses
directionless_hashfor fast initial filtering before detailed species comparison.
- list_integrase(construct)[source]
List all integrase attachment sites in a construct.
- Parameters:
construct (
Construct) – DNA construct to examine.- Returns:
Dictionary mapping integrase names (str) to lists of IntegraseSite objects.
- Return type:
dict
- reset(components=None, **kwargs)[source]
Reset linked_sites attribute in all attachment sites.
Clears stored integration reactions from all integrase sites in components, preparing for fresh enumeration.
- Parameters:
components (
listofComponent) – Components containing integrase sites to reset.**kwargs – Additional keyword arguments (unused).
Notes
Called at the start of enumeration to clear previous integration data.