IsoSpecPy 2.5.0__py3-none-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. IsoSpecPy/Advanced.py +32 -0
  2. IsoSpecPy/Distributions.py +93 -0
  3. IsoSpecPy/Formulas.py +71 -0
  4. IsoSpecPy/IsoSpec++/aligned_ptr.h +638 -0
  5. IsoSpecPy/IsoSpec++/allocator.h +69 -0
  6. IsoSpecPy/IsoSpec++/btrd.h +206 -0
  7. IsoSpecPy/IsoSpec++/composition.h +126 -0
  8. IsoSpecPy/IsoSpec++/conf.h +38 -0
  9. IsoSpecPy/IsoSpec++/cwrapper.h +271 -0
  10. IsoSpecPy/IsoSpec++/dirtyAllocator.h +58 -0
  11. IsoSpecPy/IsoSpec++/element_lookup.h +36 -0
  12. IsoSpecPy/IsoSpec++/element_tables.h +50 -0
  13. IsoSpecPy/IsoSpec++/fasta.h +70 -0
  14. IsoSpecPy/IsoSpec++/fasta_mods.h +70 -0
  15. IsoSpecPy/IsoSpec++/fixedEnvelopes.h +418 -0
  16. IsoSpecPy/IsoSpec++/isa_kernel_impl.h +192 -0
  17. IsoSpecPy/IsoSpec++/isa_kernels.h +172 -0
  18. IsoSpecPy/IsoSpec++/isoMath.h +121 -0
  19. IsoSpecPy/IsoSpec++/isoSpec++.h +801 -0
  20. IsoSpecPy/IsoSpec++/iso_simd.h +48 -0
  21. IsoSpecPy/IsoSpec++/marginalTrek++.h +614 -0
  22. IsoSpecPy/IsoSpec++/misc.h +229 -0
  23. IsoSpecPy/IsoSpec++/mman.h +67 -0
  24. IsoSpecPy/IsoSpec++/operators.h +150 -0
  25. IsoSpecPy/IsoSpec++/platform.h +180 -0
  26. IsoSpecPy/IsoSpec++/platform_incl.h +33 -0
  27. IsoSpecPy/IsoSpec++/pod_vector.h +400 -0
  28. IsoSpecPy/IsoSpec++/summator.h +118 -0
  29. IsoSpecPy/IsoSpec++/unimod.h +80 -0
  30. IsoSpecPy/IsoSpec++/unimod_support.h +2169 -0
  31. IsoSpecPy/IsoSpec++/unimod_table_data.h +1027 -0
  32. IsoSpecPy/IsoSpecPy.py +1088 -0
  33. IsoSpecPy/IsoSpecPyOld.py +290 -0
  34. IsoSpecPy/PeriodicTbl.py +51 -0
  35. IsoSpecPy/__init__.py +19 -0
  36. IsoSpecPy/__main__.py +25 -0
  37. IsoSpecPy/approximations.py +122 -0
  38. IsoSpecPy/confs_passthrough.py +16 -0
  39. IsoSpecPy/isoFFI.py +290 -0
  40. bin/IsoSpecCppPy.dll +0 -0
  41. isospecpy-2.5.0.dist-info/METADATA +220 -0
  42. isospecpy-2.5.0.dist-info/RECORD +45 -0
  43. isospecpy-2.5.0.dist-info/WHEEL +5 -0
  44. isospecpy-2.5.0.dist-info/licenses/LICENCE +35 -0
  45. lib/IsoSpecCppPy.lib +0 -0
IsoSpecPy/Advanced.py ADDED
@@ -0,0 +1,32 @@
1
+ '''This file contains a set of functions useful for the analysis of properties of
2
+ isotopic envelopes. These are unlikely to be of any interest to end-users, only
3
+ for developers interested in testing some properties of the isotopic envelopes.
4
+ These are implemented mostly in Python, and so, not as fast as the rest of the
5
+ package.'''
6
+
7
+ def _int_neighbours(subisotopologue_conf):
8
+ conf = list(subisotopologue_conf)
9
+ for i in range(len(conf)):
10
+ for j in range(len(conf)):
11
+ if i != j and conf[i] > 0:
12
+ conf[i] -= 1
13
+ conf[j] += 1
14
+ yield tuple(conf)
15
+ conf[i] += 1
16
+ conf[j] -= 1
17
+
18
+
19
+ def neighbours(conf):
20
+ for i in range(len(conf)):
21
+ for si_neigh in _int_neighbours(conf[i]):
22
+ yield tuple(conf[j] if j != i else si_neigh for j in range(len(conf)))
23
+
24
+
25
+
26
+
27
+ def conf_mass(iso, conf):
28
+ return sum(sum(mass * cnt for mass, cnt in zip(masses, cnts)) for masses, cnts in zip(iso.isotopeMasses, conf))
29
+
30
+
31
+ from IsoSpecPy import Iso
32
+ Iso.conf_mass = conf_mass
@@ -0,0 +1,93 @@
1
+ import math
2
+
3
+ from .IsoSpecPy import IsoDistribution
4
+
5
+
6
+
7
+
8
+ def simple_inverse(fun, prec = 0.01):
9
+
10
+ def inverse(x):
11
+ start = -1.0
12
+ while fun(start) > x:
13
+ start *= 2.0
14
+ end = 1.0
15
+ while fun(end) < x:
16
+ end *= 2.0
17
+
18
+ while (end - start) > prec:
19
+ mid = (end + start) * 0.5
20
+ if fun(mid) < x:
21
+ start = mid
22
+ else:
23
+ end = mid
24
+
25
+ return (end + start) * 0.5
26
+
27
+ return inverse
28
+
29
+
30
+
31
+ class Distribution(IsoDistribution):
32
+ def __init__(self, cdf, bin_width = 0.01, precision = 0.99, inverse_cdf = None):
33
+ if inverse_cdf is None:
34
+ inverse_cdf = simple_inverse(cdf, prec = bin_width*0.125)
35
+
36
+ prec_missing = 0.5 * (1.0 - precision)
37
+
38
+ start = inverse_cdf(prec_missing)
39
+ end = inverse_cdf(1.0 - prec_missing)
40
+
41
+ half_bin_width = 0.5*bin_width
42
+
43
+ bw_inverse = 1.0 / bin_width
44
+
45
+ def bw_round(x):
46
+ return math.floor(x*bw_inverse + 0.5) / bw_inverse
47
+
48
+ start = bw_round(start)
49
+ end = bw_round(end)
50
+
51
+ last_bin_start = start - half_bin_width
52
+ last_cdf = cdf(last_bin_start)
53
+
54
+ probs = [0.0]
55
+ masses = [last_bin_start - half_bin_width]
56
+
57
+ while last_bin_start < end:
58
+ next_bin_start = last_bin_start + bin_width
59
+ next_cdf = cdf(next_bin_start)
60
+
61
+ masses.append(last_bin_start + half_bin_width)
62
+ probs.append(next_cdf - last_cdf)
63
+
64
+ last_cdf = next_cdf
65
+ last_bin_start = next_bin_start
66
+
67
+ sprobs = 1.0/sum(probs)
68
+ probs = [p*sprobs for p in probs]
69
+
70
+ probs.append(0.0)
71
+ masses.append(last_bin_start + half_bin_width)
72
+
73
+ super(Distribution, self).__init__(masses = masses, probs = probs)
74
+
75
+ self.mass_sorted = True
76
+
77
+
78
+
79
+ class Gaussian(Distribution):
80
+ def __init__(self, stdev, bin_width = 0.01, precision = 0.99):
81
+ varfactor = 1.0/(stdev * 1.4142135623730951)
82
+ cdf = lambda x: 0.5*(1.0+math.erf(x*varfactor))
83
+ inv_cdf = None
84
+ try:
85
+ # If scipy is available, use its ppf
86
+ from scipy.stats import norm
87
+ inv_cdf = lambda x: norm.ppf(x, loc = 0.0, scale = stdev)
88
+ except ImportError:
89
+ pass # oh well, no scipy, we'll just use binsearch-based inversion
90
+
91
+ super(Gaussian, self).__init__(cdf = cdf, bin_width = bin_width, precision = precision, inverse_cdf = inv_cdf)
92
+
93
+
IsoSpecPy/Formulas.py ADDED
@@ -0,0 +1,71 @@
1
+ from .IsoSpecPy import Iso
2
+ from collections import Counter
3
+
4
+
5
+
6
+ loratadine = "C22H23N2O2Cl1"
7
+ desloratadine = "C19H19N2Cl1"
8
+ titin = "C169719H270466N45688O52238S911"
9
+ bovine_insulin = "C254H377N65O75S6"
10
+ ubiquitin = "C378H629N105O118S1"
11
+ substance_p = "C63H98N18O13S1"
12
+ protein_p16 = "C681H1100N216O208S5"
13
+ cholesterol = "C27H46O1"
14
+ caffeine = "C8H10N4O2"
15
+ water = "H2O1"
16
+ glucose = "C6H12O6"
17
+ sucrose = "C12H22O11"
18
+ horse_myoglobin = "C769H1212N210O218S2"
19
+ oxygen = "O2"
20
+
21
+
22
+
23
+
24
+
25
+ averagine_unit = Counter({
26
+ 'C' : 4.9384,
27
+ 'H' : 7.7583,
28
+ 'N' : 1.3577,
29
+ 'O' : 1.4773,
30
+ 'S' : 0.0417})
31
+
32
+ averagine_mass = 111.1254
33
+
34
+ def fillHs(d, target_avg_mass):
35
+ while True:
36
+ i = Iso(formula = d)
37
+ if i.getTheoreticalAverageMass() > target_avg_mass:
38
+ break
39
+ d['H'] += 1
40
+
41
+ def averagine_dct(target_avg_mass):
42
+ units = float(target_avg_mass) / averagine_mass
43
+ d = dict((key, int(units*val)) for key, val in averagine_unit.items())
44
+ fillHs(d, target_avg_mass)
45
+ for x in list(d.keys()):
46
+ if d[x] == 0:
47
+ del d[x]
48
+ return d
49
+
50
+ def averagine(target_avg_mass):
51
+ return ''.join(str(key)+str(val) for key, val in sorted(averagine_dct(target_avg_mass).items(), key= lambda x: x[0]))
52
+
53
+
54
+ acgt_avg_base = Counter({
55
+ 'C' : 9.75,
56
+ 'H' : 12.25,
57
+ 'N' : 3.75,
58
+ 'O' : 6.0,
59
+ 'P' : 1.0
60
+ })
61
+
62
+ def acgt_dct(no_bases, add_water = True):
63
+ c = {key : int(val*no_bases+0.5) for key, val in acgt_avg_base.items()}
64
+ if add_water:
65
+ c['H'] += 2
66
+ c['O'] += 1
67
+ return c
68
+
69
+ def acgt(no_bases, add_water = True):
70
+ c = acgt_dct(no_bases, add_water = add_water)
71
+ return ''.join(str(key)+str(val) for key, val in sorted(c.items(), key= lambda x: x[0]))