Def one_ctuuers(strand, names, sequences): \"\"\"(str, list of str, list of str)
ID: 3936543 • Letter: D
Question
Def one_ctuuers(strand, names, sequences): """(str, list of str, list of str) rightarrow list of (str, int) tuples The parameters are the same as for match_enzymes. Return a list of tuples representing the 1-cutters for the DNA strand that is the first parameter. The first item of each tuple is the name of a restriction enzyme and the second item is the index (in the DNA strand) of the one restriction site that the enzyme cuts. >>>one_ctuuers ("ATTGCGAGCT", ["Alul", "Kpnl"], ["AGCT", "GGTACC"]) [("Alul", [6])) >>>one_ctuuers ("CCCGGCCAGCTGGCC", ["Haelll", "Alul"], ["GGCC", "AGCT")) [("Haelll", [3]), ("Alul", [7])] >>>one_Ctuuers ("GTCGACTTATCGA", ["Taql' "Kpnl"], ["TCGA", "GGTACC")) [("TaqI", [1])]Explanation / Answer
def one_ctuuers( strand, names, sequences ):
p= []
for i in range( len( names ) ):
findindexes = binding( strand, sequences[ i ] )
p += [ ( names[ i ], findindexes ) ]
return p
def binding(stringA, stringB ):
checkindexes = []
i = 0
while i < len( stringA ):
# Firstly we will compare the string A cut from the index i to whatever size string B is
# now if the strings are equal we will be adding the index to the list and increment the value of i depending on the length of stringB
if stringA[ i : i + len( stringB ) ] == stringB:
checkindexes += [ i ]
i += len( stringB ) - 1
i += 1 # now we will go to next index
return checkindexes
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.