In addition to searching for mutated peptides, we will also need to search for post-translational modifications, which alter amino acids after a protein has been translated from RNA. In fact, most proteins are modified after translation, and hundreds of types of modifications have been discovered. For example, the enzymatic activity of many proteins is regulated by the addition or removal of a phosphate group at a specific amino acid. This process, called phosphorylation, is reversible; protein kinases add phosphate groups, whereas protein phosphatases remove them.

A modification of mass δ applied to an amino acid results in adding δ to the mass of this amino acid. For example, δ = 80 for phosphorylated amino acids (serine, threonine, and tyrosine), δ = 16 for the modification of proline into hydroxyproline, and δ = −1 for the modification of lysine into allysin. If δ is positive, then the resulting modified peptide has a peptide vector that differs from the original peptide vector Peptide' by inserting a block of δ zeroes before the i-th occurrence of 1 in Peptide'. In the more rare case that δ is negative, the modified peptide corresponds to deleting a block of |δ| zeroes from Peptide'.

We will use the term block indel to refer to the addition or removal of a block of consecutive zeroes from a binary vector. Thus, applying k modifications to an amino acid string Peptide corresponds to applying k block indels to its peptide vector Peptide'. We define Variantsk(Peptide) as the set of all modified variants of Peptide with up to k modifications.

Given a peptide Peptide and a spectral vector Spectrum', our goal is to find a modified peptide from Variantsk(Peptide) with maximum score against Spectrum'.

Assignment

Given a peptide Peptide, a spectral vector Spectrum', and an integer k.

Return a peptide Peptide' related to Peptide by up to k modifications with maximal score against Spectrum' out of all possibilities.

Example

>>> spectral_alignment('AN', (-19, 11, 25, 1, -15, -10, 11, -27, 2, -24, -2, -29, 17, 8, 24, -25, -1, -5, 6, 2, -9, -13, -9, -1, 20, 11, -22, 23, -20, -11, 28, -7, 19, 10, 2, 12, 12, 14, -27, -17, -17, -21, -9, 22, -21, -6, -10, -8, -30, 5, 27, 20, -20, 9, -5, 27, -24, 4, 28, 26, 20, 21, -6, 7, 20, 22, -17, 5, 5, 26, 7, 13, -25, -14, 6, 9, -7, 29, 14, -26, 5, -11, -11, -6, 22, -16, -5, -17, 1, 21, -18, -11, -11, -26, 10, -14, 0, 11, 1, -30, 29, 2, -23, 6, 1, 16, 23, -1, -10, -14, 9, 7, -22, -21, 12, 5, -9, 2, -18, -6, 10, -10, 10, -19, 12, -28, -7, -8, -24, 21, 0, -29, 8, 6, -18, -28, 7, 23, 12, -4, -5, -7, 14, -9, 16, -3, -8, 18, 19, 25, 9, -17, -26, -22, -24, -23, -8, 24, 0, -17, -13, -24, -22, -26, 2, -6, -13, -13, 3, 20, 14, -11, 1, -4, 12, 14, -3, -10, 13, -21, -23, -25, -7, -24, 18, 23, 6, -22), 3)
'A(+7)N(-4)'

>>> spectral_alignment('IED', (-30, 14, -18, 6, 13, 4, 8, -29, 16, 2, 11, 5, -11, 26, 11, -25, -29, -17, 9, 0, 5, -10, 5, -28, -22, 11, -11, 14, -20, 0, 21, -22, -11, 15, 29, 12, 2, 28, -27, -6, 20, -2, 17, -26, 7, -7, 18, -4, -25, -3, 28, 7, -17, -30, -20, 18, 9, -19, -20, 15, 14, -14, 5, 3, -5, -22, 20, -14, -14, -5, -21, 6, 10, -18, 3, 29, -29, -28, -8, -20, 25, -27, -11, 19, 16, -24, 26, 29, -17, 8, -21, 3, 19, -13, -3, -18, 26, 27, -25, 8, 3, 2, -28, 15, -20, 19, 22, 12, -1, 8, 3, 4, 23, -17, -17, -27, 12, -21, -30, -23, -26, -13, -3, 21, -10, -12, 17, 24, 11, 3, -22, 12, 22, 14, 7, 15, -25, 4, 18, -2, -22, -25, -29, -7, -17, -18, -21, 16, 11, -29, -18, -25, -15, -5, 1, -17, -5, 28, 29, 0, 27, -16, 17, 27, -17, 3, -20, 14, 0, -27, -19, -20, 2, -6, -11, 24, 25, -15, -17, 23, -4, 21, -4, 28, 6, -28, -10, -17, -24, -18, -24, 26, -3, 22, 4, 14, -18, 20, -2, -26, -23, -21, 15, -15, 26, 12, 14, 5, -26, -11, -9, 10, 20, 10, -17, -18, 3, -25, -12, -20, -25, -24, 20, -29, -30, 20, -16, -26, 26, 5, 13, -26, -28, -24, 14, -28, 12, -1, 23, -26, -9, -27, 16, 5, 10, 11, -28, 8, -20, -17, 20, -21, -15, 19, -30, 1, -13, 16, 27, -5, -13, -23, 7, 21, 24, 26, 18, -5, -15, 25, 26, -2, 21, -23, -20, -3, 4, -16, 25, 3, 25, 24, 14, -2, 19, 7, -27, -27, 28, 6, -29, -20, -9, -7, 6, 23, 29, -15, -9, 4, 24, -25, 7, -29, 1, 2, 24, 24, -3, -13, -28, 3, 21, 12, -23, -14, -6, 3, 7, 7, -30, -21, 16, 16, -11, -9, 11, -24, 14, -18, 22, -16, -1, -18, 16, 3, 19, -10, 18, -7, 2, -1, 0, 18, -25, -14, -19, -7, 15, -2, 15, -21, -21, -9, 19, 27, 9, -6), 1)
'IE(+1)D'