-
Notifications
You must be signed in to change notification settings - Fork 3
/
BA4F.py
56 lines (52 loc) · 10.3 KB
/
BA4F.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
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 cyclospectrum(peptide):
spec = [0]
for x in range(1,len(peptide)):
for i in range(len(peptide)):
if i+x >= len(peptide):
y = i+x-len(peptide)
spec.append(proteinMass(peptide[i:]+peptide[:y]))
else:
spec.append(proteinMass(peptide[i:i+x]))
spec.append(proteinMass(peptide))
spec.sort()
return spec
def score(peptide, spectrum):
spec = cyclospectrum(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
pep = 'DWQPRPNQHGSYTMTNCQQPSLPNERYCLAFSPNRIPYLYD'
spec = [0, 57, 57, 87, 87, 87, 87, 97, 97, 97, 97, 97, 101, 103, 113, 113, 113, 113, 114, 114, 114, 114, 115, 115, 128, 128, 128, 129, 129, 131, 137, 144, 144, 147, 147, 147, 147, 156, 156, 163, 163, 163, 163, 171, 184, 186, 194, 200, 201, 210, 210, 211, 211, 215, 216, 224, 225, 225, 230, 232, 234, 243, 250, 253, 253, 256, 258, 260, 260, 260, 260, 261, 261, 266, 275, 276, 276, 278, 281, 281, 285, 291, 292, 294, 297, 297, 298, 301, 307, 312, 314, 318, 319, 324, 338, 340, 346, 350, 353, 357, 361, 362, 363, 367, 368, 373, 373, 374, 379, 379, 381, 381, 389, 391, 393, 394, 395, 399, 403, 405, 405, 407, 411, 411, 416, 422, 423, 425, 429, 431, 435, 436, 438, 439, 440, 444, 448, 453, 454, 464, 471, 475, 478, 482, 486, 490, 492, 493, 494, 496, 500, 506, 508, 510, 510, 517, 518, 520, 522, 524, 526, 526, 528, 531, 535, 536, 540, 544, 551, 551, 551, 552, 552, 553, 554, 562, 567, 567, 573, 579, 579, 587, 591, 592, 597, 609, 611, 614, 615, 618, 621, 622, 633, 634, 636, 637, 638, 641, 645, 648, 649, 650, 651, 654, 659, 660, 664, 664, 665, 665, 665, 668, 669, 673, 679, 682, 682, 688, 691, 692, 696, 699, 700, 701, 704, 707, 715, 725, 735, 742, 745, 747, 749, 750, 760, 762, 762, 764, 764, 765, 766, 768, 772, 774, 778, 778, 778, 779, 782, 785, 791, 793, 796, 797, 797, 802, 804, 804, 805, 811, 812, 812, 814, 816, 817, 820, 829, 832, 846, 855, 859, 865, 871, 872, 873, 875, 875, 878, 879, 891, 892, 893, 893, 894, 898, 905, 909, 910, 911, 911, 911, 913, 915, 915, 916, 917, 919, 921, 925, 925, 925, 929, 931, 933, 952, 956, 958, 960, 960, 962, 967, 973, 975, 980, 983, 988, 995, 1000, 1002, 1002, 1006, 1006, 1008, 1012, 1022, 1022, 1025, 1025, 1026, 1027, 1028, 1038, 1040, 1041, 1045, 1046, 1049, 1054, 1057, 1057, 1059, 1059, 1062, 1065, 1066, 1072, 1072, 1073, 1075, 1078, 1080, 1080, 1082, 1084, 1087, 1095, 1102, 1103, 1117, 1120, 1123, 1124, 1125, 1126, 1128, 1135, 1138, 1140, 1143, 1146, 1153, 1154, 1158, 1159, 1169, 1169, 1170, 1171, 1172, 1174, 1175, 1177, 1185, 1185, 1185, 1187, 1191, 1193, 1194, 1196, 1197, 1201, 1212, 1212, 1216, 1216, 1217, 1222, 1225, 1225, 1232, 1234, 1236, 1252, 1255, 1255, 1256, 1257, 1258, 1259, 1261, 1267, 1272, 1281, 1282, 1282, 1284, 1284, 1288, 1288, 1289, 1290, 1298, 1300, 1309, 1310, 1312, 1313, 1315, 1316, 1319, 1322, 1326, 1330, 1333, 1333, 1338, 1340, 1347, 1348, 1356, 1359, 1363, 1364, 1369, 1369, 1369, 1371, 1373, 1376, 1383, 1383, 1386, 1386, 1395, 1395, 1401, 1409, 1411, 1419, 1424, 1425, 1426, 1427, 1428, 1430, 1431, 1435, 1437, 1438, 1444, 1446, 1447, 1447, 1451, 1452, 1454, 1456, 1461, 1462, 1463, 1466, 1470, 1470, 1473, 1476, 1477, 1482, 1484, 1492, 1506, 1506, 1508, 1511, 1513, 1515, 1520, 1522, 1523, 1534, 1539, 1539, 1540, 1542, 1543, 1544, 1549, 1551, 1553, 1553, 1564, 1564, 1565, 1569, 1573, 1574, 1574, 1575, 1575, 1576, 1576, 1578, 1579, 1590, 1593, 1593, 1594, 1598, 1598, 1607, 1608, 1610, 1617, 1617, 1619, 1620, 1620, 1627, 1631, 1636, 1648, 1652, 1657, 1668, 1670, 1671, 1671, 1677, 1678, 1679, 1681, 1684, 1687, 1687, 1687, 1689, 1690, 1691, 1693, 1695, 1702, 1705, 1706, 1707, 1707, 1716, 1717, 1720, 1722, 1722, 1724, 1727, 1728, 1736, 1738, 1744, 1745, 1745, 1745, 1764, 1764, 1765, 1768, 1774, 1776, 1784, 1784, 1785, 1790, 1794, 1799, 1800, 1803, 1804, 1804, 1804, 1808, 1809, 1815, 1815, 1820, 1822, 1825, 1830, 1831, 1834, 1834, 1836, 1842, 1842, 1849, 1850, 1851, 1852, 1861, 1866, 1869, 1871, 1873, 1873, 1873, 1877, 1881, 1883, 1887, 1891, 1892, 1897, 1899, 1900, 1912, 1917, 1917, 1917, 1918, 1921, 1921, 1931, 1937, 1937, 1938, 1944, 1947, 1948, 1956, 1957, 1959, 1960, 1962, 1963, 1970, 1975, 1978, 1978, 1980, 1980, 1983, 1984, 1984, 1989, 1997, 1998, 1998, 1999, 2001, 2005, 2005, 2012, 2013, 2014, 2014, 2025, 2028, 2031, 2046, 2046, 2050, 2057, 2059, 2060, 2060, 2062, 2062, 2063, 2068, 2070, 2073, 2075, 2075, 2081, 2084, 2084, 2085, 2095, 2098, 2100, 2102, 2107, 2108, 2112, 2113, 2115, 2126, 2127, 2127, 2127, 2127, 2128, 2141, 2142, 2143, 2145, 2147, 2149, 2160, 2161, 2170, 2170, 2171, 2172, 2173, 2174, 2176, 2177, 2185, 2187, 2187, 2188, 2197, 2199, 2199, 2202, 2204, 2205, 2209, 2209, 2213, 2215, 2223, 2228, 2238, 2240, 2241, 2241, 2242, 2242, 2244, 2244, 2256, 2257, 2258, 2260, 2267, 2271, 2274, 2278, 2284, 2284, 2286, 2286, 2289, 2290, 2296, 2298, 2299, 2300, 2302, 2302, 2316, 2317, 2324, 2335, 2335, 2336, 2337, 2338, 2339, 2342, 2343, 2343, 2344, 2355, 2356, 2356, 2357, 2357, 2359, 2360, 2361, 2365, 2368, 2371, 2372, 2381, 2381, 2387, 2388, 2395, 2399, 2413, 2413, 2417, 2423, 2427, 2428, 2430, 2431, 2433, 2436, 2437, 2443, 2447, 2448, 2449, 2451, 2452, 2453, 2453, 2458, 2464, 2468, 2469, 2473, 2479, 2484, 2484, 2485, 2486, 2488, 2489, 2490, 2494, 2500, 2501, 2504, 2506, 2507, 2509, 2510, 2514, 2520, 2524, 2524, 2538, 2542, 2549, 2550, 2556, 2556, 2565, 2566, 2569, 2572, 2576, 2577, 2578, 2580, 2580, 2581, 2581, 2582, 2593, 2594, 2594, 2595, 2598, 2599, 2600, 2601, 2602, 2602, 2613, 2620, 2621, 2635, 2635, 2637, 2638, 2639, 2641, 2647, 2648, 2651, 2651, 2653, 2653, 2659, 2663, 2666, 2670, 2677, 2679, 2680, 2681, 2693, 2693, 2695, 2695, 2696, 2696, 2697, 2699, 2709, 2714, 2722, 2724, 2728, 2728, 2732, 2733, 2735, 2738, 2738, 2740, 2749, 2750, 2750, 2752, 2760, 2761, 2763, 2764, 2765, 2766, 2767, 2767, 2776, 2777, 2788, 2790, 2792, 2794, 2795, 2796, 2809, 2810, 2810, 2810, 2810, 2811, 2822, 2824, 2825, 2829, 2830, 2835, 2837, 2839, 2842, 2852, 2853, 2853, 2856, 2862, 2862, 2864, 2867, 2869, 2874, 2875, 2875, 2877, 2877, 2878, 2880, 2887, 2891, 2891, 2906, 2909, 2912, 2923, 2923, 2924, 2925, 2932, 2932, 2936, 2938, 2939, 2939, 2940, 2948, 2953, 2953, 2954, 2957, 2957, 2959, 2959, 2962, 2967, 2974, 2975, 2977, 2978, 2980, 2981, 2989, 2990, 2993, 2999, 3000, 3000, 3006, 3016, 3016, 3019, 3020, 3020, 3020, 3025, 3037, 3038, 3040, 3045, 3046, 3050, 3054, 3056, 3060, 3064, 3064, 3064, 3066, 3068, 3071, 3076, 3085, 3086, 3087, 3088, 3095, 3095, 3101, 3103, 3103, 3106, 3107, 3112, 3115, 3117, 3122, 3122, 3128, 3129, 3133, 3133, 3133, 3134, 3137, 3138, 3143, 3147, 3152, 3153, 3153, 3161, 3163, 3169, 3172, 3173, 3173, 3192, 3192, 3192, 3193, 3199, 3201, 3209, 3210, 3213, 3215, 3215, 3217, 3220, 3221, 3230, 3230, 3231, 3232, 3235, 3242, 3244, 3246, 3247, 3248, 3250, 3250, 3250, 3253, 3256, 3258, 3259, 3260, 3266, 3266, 3267, 3269, 3280, 3285, 3289, 3301, 3306, 3310, 3317, 3317, 3318, 3320, 3320, 3327, 3329, 3330, 3339, 3339, 3343, 3344, 3344, 3347, 3358, 3359, 3361, 3361, 3362, 3362, 3363, 3363, 3364, 3368, 3372, 3373, 3373, 3384, 3384, 3386, 3388, 3393, 3394, 3395, 3397, 3398, 3398, 3403, 3414, 3415, 3417, 3422, 3424, 3426, 3429, 3431, 3431, 3445, 3453, 3455, 3460, 3461, 3464, 3467, 3467, 3471, 3474, 3475, 3476, 3481, 3483, 3485, 3486, 3490, 3490, 3491, 3493, 3499, 3500, 3502, 3506, 3507, 3509, 3510, 3511, 3512, 3513, 3518, 3526, 3528, 3536, 3542, 3542, 3551, 3551, 3554, 3554, 3561, 3564, 3566, 3568, 3568, 3568, 3573, 3574, 3578, 3581, 3589, 3590, 3597, 3599, 3604, 3604, 3607, 3611, 3615, 3618, 3621, 3622, 3624, 3625, 3627, 3628, 3637, 3639, 3647, 3648, 3649, 3649, 3653, 3653, 3655, 3655, 3656, 3665, 3670, 3676, 3678, 3679, 3680, 3681, 3682, 3682, 3685, 3701, 3703, 3705, 3712, 3712, 3715, 3720, 3721, 3721, 3725, 3725, 3736, 3740, 3741, 3743, 3744, 3746, 3750, 3752, 3752, 3752, 3760, 3762, 3763, 3765, 3766, 3767, 3768, 3768, 3778, 3779, 3783, 3784, 3791, 3794, 3797, 3799, 3802, 3809, 3811, 3812, 3813, 3814, 3817, 3820, 3834, 3835, 3842, 3850, 3853, 3855, 3857, 3857, 3859, 3862, 3864, 3865, 3865, 3871, 3872, 3875, 3878, 3878, 3880, 3880, 3883, 3888, 3891, 3892, 3896, 3897, 3899, 3909, 3910, 3911, 3912, 3912, 3915, 3915, 3925, 3929, 3931, 3931, 3935, 3935, 3937, 3942, 3949, 3954, 3957, 3962, 3964, 3970, 3975, 3977, 3977, 3979, 3981, 3985, 4004, 4006, 4008, 4012, 4012, 4012, 4016, 4018, 4020, 4021, 4022, 4022, 4024, 4026, 4026, 4026, 4027, 4028, 4032, 4039, 4043, 4044, 4044, 4045, 4046, 4058, 4059, 4062, 4062, 4064, 4065, 4066, 4072, 4078, 4082, 4091, 4105, 4108, 4117, 4120, 4121, 4123, 4125, 4125, 4126, 4132, 4133, 4133, 4135, 4140, 4140, 4141, 4144, 4146, 4152, 4155, 4158, 4159, 4159, 4159, 4163, 4165, 4169, 4171, 4172, 4173, 4173, 4175, 4175, 4177, 4187, 4188, 4190, 4192, 4195, 4202, 4212, 4222, 4230, 4233, 4236, 4237, 4238, 4241, 4245, 4246, 4249, 4255, 4255, 4258, 4264, 4268, 4269, 4272, 4272, 4272, 4273, 4273, 4277, 4278, 4283, 4286, 4287, 4288, 4289, 4292, 4296, 4299, 4300, 4301, 4303, 4304, 4315, 4316, 4319, 4322, 4323, 4326, 4328, 4340, 4345, 4346, 4350, 4358, 4358, 4364, 4370, 4370, 4375, 4383, 4384, 4385, 4385, 4386, 4386, 4386, 4393, 4397, 4401, 4402, 4406, 4409, 4411, 4411, 4413, 4415, 4417, 4419, 4420, 4427, 4427, 4429, 4431, 4437, 4441, 4443, 4444, 4445, 4447, 4451, 4455, 4459, 4462, 4466, 4473, 4483, 4484, 4489, 4493, 4497, 4498, 4499, 4501, 4502, 4506, 4508, 4512, 4514, 4515, 4521, 4526, 4526, 4530, 4532, 4532, 4534, 4538, 4542, 4543, 4544, 4546, 4548, 4556, 4556, 4558, 4558, 4563, 4564, 4564, 4569, 4570, 4574, 4575, 4576, 4580, 4584, 4587, 4591, 4597, 4599, 4613, 4618, 4619, 4623, 4625, 4630, 4636, 4639, 4640, 4640, 4643, 4645, 4646, 4652, 4656, 4656, 4659, 4661, 4661, 4662, 4671, 4676, 4676, 4677, 4677, 4677, 4677, 4679, 4681, 4684, 4684, 4687, 4694, 4703, 4705, 4707, 4712, 4712, 4713, 4721, 4722, 4726, 4726, 4727, 4727, 4736, 4737, 4743, 4751, 4753, 4766, 4774, 4774, 4774, 4774, 4781, 4781, 4790, 4790, 4790, 4790, 4793, 4793, 4800, 4806, 4808, 4808, 4809, 4809, 4809, 4822, 4822, 4823, 4823, 4823, 4823, 4824, 4824, 4824, 4824, 4834, 4836, 4840, 4840, 4840, 4840, 4840, 4850, 4850, 4850, 4850, 4880, 4880, 4937]
print(score(pep, spec))