Skip to content

Commit

Permalink
wip: integrated enzyme choices for all workflows now
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyama341 committed Oct 16, 2024
1 parent 1369480 commit cf56af4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
26 changes: 19 additions & 7 deletions web_app/callbacks/workflow_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import logging
import sys
import io
from Bio.Restriction import *
from Bio import Restriction


# Create a StringIO object to capture logs in memory
Expand Down Expand Up @@ -131,7 +133,9 @@ def register_workflow_3_callbacks(app):
State('backbone-overhang-f', 'value'),
State('backbone-overhang-r', 'value'),
State('cys4-sequence', 'value'),
State('editing_context_3', 'value')
State('editing_context_3', 'value'),
State('restriction-enzymes_3', 'value')
]
)
Expand All @@ -141,7 +145,7 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect
number_of_sgRNAs_per_group, only_stop_codons, chosen_polymerase, melting_temperature,
primer_concentration, flanking_region_number,
restriction_overhang_f, restriction_overhang_r, backbone_overhang_f, backbone_overhang_r, cys4_sequence,
editing_context):
editing_context, restriction_enzymes):

if n_clicks is None:
raise PreventUpdate
Expand Down Expand Up @@ -215,10 +219,15 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect
logger.info(f"sgRNA list prepared: {len(sgRNA_list)} sequences")

sgRNA_handle_cys4_sites = [Dseqrecord(sgRNA_handle_input, name='sgRNA_handle_cys4')] * len(sgRNA_list)
golden_gate = GoldenGateCloning(sgRNA_list, sgRNA_handle_cys4_sites, target_tm=input_tm,
restriction_overhang_f=restriction_overhang_f, restriction_overhang_r=restriction_overhang_r,
backbone_overhang_f=backbone_overhang_f, backbone_overhang_r=backbone_overhang_r,
cys4=cys4_sequence, tm_function=primer_tm_neb,
golden_gate = GoldenGateCloning(sgRNA_list,
sgRNA_handle_cys4_sites,
target_tm=input_tm,
restriction_overhang_f=restriction_overhang_f,
restriction_overhang_r=restriction_overhang_r,
backbone_overhang_f=backbone_overhang_f,
backbone_overhang_r=backbone_overhang_r,
cys4=cys4_sequence,
tm_function=primer_tm_neb,
polymerase=chosen_polymerase)
logger.info("Golden Gate Cloning setup completed.")

Expand All @@ -242,8 +251,11 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect

digest_amplicons = digest_amplicons_w_BsaI(list_of_amplicons)
logger.info(f"Amplicons digested: {len(digest_amplicons)} fragments")
# Cut plasmid
restriction_enzymes = restriction_enzymes.split(',')
enzymes_for_repair_template_integration = [getattr(Restriction, str(enzyme)) for enzyme in restriction_enzymes]

linear_plasmid, _ = sorted(clean_plasmid.cut(NcoI, NheI), key=lambda x: len(x), reverse=True)
linear_plasmid = sorted(clean_plasmid.cut(enzymes_for_repair_template_integration), key=lambda x: len(x), reverse=True)[0]
logger.info("Plasmid linearized.")

for amplicon in digest_amplicons:
Expand Down
13 changes: 10 additions & 3 deletions web_app/callbacks/workflow_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from Bio.Restriction import NcoI
from pydna.dseqrecord import Dseqrecord
from teemi.design.fetch_sequences import read_genbank_files
from Bio.Restriction import *
from Bio import Restriction

from dash import dcc, html, dash_table, exceptions
from dash.dependencies import Input, Output, State
Expand Down Expand Up @@ -95,12 +97,14 @@ def register_workflow_4_callbacks(app):
State('off-target-upper_4', 'value'),
State('cas-type_4', 'value'),
State('number-of-sgRNAs-per-group_4', 'value'),
State('extension-to-promoter-region_4', 'value')
State('extension-to-promoter-region_4', 'value'),
State('restriction-enzymes_4', 'value')
]
)
def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vector_filename, genes_to_KO,
up_homology, dw_homology, gc_upper, gc_lower, off_target_seed, off_target_upper, cas_type,
number_of_sgRNAs_per_group, extension_to_promoter_region):
number_of_sgRNAs_per_group, extension_to_promoter_region, restriction_enzymes):
if n_clicks is None:
raise PreventUpdate

Expand Down Expand Up @@ -155,7 +159,10 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect
logging.debug(f"List of ssDNAs: {list_of_ssDNAs}")

logging.info("Cutting plasmid")
linearized_plasmid = sorted(clean_plasmid.cut(NcoI), key=lambda x: len(x), reverse=True)[0]
restriction_enzymes = restriction_enzymes.split(',')
enzymes_for_repair_template_integration = [getattr(Restriction, str(enzyme)) for enzyme in restriction_enzymes]

linearized_plasmid = sorted(clean_plasmid.cut(enzymes_for_repair_template_integration), key=lambda x: len(x), reverse=True)[0]
logging.debug(f"Linearized plasmid: {linearized_plasmid}")

logging.info("Assembling plasmid")
Expand Down
19 changes: 14 additions & 5 deletions web_app/callbacks/workflow_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import dash_bootstrap_components as dbc

from dash.exceptions import PreventUpdate
from Bio.Restriction import NcoI
from Bio.Restriction import *
from Bio import Restriction


# Local module imports
Expand Down Expand Up @@ -101,13 +102,17 @@ def register_workflow_5_callbacks(app):
State('flanking-region-number_5', 'value'),
State('repair_templates_length_5', 'value'),
State('overlap_for_gibson_length_5', 'value'),
State('restriction-enzymes_5', 'value'),
State('restriction-enzymes_5-2', 'value')
]
)
def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vector_filename, genes_to_KO,
up_homology, dw_homology, gc_upper, gc_lower, off_target_seed, off_target_upper, cas_type,
number_of_sgRNAs_per_group, in_frame_deletion, chosen_polymerase, melting_temperature,
primer_concentration, flanking_region_number,
repair_templates_length, overlap_for_gibson_length):
repair_templates_length, overlap_for_gibson_length, restriction_enzymes, restriction_enzymes_2):
if n_clicks is None:
raise PreventUpdate

Expand Down Expand Up @@ -165,7 +170,9 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect
downstream_ovh=dw_homology)

# cut plasmid
linearized_plasmid = sorted(clean_plasmid.cut(NcoI), key=lambda x: len(x), reverse=True)[0]
restriction_enzymes = restriction_enzymes.split(',')
enzymes_for_repair_template_integration = [getattr(Restriction, str(enzyme)) for enzyme in restriction_enzymes]
linearized_plasmid = sorted(clean_plasmid.cut(enzymes_for_repair_template_integration), key=lambda x: len(x), reverse=True)[0]
#print(linearized_plasmid)

sgRNA_vectors = assemble_plasmids_by_ssDNA_bridging(list_of_ssDNAs,linearized_plasmid)
Expand Down Expand Up @@ -196,7 +203,9 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect
logging.info(f"Repair templates data: {repair_templates_data}")

# Digest the plasmids
processed_records = [Dseqrecord(record, circular=True).cut(StuI)[0] for record in sgRNA_vectors]
restriction_enzymes_2 = restriction_enzymes_2.split(',')
enzymes_for_repair_template_integration_2 = [getattr(Restriction, str(enzyme)) for enzyme in restriction_enzymes_2]
processed_records = [Dseqrecord(record, circular=True).cut(enzymes_for_repair_template_integration_2)[0] for record in sgRNA_vectors]
logging.info(f"processed_records: {processed_records}")

# Rename them appropriately
Expand Down Expand Up @@ -250,7 +259,7 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect

workflow_df = determine_workflow_order_for_plasmids(sgRNA_vectors,
assembled_contigs,
["StuI",], [ "NcoI"])
restriction_enzymes_2, restriction_enzymes)

plasmid_metadata_df = pd.merge(plasmid_metadata_df, workflow_df, on='plasmid_name', how='inner')

Expand Down
7 changes: 4 additions & 3 deletions web_app/callbacks/workflow_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def register_workflow_6_callbacks(app):
def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vector_filename, genes_to_KO,
forward_protospacer_overhang, reverse_protospacer_overhang, gc_upper, gc_lower, off_target_seed, off_target_upper, cas_type,
number_of_sgRNAs_per_group, in_frame_deletion, chosen_polymerase, melting_temperature,
primer_concentration, flanking_region_number, enzyme_for_repair_template_integration,
primer_concentration, flanking_region_number, restriction_enzymes_2,
repair_templates_length, overlap_for_gibson_length, backbone_fwd_overhang, backbone_rev_overhang):
if n_clicks is None:
raise PreventUpdate
Expand Down Expand Up @@ -209,7 +209,8 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect
primer_tm_kwargs={'conc':primer_concentration, 'prodcode':chosen_polymerase} ,
repair_length=repair_templates_length)
# Convert the lists to a list of enzyme object
enzymes_for_repair_template_integration = [getattr(Restriction, str(enzyme)) for enzyme in enzymes_for_repair_template_integration]
restriction_enzymes_2 = restriction_enzymes_2.split(',')
enzymes_for_repair_template_integration = [getattr(Restriction, str(enzyme)) for enzyme in restriction_enzymes_2]

logging.info("Digesting plasmids with enzyme_for_repair_template_integration.")
processed_records = [sorted(Dseqrecord(record, circular=True).cut(enzymes_for_repair_template_integration), key=lambda x: len(x), reverse=True)[0] for record in assembled_cas3_plasmids]
Expand Down Expand Up @@ -250,7 +251,7 @@ def run_workflow(n_clicks, genome_content, vector_content, genome_filename, vect

workflow_df = determine_workflow_order_for_plasmids(assembled_cas3_plasmids,
assembled_contigs,
[enzyme_for_repair_template_integration], ["NcoI", "BstBI"])
restriction_enzymes_2, ["NcoI", "BstBI"])

plasmid_metadata_df = pd.merge(plasmid_metadata_df, workflow_df, on='plasmid_name', how='inner')

Expand Down

0 comments on commit cf56af4

Please sign in to comment.