biocrnpyler.components.IntegraseRule

class biocrnpyler.components.IntegraseRule(name=None, reactions=None, allow_deletion=True, allow_integration=True, allow_inversion=True)[source]

Bases: object

Rules defining integrase recombination reactions and products.

An IntegraseRule specifies 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, default True) – Whether to allow deletion reactions (intramolecular, same direction).

  • allow_integration (bool, default True) – Whether to allow integration reactions (intermolecular).

  • allow_inversion (bool, default True) – 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

IntegraseSite

DNA part representing attachment sites.

Integrase_Enumerator

Enumerator using integrase rules.

Polymer_transformation

Template for DNA transformations.

Notes

Integrase mechanism types:

  1. Serine Integrases:

    • Recombine attB + attP \(\rightarrow\) attL + attR

    • Require matching dinucleotides

    • With directionality factors: attL + attR \(\rightarrow\) attB + attP

  2. Tyrosine Recombinases (Cre, Flp):

    • Homotypic sites: loxP + loxP \(\rightarrow\) loxP + loxP

    • Can be palindromic (bidirectional)

  3. Invertases:

    • Only perform inversion reactions

    • Set allow_deletion=False, allow_integration=False

  4. 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

binds_to

Get all attachment site types this integrase binds to.

generate_products

Generate product sites from recombination of two sites.

integrate

Perform integrase recombination between two attachment sites.

reaction_allowed

Check if two sites can undergo integrase recombination.

reactive_sites

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:

list of str

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:

tuple of (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, default True) – If True and reaction is intramolecular, also generate intermolecular version (between two copies of same plasmid).

  • force_inter (bool, default False) – Force reaction to be treated as intermolecular even if sites are on same construct.

  • existing_dna_constructs (list of Construct, optional) – List of previously generated constructs to check for duplicates.

Returns:

List of newly created DNA constructs from the integration.

Return type:

list of Construct

Raises:

ValueError – If either site is not part of a Construct.

Notes

Four reaction types:

  1. Inversion (intramolecular, opposite directions):

    • Same construct, sites point opposite directions

    • Result: Region between sites is flipped

    • Circularity preserved

  2. Deletion (intramolecular, same direction):

    • Same construct, sites point same direction

    • Result: Two constructs - one with deleted region, one circular excised fragment

  3. Integration (intermolecular, one circular):

    • Sites on different constructs, one circular

    • Result: Single construct (circular if both were circular)

  4. 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:
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.

reactive_sites()[source]

Get attachment site types that participate in reactions.

Returns:

List of site types that can be reactants (not just products).

Return type:

list of str