We represent the masses in a spectrum as a sequence Spectrum of integers  $$\textit{s}_\text{1}, \ldots, \textit{s}_\textit{m}$$ in increasing order, where $$\textit{s}_\text{1}$$ is zero and $$\textit{s}_\textit{m}$$ is the total mass of the (unknown) peptide. We define a labeled graph Graph(Spectrum) by forming a node for each element of Spectrum, then connecting nodes $$s_i$$ and $$s_j$$ by a directed edge labeled by an amino acid $$a$$ if $$s_j - s_i$$ is equal to the mass of $$a$$. As we assumed when sequencing antibiotics, we do not distinguish between amino acids having the same integer masses (i.e., the pairs K/Q and I/L).

Assignment

Given a sequence of emitted symbols x = x1 . . . xn in an alphabet A, generated by a k-state HMM with unknown transition and emission probabilities, initial Transition and Emission matrices and a number of iterations I.

Return a matrix of transition probabilities Transition and a matrix of emission probabilities Emission that maximizes Pr(x,π) over all possible transition and emission matrices and over all hidden paths π.

Example

>>> create_from_list([0, 115, 137, 252])
SpectrumGraph(0, [Edge('D', SpectrumGraph(115, [Edge('H', SpectrumGraph(252, []))])), Edge('H', SpectrumGraph(137, [Edge('D', SpectrumGraph(252, []))]))])

>>> create_from_list([0, 87, 113, 200])
SpectrumGraph(0, [Edge('S', SpectrumGraph(87, [Edge('L', SpectrumGraph(200, []))])), Edge('L', SpectrumGraph(113, [Edge('S', SpectrumGraph(200, []))]))])