The workhorse of peptide sequencing is the mass spectrometer, an expensive molecular scale that shatters molecules into pieces and then weighs the resulting fragments. The mass spectrometer measures the mass of a molecule in daltons (Da); 1 Da is approximately equal to the mass of a single nuclear particle (i.e., a proton or neutron).

We will approximate the mass of a molecule by simply adding the number of protons and neutrons found in the molecule’s constituent atoms, which yields the molecule’s integer mass. For example, the amino acid “Gly”, which has chemical formula C2H3ON, has an integer mass of 57, since 2·12 + 3·1 + 1·16 + 1·14 = 57. Yet 1 Da is not exactly equal to the mass of a proton/neutron, and we may need to account for different naturally occurring isotopes of each atom when weighing a molecule. As a result, amino acids typically have non-integer masses (e.g., “Gly” has total mass equal to approximately 57.02 Da); for simplicity, however, we will work with the integer mass table given in the figure below.

integer_mass_table

The theoretical spectrum of a cyclic peptide peptide, denoted cyclospectrum(peptide), is the collection of all of the masses of its subpeptides, in addition to the mass 0 and the mass of the entire peptide. We will assume that the theoretical spectrum can contain duplicate elements, as is the case for “NQEL” (shown in the figure below), where “NQ” and “EL” have the same mass.

cyclospectrum

Assignment

Write a Python function cyclospectrum that generates the theoretical spectrum of a cyclic peptide. It takes a peptide as parameter and returns a list of all the masses in the spectrum, in increasing order.

Examples

>>> cyclospectrum("LEQN")
[0, 113, 114, 128, 129, 227, 242, 242, 257, 355, 356, 370, 371, 484]
>>> cyclospectrum("IAQMLFYCKVATN")
[0, 71, 71, 99, 101, 103, 113, 113, 114, 128, 128, 131, 147, 163, 170, 172, 184, 199, 215, 227, 227, 231, 244, 259, 260, 266, 271, 286, 298, 298, 310, 312, 328, 330, 330, 372, 385, 391, 394, 399, 399, 399, 401, 413, 423, 426, 443, 443, 470, 493, 498, 502, 513, 519, 526, 527, 541, 554, 556, 557, 564, 569, 590, 598, 616, 626, 640, 654, 657, 658, 665, 670, 682, 697, 697, 703, 711, 729, 729, 753, 753, 771, 779, 785, 785, 800, 812, 817, 824, 825, 828, 842, 856, 866, 884, 892, 913, 918, 925, 926, 928, 941, 955, 956, 963, 969, 980, 984, 989, 1012, 1039, 1039, 1056, 1059, 1069, 1081, 1083, 1083, 1083, 1088, 1091, 1097, 1110, 1152, 1152, 1154, 1170, 1172, 1184, 1184, 1196, 1211, 1216, 1222, 1223, 1238, 1251, 1255, 1255, 1267, 1283, 1298, 1310, 1312, 1319, 1335, 1351, 1354, 1354, 1368, 1369, 1369, 1379, 1381, 1383, 1411, 1411, 1482]