biocrnpyler.components.IntegraseRule
- class biocrnpyler.components.IntegraseRule(name=None, reactions=None, allow_deletion=True, allow_integration=True, allow_inversion=True)[source]
Bases:
objectRules defining integrase recombination reactions and products.
An
IntegraseRulespecifies how an integrase enzyme acts on attachment sites to generate recombined DNA products. Defines which site pairs can react, what products they form, and which reaction types (deletion, integration, inversion) are allowed.- Parameters:
name (
str, optional) – Name of the integrase (default=’int1’).reactions (
dict, optional) – Dictionary mapping (site1_type, site2_type) tuples to product site type. Default: {(‘attB’, ‘attP’): ‘attL’, (‘attP’, ‘attB’): ‘attR’}allow_deletion (
bool, defaultTrue) – Whether to allow deletion reactions (intramolecular, same direction).allow_integration (
bool, defaultTrue) – Whether to allow integration reactions (intermolecular).allow_inversion (
bool, defaultTrue) – Whether to allow inversion reactions (intramolecular, opposite directions).
- Attributes:
name (
str) – Integrase name.integrase_species (
Species) – The integrase protein species.reactions (
dict) – Reaction rules mapping site pairs to products.attsites (
list) – All attachment site types involved in reactions.allow_deletion (
bool) – Whether deletions are allowed.allow_integration (
bool) – Whether integrations are allowed.allow_inversion (
bool) – Whether inversions are allowed.integrations_to_do (
list) – List of integrations to perform during compilation.
See also
IntegraseSiteDNA part representing attachment sites.
Integrase_EnumeratorEnumerator using integrase rules.
Polymer_transformationTemplate for DNA transformations.
Notes
Integrase mechanism types:
Serine Integrases:
Recombine attB + attP \(\rightarrow\) attL + attR
Require matching dinucleotides
With directionality factors: attL + attR \(\rightarrow\) attB + attP
Tyrosine Recombinases (Cre, Flp):
Homotypic sites: loxP + loxP \(\rightarrow\) loxP + loxP
Can be palindromic (bidirectional)
Invertases:
Only perform inversion reactions
Set allow_deletion=False, allow_integration=False
Resolvases:
Only perform deletion reactions
Set allow_inversion=False, allow_integration=False
Reaction Types:
Inversion: Two sites on same DNA, opposite directions \(\rightarrow\) region between sites flips
Deletion: Two sites on same DNA, same direction \(\rightarrow\) region between sites excised (forms circular product)
Integration: Sites on different DNAs \(\rightarrow\) DNAs join
Recombination: Two linear DNAs \(\rightarrow\) two recombinant linear DNAs
Examples
Define a standard serine integrase:
>>> int_rule = bcp.IntegraseRule( ... name='PhiC31', ... reactions={ ... ('attB', 'attP'): 'attL', ... ('attP', 'attB'): 'attR' ... } ... )
Define a Cre recombinase (homotypic):
>>> cre_rule = bcp.IntegraseRule( ... name='Cre', ... reactions={ ... ('loxP', 'loxP'): 'loxP', ... ('loxP', 'loxP'): 'loxP' # Symmetric ... } ... )
Define an invertase (inversion only):
>>> inv_rule = bcp.IntegraseRule( ... name='Hin', ... reactions={('hixL', 'hixR'): 'hixL', ('hixR', 'hixL'): 'hixR'}, ... allow_deletion=False, ... allow_integration=False ... )
Methods
Get all attachment site types this integrase binds to.
Generate product sites from recombination of two sites.
Perform integrase recombination between two attachment sites.
Check if two sites can undergo integrase recombination.
Get attachment site types that participate in reactions.
- binds_to()[source]
Get all attachment site types this integrase binds to.
- Returns:
List of all site types involved in integrase reactions.
- Return type:
listofstr
- generate_products(site1, site2, site2_parent=None)[source]
Generate product sites from recombination of two sites.
Creates IntegraseSite objects for the products of site1 + site2 recombination according to the reaction rules.
- Parameters:
site1 (
IntegraseSite) – First attachment site (determines product ordering).site2 (
IntegraseSite) – Second attachment site.site2_parent (
Polymer, optional) – Parent polymer for site2 (used in intermolecular reactions).
- Returns:
Product sites at positions corresponding to site1 and site2.
- Return type:
tupleof(IntegraseSite,IntegraseSite)- Raises:
AssertionError – If sites have mismatched integrases or dinucleotides.
KeyError – If site pair is not in reaction rules.
Notes
Product sites inherit dinucleotides and integrase from reactants. Product order depends on site1 direction:
site1 forward: return (prod1, prod2)
site1 reverse: return (prod2, prod1) with swapped directions
- integrate(site1, site2, also_inter=True, force_inter=False, existing_dna_constructs=None)[source]
Perform integrase recombination between two attachment sites.
Executes an integration reaction between site1 and site2, creating new DNA constructs based on the reaction type (inversion, deletion, integration, or recombination). Stores transformation templates in the sites’ linked_sites attribute.
- Parameters:
site1 (
IntegraseSite) – First attachment site (must have Construct parent).site2 (
IntegraseSite) – Second attachment site (must have Construct parent).also_inter (
bool, defaultTrue) – If True and reaction is intramolecular, also generate intermolecular version (between two copies of same plasmid).force_inter (
bool, defaultFalse) – Force reaction to be treated as intermolecular even if sites are on same construct.existing_dna_constructs (
listofConstruct, optional) – List of previously generated constructs to check for duplicates.
- Returns:
List of newly created DNA constructs from the integration.
- Return type:
listofConstruct- Raises:
ValueError – If either site is not part of a Construct.
Notes
Four reaction types:
Inversion (intramolecular, opposite directions):
Same construct, sites point opposite directions
Result: Region between sites is flipped
Circularity preserved
Deletion (intramolecular, same direction):
Same construct, sites point same direction
Result: Two constructs - one with deleted region, one circular excised fragment
Integration (intermolecular, one circular):
Sites on different constructs, one circular
Result: Single construct (circular if both were circular)
Recombination (intermolecular, both linear):
Sites on two linear constructs
Result: Two recombinant linear constructs
Polymer_transformation templates are stored in:
site1.linked_sites[(site2, intermolecular)]
site2.linked_sites[(site1, intermolecular)]
These templates are used during CRN compilation to generate reactions and species.
Existing_dna_constructs are checked for matches (including circular permutations and reversals) to avoid creating duplicates.
Examples
Inversion reaction:
>>> # Two sites on same plasmid, opposite directions >>> int_rule.integrate(attB_site, attP_site_reversed) # Creates inverted plasmid
Integration reaction:
>>> # Sites on different plasmids >>> int_rule.integrate( ... plasmid1_attB, ... plasmid2_attP, ... existing_dna_constructs=prev_constructs ... ) # Creates integrated plasmid
- reaction_allowed(site1, site2)[source]
Check if two sites can undergo integrase recombination.
- Parameters:
site1 (
IntegraseSite) – First attachment site.site2 (
IntegraseSite) – Second attachment site.
- Returns:
True if sites can react according to reaction rules.
- Return type:
bool- Raises:
AssertionError – If sites have different integrases or do not match this integrase.