Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c8f78cfc authored by BOULLE Olivier's avatar BOULLE Olivier
Browse files

more comments

parent 520f1b35
No related branches found
No related tags found
No related merge requests found
...@@ -74,29 +74,34 @@ def select_primers(primers_list: list, number_assembly: int) -> list: ...@@ -74,29 +74,34 @@ def select_primers(primers_list: list, number_assembly: int) -> list:
primers needs to not hybridize with each other primers needs to not hybridize with each other
""" """
selected_primers_list = [] selected_primers_list = []
def test_hybridation(primer: str, selected_primers_list: list, max_hybridisation_value=4) -> bool: def test_hybridation(primer: str, selected_primers_list: list, max_hybridisation_value=4) -> bool:
""" """
test the hybridisation of the primer with a list of other primers test the hybridisation of the primer with a list of other primers
""" """
primer_rc = dfr.reverse_complement(primer) primer_rc = dfr.reverse_complement(primer) # get the reverse complement of the primer
for selected_primer in selected_primers_list: for selected_primer in selected_primers_list:
for i in range(len(primer)-max_hybridisation_value): for i in range(len(primer)-max_hybridisation_value):
# test if any part of the primer is contained in another primer from the list (= hybridisation)
if primer[i:i+max_hybridisation_value+1] in selected_primer: if primer[i:i+max_hybridisation_value+1] in selected_primer:
return False return False
# test also for the reverse complement
if primer_rc[i:i+max_hybridisation_value+1] in selected_primer: if primer_rc[i:i+max_hybridisation_value+1] in selected_primer:
return False return False
# return true if no hybridisation at all
return True return True
def compare_GC(primer_A: str, primer_B: str) -> bool: def compare_GC(primer_A: str, primer_B: str) -> bool:
""" """
primers have a special temperature in PCR depending on %GC, a couple (start;stop) needs to have a close tmp, so the same %GC is better primers have a special temperature in PCR depending on %GC, a couple (start;stop) needs to have a close tmp, so the same %GC is better
return true if the %GC is the same for the 2 primers
""" """
start_GC = (primer_A.count("C") + primer_A.count("G"))/(primer_A.count("A")+primer_A.count("T")) start_GC = (primer_A.count("C") + primer_A.count("G"))/(primer_A.count("A")+primer_A.count("T")) # get the %GC of the first primer
stop_GC = (primer_B.count("C") + primer_B.count("G"))/(primer_B.count("A")+primer_B.count("T")) stop_GC = (primer_B.count("C") + primer_B.count("G"))/(primer_B.count("A")+primer_B.count("T")) # get the %GC of the second primer
return start_GC == stop_GC return start_GC == stop_GC
...@@ -110,19 +115,20 @@ def select_primers(primers_list: list, number_assembly: int) -> list: ...@@ -110,19 +115,20 @@ def select_primers(primers_list: list, number_assembly: int) -> list:
# the primer must not hybridise with any previous selected primers # the primer must not hybridise with any previous selected primers
if test_hybridation(potential_stop_primer, selected_primers_list, 4): if test_hybridation(potential_stop_primer, selected_primers_list, 4):
selected_primers_list += [potential_start_primer, potential_stop_primer] # add the couple selected_primers_list += [potential_start_primer, potential_stop_primer] # add the couple to the list
print(str(len(selected_primers_list)//2)+"/"+str(number_assembly)) print(str(len(selected_primers_list)//2)+"/"+str(number_assembly))
# all required primers have been selected # if all required primers have been selected
if len(selected_primers_list) == number_assembly*2: if len(selected_primers_list) == number_assembly*2:
#print(selected_primers_list) #print(selected_primers_list)
return selected_primers_list return selected_primers_list # end the script with the result
# the corresponding stop primer has been found
break # return to start primers search break # return to start primers search
# not enough couple of primers found # not enough couple of primers found
print("error in fragment design : not enough correct primers couple found, found",str(len(selected_primers_list)),"but wanted",str(number_assembly*2)) print("error in fragment design : not enough correct primers couple found, found",str(len(selected_primers_list)),"but wanted",str(number_assembly*2))
print("can be solved by using a longer random sequence in primers_generation") print("can be solved by using a longer random sequence in primers_generation to have a longer primer list ")
return selected_primers_list return selected_primers_list
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment