-
Notifications
You must be signed in to change notification settings - Fork 3
/
BA4L.py
73 lines (68 loc) · 6.08 KB
/
BA4L.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
mass = {}
mass['G'] = 57
mass['A'] = 71
mass['S'] = 87
mass['P'] = 97
mass['V'] = 99
mass['T'] = 101
mass['C'] = 103
mass['I'] = 113
mass['L'] = 113
mass['N'] = 114
mass['D'] = 115
mass['K'] = 128
mass['Q'] = 128
mass['E'] = 129
mass['M'] = 131
mass['H'] = 137
mass['F'] = 147
mass['R'] = 156
mass['Y'] = 163
mass['W'] = 186
def proteinMass(pep):
weight = 0
for x in pep:
weight += mass[x]
return weight
def linospectrum(peptide):
spec = [0]
for x in range(1,len(peptide)):
for i in range(len(peptide)):
if i+x <= len(peptide):
spec.append(proteinMass(peptide[i:i+x]))
spec.append(proteinMass(peptide))
spec.sort()
return spec
def score(peptide, spectrum):
spec = linospectrum(peptide)
score = 0
i = 0
for x in spectrum:
for y in range(i,len(spec)):
if x == spec[y]:
score +=1
i = y+1
break
return score
def cut(leaderboard, spectrum, n):
if len(leaderboard) <= n:
return leaderboard
scores = []
for x in leaderboard:
scores.append(score(x, spectrum))
scores.sort()
scores.reverse()
min = scores[n-1]
new = []
for x in leaderboard:
if score(x, spectrum) >= min:
new.append(x)
return new
leaderboard = ["TQRGRCNLCEEANSVRMWEIRAEPNIASSMSVENVSAR", "HHNAWWEEKYKRENHLEWFDAHDHEPGHQQMLFQYRWI", "WNTRICLWPDLIIWPLPFCAWSLWDLYTVVPKTMKADE", "VPTPYCKINHPFWNKEYMYMPPGDRHHTRSDVKPEPKA", "QDAIQPENHNVCELGDFMGFHYKLGGLDDCRQICAYHV", "PEHGTLTTMYTANFFRWYNQYTVPPDSNWDRCSSEHDE", "SCRISNNNLAAKDNVTNFMAKLELHGGEHVPVNEIFIH", "YYLNYQYIEGEIHCCGGFVTDKSYGAMDTIALSFPGKI", "CLTIPGYQYGRIFQMFENSSTRVKDFHFRLVQVKFGED", "TEEPPTWDMASTAWHMTCWLFFEACSDMAKTQPRKGFF", "DADNPHAPQDECDRDHMEWFGEYYVHRGVQWKKINRFK", "CWSLNQTEWHVAFCKLLFNAAMAHGQAAQWVTYKEFTK", "HYCDLYKRQWPSDDRSSVLTNKYDTNWKIPWLPPCAID", "YTLGVQSGSPTYCYLEPWWLHWHEKVCYMFYDPIQEIV", "FASQPFDKCFEELMWEYDDNRKAEPIWYDLQRWHRILG", "QVYARCIKGVQHLINGYCNIVTQQQIGPPCPHNEKMYV", "IWLRCYNDEFKRDPELAYLFFWPVWMCEEGYQSRRHFT", "KNTVIHCTTLPIVRLQDSDMGLDGWFWMILWDSGVTWG", "SMRCYMWDEDSPYHDITQPWALHFYHTNSYFGYLWCYR"]
spectrum = [0, 57, 71, 71, 71, 97, 99, 99, 99, 99, 101, 101, 103, 113, 113, 113, 113, 113, 113, 114, 115, 115, 115, 128, 128, 128, 128, 128, 129, 131, 137, 137, 137, 142, 147, 163, 163, 163, 163, 163, 185, 186, 208, 210, 212, 213, 214, 214, 218, 220, 225, 226, 229, 229, 231, 231, 236, 236, 241, 241, 243, 244, 246, 250, 250, 252, 257, 257, 259, 262, 262, 264, 276, 276, 278, 288, 292, 314, 317, 323, 323, 326, 326, 326, 328, 328, 338, 344, 348, 349, 349, 351, 351, 355, 356, 357, 359, 372, 375, 377, 378, 383, 383, 385, 388, 389, 391, 392, 404, 415, 416, 420, 425, 427, 427, 427, 439, 441, 450, 451, 451, 454, 454, 454, 464, 465, 470, 472, 477, 481, 484, 485, 486, 488, 489, 489, 496, 498, 501, 511, 514, 517, 519, 519, 529, 540, 540, 551, 552, 554, 555, 564, 567, 569, 578, 579, 580, 582, 582, 585, 590, 591, 592, 597, 602, 602, 604, 609, 612, 612, 614, 614, 616, 632, 633, 650, 652, 661, 664, 666, 668, 669, 677, 677, 677, 682, 683, 692, 695, 703, 703, 704, 706, 706, 708, 709, 710, 711, 715, 715, 717, 730, 731, 732, 732, 740, 742, 748, 763, 765, 765, 774, 777, 790, 797, 802, 805, 805, 806, 809, 811, 813, 816, 819, 822, 823, 829, 831, 837, 839, 840, 843, 843, 845, 845, 846, 855, 869, 873, 874, 876, 877, 878, 880, 895, 908, 916, 918, 920, 926, 928, 928, 934, 935, 937, 940, 940, 944, 950, 953, 953, 956, 960, 968, 971, 973, 974, 982, 987, 992, 994, 994, 1002, 1005, 1009, 1021, 1024, 1031, 1036, 1039, 1041, 1043, 1053, 1059, 1063, 1065, 1066, 1066, 1068, 1081, 1081, 1081, 1083, 1084, 1091, 1093, 1093, 1101, 1102, 1103, 1103, 1123, 1130, 1131, 1136, 1136, 1137, 1149, 1152, 1154, 1157, 1166, 1178, 1181, 1181, 1182, 1184, 1192, 1194, 1194, 1194, 1194, 1196, 1201, 1202, 1206, 1206, 1221, 1244, 1249, 1251, 1251, 1256, 1260, 1264, 1266, 1266, 1267, 1283, 1291, 1294, 1294, 1297, 1297, 1307, 1309, 1312, 1318, 1320, 1320, 1322, 1322, 1323, 1338, 1345, 1362, 1365, 1365, 1369, 1369, 1373, 1379, 1380, 1382, 1388, 1388, 1396, 1407, 1417, 1419, 1421, 1425, 1425, 1425, 1425, 1429, 1431, 1435, 1437, 1451, 1451, 1459, 1474, 1480, 1482, 1486, 1495, 1501, 1508, 1509, 1516, 1519, 1520, 1528, 1528, 1530, 1532, 1532, 1532, 1538, 1540, 1544, 1549, 1553, 1553, 1554, 1579, 1585, 1587, 1602, 1606, 1608, 1610, 1611, 1614, 1617, 1632, 1632, 1633, 1643, 1643, 1645, 1645, 1646, 1648, 1666, 1668, 1675, 1682, 1682, 1688, 1691, 1695, 1705, 1713, 1717, 1725, 1733, 1734, 1739, 1745, 1745, 1745, 1748, 1758, 1759, 1761, 1773, 1774, 1780, 1795, 1796, 1796, 1803, 1806, 1808, 1810, 1816, 1833, 1835, 1842, 1845, 1846, 1851, 1858, 1858, 1858, 1863, 1867, 1872, 1876, 1888, 1889, 1902, 1909, 1924, 1932, 1934, 1936, 1943, 1944, 1955, 1958, 1959, 1959, 1970, 1971, 1971, 1979, 1991, 1998, 2000, 2003, 2014, 2017, 2021, 2030, 2031, 2037, 2037, 2051, 2056, 2057, 2071, 2071, 2083, 2084, 2094, 2095, 2097, 2102, 2107, 2122, 2128, 2131, 2134, 2134, 2146, 2152, 2161, 2165, 2184, 2184, 2193, 2194, 2194, 2199, 2215, 2218, 2220, 2222, 2223, 2230, 2231, 2234, 2247, 2247, 2260, 2260, 2262, 2280, 2285, 2293, 2294, 2302, 2309, 2317, 2335, 2343, 2346, 2347, 2351, 2357, 2359, 2359, 2360, 2375, 2377, 2378, 2397, 2408, 2422, 2423, 2430, 2445, 2448, 2448, 2449, 2454, 2456, 2472, 2472, 2472, 2488, 2490, 2491, 2506, 2510, 2519, 2522, 2522, 2543, 2548, 2561, 2567, 2571, 2571, 2577, 2582, 2603, 2609, 2611, 2619, 2619, 2621, 2632, 2635, 2635, 2668, 2674, 2676, 2680, 2685, 2685, 2686, 2690, 2695, 2708, 2734, 2734, 2745, 2747, 2748, 2779, 2784, 2789, 2796, 2798, 2798, 2800, 2805, 2813, 2823, 2827, 2862, 2876, 2876, 2894, 2897, 2897, 2899, 2899, 2911, 2926, 2926, 2926, 2926, 2933, 2937, 2991, 3004, 3008, 3010, 3012, 3025, 3027, 3036, 3039, 3039, 3041, 3060, 3062, 3063, 3107, 3133, 3138, 3140, 3140, 3149, 3154, 3155, 3162, 3173, 3175, 3176, 3220, 3225, 3253, 3254, 3254, 3275, 3277, 3277, 3288, 3296, 3301, 3312, 3324, 3353, 3367, 3376, 3383, 3390, 3391, 3395, 3416, 3416, 3425, 3466, 3487, 3490, 3491, 3496, 3504, 3530, 3531, 3553, 3558, 3602, 3603, 3603, 3605, 3624, 3629, 3643, 3668, 3673, 3704, 3716, 3739, 3739, 3742, 3766, 3771, 3810, 3810, 3817, 3870, 3879, 3879, 3881, 3886, 3957, 3980, 3985, 3992, 4007, 4028, 4056, 4093, 4120, 4122, 4127, 4193, 4221, 4235, 4264, 4306, 4336, 4377, 4407, 4478]
n = 6
l = cut(leaderboard, spectrum, n)
p = ""
for x in l:
p+= x + " "
print(p)