Write a program that takes a protein sequence and returns a list of all tryptic…
- User
Write a program that takes a protein sequence and returns a list of all tryptic peptides. Keep the initial order of pieces in protein sequence use function def trypsin(seq)
Hints:
Protein sequence is always a string over ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'] alphabet Trypsin cuts proteins. Trypsin cuts proteins after R or after K (if we look from left to right). R or K are kept after cleavage. Tryptic peptides are pieces of initail protein that are left after cleavage. Example input: 'AKARA' Example output: ['AK', 'AR', 'A']
Example input: MSGKMTGIVKWFNADRGFGFITPDDGSKDVFVHFSAIQNDGYKSLDEGQKVSESGAKGPAAGNVTSL Example output:[‘MSGK’, ‘MTGIVK’, ‘WFNADR’, ‘GFGFITPDDGSK’, ‘DVFVHFSAIQNDGYK’, ‘SLDEGQK’, ‘VSESGAK’, ‘GPAAGNVTSL’]
- Assistant
Here is a solution to the problem using the given function definition:
pythondef trypsin(seq): peptides = [] # list to store tryptic peptides peptide = "" # variable to store current tryptic peptide for amino acid in seq: # iterate over each amino acid in the protein sequence peptide += amino acid # add current amino acid to the peptide if amino acid == 'R' or amino acid == 'K': # if the current amino acid is R or K peptides.append(peptide) # add the current peptide to the list of tryptic peptides peptide = "" # reset the peptide variable peptides.append(peptide) # add the last peptide to the list of tryptic peptides return peptides