I want to identify the keys from a dictionary (strings) in a DNA sequence(string or fasta).
How can I find the keys in the sequence and get? I've tried something like this:
def identification(ren, S):
patternkeys = []
for key in ren:
if S in key:
patternkeys.append(key)
return patternKeys
patterns = []
patterns = identification(ren, S)
print patterns
#..............
ren
is the dictionary and S
the sequence
I need to get keys and values FOUND in the sequence.
Thanks
not terribly efficient, but you could modify the line
"if S in key" to use a regular expression that identifies key in S. See e.g. http://stackoverflow.com/questions/7345252/python-regex-match-words-in-string-and-get-count