Untitled
unknown
plain_text
a month ago
4.6 kB
7
Indexable
import re # Write a function that receives a long DNA sequence and the gene sequence. # The function seperates the gene from the longer sequence and returns all the new seuences. full_seq= "ggcttatttacgtcgtcgtaattgcggaattccctggtcgaaatgctgctagtcctcgagggtccgatgctgagccgatggtgagcaagggcgaggagctgttcaccggggtggtgcccatcctggtcgagctggacggcgacgtaaacggccacaagttcagcgtgtccggcgagggcgagggcgatgccacctacggcaagctgaccctgaagttcatctgcaccaccggcaagctgcccgtgccctggcccaccctcgtgaccaccctgtcctggggcgtgcagtgcttcgcccgctaccccgaccacatgaagcagcacgacttcttcaagtccgccatgcccgaaggctacgtccaggagcgcaccatcttcttcaaggacgacggcaactacaagacccgcgccgaggtgaagttcgagggcgacaccctggtgaaccgcatcgagctgaagggcatcgacttcaaggaggacggcaacatcctggggcacaagctggagtacaactactttagcgacaacgtctatatcaccgccgacaagcagaagaacggcatcaaggccaacttcaagatccgccacaacatcgaggacggcggcgtgcagctcgccgaccactaccagcagaacacccccatcggcgacggccccgtgctgctgcccgacaaccactacctgagcacccagtccaagctgagcaaagaccccaacgagaagcgcgatcacatggtcctgctggagttcgtgaccgccgccgggatcactctcggcatggacgagctgtacaagccttggtagctcgaggctaggctagctgaattcgtcgattgaattc" gene_seq= "atggtgagcaagggcgaggagctgttcaccggggtggtgcccatcctggtcgagctggacggcgacgtaaacggccacaagttcagcgtgtccggcgagggcgagggcgatgccacctacggcaagctgaccctgaagttcatctgcaccaccggcaagctgcccgtgccctggcccaccctcgtgaccaccctgtcctggggcgtgcagtgcttcgcccgctaccccgaccacatgaagcagcacgacttcttcaagtccgccatgcccgaaggctacgtccaggagcgcaccatcttcttcaaggacgacggcaactacaagacccgcgccgaggtgaagttcgagggcgacaccctggtgaaccgcatcgagctgaagggcatcgacttcaaggaggacggcaacatcctggggcacaagctggagtacaactactttagcgacaacgtctatatcaccgccgacaagcagaagaacggcatcaaggccaacttcaagatccgccacaacatcgaggacggcggcgtgcagctcgccgaccactaccagcagaacacccccatcggcgacggccccgtgctgctgcccgacaaccactacctgagcacccagtccaagctgagcaaagaccccaacgagaagcgcgatcacatggtcctgctggagttcgtgaccgccgccgggatcactctcggcatggacgagctgtacaag" matches = list(re.finditer(gene_seq, full_seq)) match = matches[0] before_gene = full_seq[:match.start()] gene = full_seq[match.start():match.end()] after_gene = full_seq[match.end():] print("gene: ",gene, "\n", "before_gene: ", before_gene, "\n" , "after_gene: ", after_gene) # Write a function that receives the enzyme dictionary and the sequence you study. # The function returns a list of enzymes you can use for restriction before and after the gene. # This is a dictionary of restriction enzymes, use it for your code. enzymes = {"XbaI": "TCTAGA", "XhoI":"CTCGAG", "HindIII": "AAGCTT", "EcoRI": "GAATTC", "BamHI": "GGATCC", "KpnI": "GGTACC"} one_enzyme_cutting_twice = [] for enzyme_name, sequence in enzymes.items(): # before_match = re.finditer(sequence, before_gene) before_match = before_gene.find(sequence) # after_match = re.finditer(sequence, after_gene) after_match = after_gene.find(sequence) if before_match >=0 and after_match >=0: one_enzyme_cutting_twice.append(enzyme_name) for enz in one_enzyme_cutting_twice: print("The enzyme: ", enz, " is cutting both before and after the gene") if (len(one_enzyme_cutting_twice) < 1): print("אין אנזימים החותכים גם לפניי הגן וגם אחריי הגן") # Write a function that receives the enzyme dictionary and the sequence you study. # The function returns a list of enzymes you can use for restriction before or after the gene. enzymes = {"XbaI": "TCTAGA", "XhoI":"CTCGAG", "HindIII": "AAGCTT", "EcoRI": "GAATTC","BamHI": "GGATCC","KpnI": "GGTACC" } enzymes_cut_before = [] enzymes_cut_after = [] for enzyme, sequence in enzymes.items(): if sequence in before_gene: enzymes_cut_before.append(enzyme) for enzyme, sequence in enzymes.items(): if sequence in after_gene: enzymes_cut_after.append(enzyme) if enzymes_cut_before and enzymes_cut_after: print("אנזימים שחותכים לפני הגן:") for enzyme in enzymes_cut_before: print(enzyme) print("אנזימים שחותכים אחרי הגן:") for enzyme in enzymes_cut_after: print(enzyme) else: print("אין חיתוך במקטע לפני הגן או במקטע אחרי הגן או בשניהם") ########################################################### Running code ################################################################### # Here write the code that runs your functions. # Make sure that it works without the need to change anything if you run it on a different computer. # Feel free to solve this in a different way, there is more than one way to write this code! # The sequences you need will be provided seperatly. Good luck :)
Editor is loading...
Leave a Comment