@@ -718,7 +718,9 @@ def compare_iterables(source, target):
718718target_species = { "Bacillus subtilis" : 2 , "Escherichia coli" : 8 , "Saccaromyces cerevisiae" : 3 , "Synechocystis sp. PCC 6803" : 1 , "Vibrio natriegens" : 1 } # original optimimzation, actual pDestination fluorescence
719719# target_species = { "Bacillus subtilis": 1, "Danio rerio": 1, "Escherichia coli": 8, "Saccaromyces cerevisiae": 1, "Vibrio natriegens": 1 } # pBsaI fluorescence
720720# target_species = { "Escherichia coli": 3, "Vibrio natriegens": 1 } # Golden Gate enzymes
721- target_species = {}
721+ target_species = {} # the weights of the species to optimize for
722+
723+ restriction_enzymes = [] # the restriction enzymes to use
722724
723725def add_codon_preference (pref_list , label ):
724726 '''
@@ -937,6 +939,7 @@ def find_bad_seqs(seq):
937939 rand_sites .append ((index , index + len (bad_seq )))
938940 # checks for restriction sites
939941 prs = [] # possible restriction sites
942+ '''
940943 restriction_enzymes = [
941944 "ggatcc", # BamHI
942945 "gaagac", # BbsI # semi-important
@@ -957,6 +960,7 @@ def find_bad_seqs(seq):
957960 "tctaga", # XbaI ## important ##
958961 "ctcgag" # XhoI
959962 ]
963+ '''
960964 for restriction_site in restriction_enzymes :
961965 prs .append (restriction_site )
962966 if restriction_site != reverse_complement (restriction_site ): # if the restriction site isn't palindromic
@@ -1029,14 +1033,20 @@ def optimize_amino_acids():
10291033 '''
10301034 turn a string of amino acids or DNA into a species-optimized sequence of DNA
10311035 '''
1032- sequence = input_2 .get ().lower ()
1036+ global restriction_enzymes
1037+ sequence = aa_input .get ().lower ()
10331038 # sequence = gfp_aa_seq.lower() # default sequence for testing
1034- if (sequence == "" or " " in sequence ) and input_1 .get () != "" and not " " in input_1 .get (): # if the amino acid input isn't filled but the DNA input is
1035- sequence = dna_to_aa (input_1 .get ())
1039+ if (sequence == "" or " " in sequence ) and DNA_input .get () != "" and not " " in DNA_input .get (): # if the amino acid input isn't filled but the DNA input is
1040+ sequence = dna_to_aa (DNA_input .get ())
10361041 elif " " in sequence : # if the sequence data is just placeholder text and there's no DNA input
10371042 sequence = ""
10381043 random .seed (42 ) # makes optimizations reproducible
10391044 best_seq = { "seq" : "" , "score" : float ("-inf" ), "probs" : [], "bad_probs" : [], "gc" : 0 , "unsuccessful" : 0 }
1045+ restriction_enzymes = []
1046+ for box in restriction_checkbuttons :
1047+ if box .selected .get ():
1048+ restriction_enzymes .append (box .seq )
1049+ print (restriction_enzymes )
10401050 for _ in range (80 ): # finds the best of 80 random optimization attempts
10411051 p = { "seq" : "" , "score" : 100 , "probs" : [], "bad_probs" : [], "gc" : 0 }
10421052 # assigns codons to every amino acid based on the codon preferences
@@ -1182,6 +1192,7 @@ def toggle_enzymes():
11821192
11831193gui = GUI (title = "Codon optimizer" )
11841194# title
1195+ gui .pack_padding (2 )
11851196gui .make_text ("Codon optimizer" , 15 ).pack ()
11861197# theme radiobuttons
11871198theme_buttons = gui .make_frame ()
@@ -1195,7 +1206,7 @@ def toggle_enzymes():
11951206show_species = gui .make_checkbutton ("Show species weights" , command = toggle_species , parent = checkboxes_frame )
11961207show_species .grid (column = 0 , row = 0 )
11971208show_enzymes = gui .make_checkbutton ("Show restriction sites" , command = toggle_enzymes , parent = checkboxes_frame )
1198- ### show_enzymes.grid(column=1, row=0)
1209+ show_enzymes .grid (column = 1 , row = 0 )
11991210checkboxes_frame .pack (pady = 5 )
12001211# species section
12011212species_boxes = []
@@ -1231,6 +1242,7 @@ def toggle_enzymes():
12311242 box .entry .insert (0 , "0" )
12321243# enzymes section
12331244enzymes_section = gui .make_frame ()
1245+ gui .make_text ("Select restriction sites to avoid" , 4 , parent = enzymes_section ).grid (row = 0 , column = 0 , columnspan = 4 , sticky = "ew" )
12341246enzyme_cuts = {
12351247 "BamHI" : "ggatcc" ,
12361248 "BbsI" : "gaagac" ,
@@ -1251,17 +1263,21 @@ def toggle_enzymes():
12511263 "XbaI" : "tctaga" ,
12521264 "XhoI" : "ctcgag"
12531265}
1266+ restriction_checkbuttons = []
12541267index = 0
12551268for name , site in enzyme_cuts .items ():
1256- gui .make_checkbutton ("{} ({})" .format (name , site .upper ()), parent = enzymes_section , selected = True ).grid (column = index % 4 , row = index // 4 , padx = 2 , pady = 2 , sticky = "w" )
1269+ checkbox = gui .make_checkbutton ("{} ({})" .format (name , site .upper ()), parent = enzymes_section , selected = False )
1270+ checkbox .seq = site
1271+ checkbox .grid (column = index % 4 , row = index // 4 + 1 , padx = 2 , pady = 2 , sticky = "w" )
1272+ restriction_checkbuttons .append (checkbox )
12571273 index += 1
12581274# allows inputting DNA or amino acids
12591275input_frame = gui .make_frame ()
1260- input_1 = gui .make_entry (placeholder = "DNA here" , parent = input_frame )
1261- input_1 .grid (column = 0 , row = 0 )
1276+ DNA_input = gui .make_entry (placeholder = "DNA here" , parent = input_frame )
1277+ DNA_input .grid (column = 0 , row = 0 )
12621278gui .make_text (" or " , 5 , parent = input_frame ).grid (column = 1 , row = 0 )
1263- input_2 = gui .make_entry (placeholder = "Amino acids here" , parent = input_frame )
1264- input_2 .grid (column = 2 , row = 0 )
1279+ aa_input = gui .make_entry (placeholder = "Amino acids here" , parent = input_frame )
1280+ aa_input .grid (column = 2 , row = 0 )
12651281input_frame .pack (pady = 5 )
12661282# shows codon preferences or optimization results
12671283buttons_frame = gui .make_frame ()
0 commit comments