12-30-2008, 02:22 AM
Thanks.
This is the python code that did it. I could not do it in one pass. There is no global flag for python for regex.
This is the python code that did it. I could not do it in one pass. There is no global flag for python for regex.
def trypsinize(proteins):
p = re.compile(r'([K|R])([^P])'
q = re.compile(r'([K|R])([^,P])'
output = []
for protein in proteins:
name = protein[0]
sequence = protein[1]
a = p.sub(r'\1,\2',sequence)
b = q.sub(r'\1,\2',a)
output.append([name,b.split(','])
return output