hi
after reading the specification like 5 times here's what I came up with :)
first part:
def binding_locations( strA, strB ):
indexes = []
i = 0
while i < len( strA ):
# compare the strA cut from the index i to whatever size strB is
# and if the strings are equal add the index to the list and increment the value of i depending on the length of strB
if strA[ i : i + len( strB ) ] == strB:
indexes += [ i ]
i += len( strB ) - 1
i += 1 #go to next index
return indexes
second part:
def match_enzymes( strand, enzymes, recognitionSequence ):
l = []
# basically using the first function :)
for i in range( len( enzymes ) ):
indexes = binding_locations( strand, recognitionSequence[ i ] )
l += [ ( enzymes[ i ], indexes ) ]
return l
I couldn't understand the specification for the third part if you could provide an example I'll try to help :)
masterofpuppets
Posting Whiz in Training
272 posts since Jul 2009
Reputation Points: 20
Solved Threads: 74