IsoSpecPy 2.3.0.dev11__cp313-cp313-win_arm64.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.
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,94 @@
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
+ print(start, end)
20
+ mid = (end + start) * 0.5
21
+ if fun(mid) < x:
22
+ start = mid
23
+ else:
24
+ end = mid
25
+
26
+ return (end + start) * 0.5
27
+
28
+ return inverse
29
+
30
+
31
+
32
+ class Distribution(IsoDistribution):
33
+ def __init__(self, cdf, bin_width = 0.01, precision = 0.99, inverse_cdf = None):
34
+ if inverse_cdf is None:
35
+ inverse_cdf = simple_inverse(cdf, prec = bin_width*0.125)
36
+
37
+ prec_missing = 0.5 * (1.0 - precision)
38
+
39
+ start = inverse_cdf(prec_missing)
40
+ end = inverse_cdf(1.0 - prec_missing)
41
+
42
+ half_bin_width = 0.5*bin_width
43
+
44
+ bw_inverse = 1.0 / bin_width
45
+
46
+ def bw_round(x):
47
+ return math.floor(x*bw_inverse + 0.5) / bw_inverse
48
+
49
+ start = bw_round(start)
50
+ end = bw_round(end)
51
+
52
+ last_bin_start = start - half_bin_width
53
+ last_cdf = cdf(last_bin_start)
54
+
55
+ probs = [0.0]
56
+ masses = [last_bin_start - half_bin_width]
57
+
58
+ while last_bin_start < end:
59
+ next_bin_start = last_bin_start + bin_width
60
+ next_cdf = cdf(next_bin_start)
61
+
62
+ masses.append(last_bin_start + half_bin_width)
63
+ probs.append(next_cdf - last_cdf)
64
+
65
+ last_cdf = next_cdf
66
+ last_bin_start = next_bin_start
67
+
68
+ sprobs = 1.0/sum(probs)
69
+ probs = [p*sprobs for p in probs]
70
+
71
+ probs.append(0.0)
72
+ masses.append(last_bin_start + half_bin_width)
73
+
74
+ super(Distribution, self).__init__(masses = masses, probs = probs)
75
+
76
+ self.mass_sorted = True
77
+
78
+
79
+
80
+ class Gaussian(Distribution):
81
+ def __init__(self, stdev, bin_width = 0.01, precision = 0.99):
82
+ varfactor = 1.0/(stdev * 1.4142135623730951)
83
+ cdf = lambda x: 0.5*(1.0+math.erf(x*varfactor))
84
+ inv_cdf = None
85
+ try:
86
+ # If scipy is available, use its ppf
87
+ from scipy.stats import norm
88
+ inv_cdf = lambda x: norm.ppf(x, loc = 0.0, scale = stdev)
89
+ except ImportError:
90
+ pass # oh well, no scipy, we'll just use binsearch-based inversion
91
+
92
+ super(Gaussian, self).__init__(cdf = cdf, bin_width = bin_width, precision = precision, inverse_cdf = inv_cdf)
93
+
94
+
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]))
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright (C) 2015-2020 Mateusz Łącki and Michał Startek.
3
+ *
4
+ * This file is part of IsoSpec.
5
+ *
6
+ * IsoSpec is free software: you can redistribute it and/or modify
7
+ * it under the terms of the Simplified ("2-clause") BSD licence.
8
+ *
9
+ * IsoSpec is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ *
13
+ * You should have received a copy of the Simplified BSD Licence
14
+ * along with IsoSpec. If not, see <https://opensource.org/licenses/BSD-2-Clause>.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include <cstring>
20
+ #include "conf.h"
21
+ #include "pod_vector.h"
22
+
23
+ namespace IsoSpec
24
+ {
25
+
26
+ template <typename T> inline void copyConf(
27
+ const T* source, T* destination,
28
+ int dim
29
+ ){
30
+ memcpy(destination, source, dim*sizeof(T));
31
+ }
32
+
33
+ template <typename T> class Allocator
34
+ {
35
+ private:
36
+ T* currentTab;
37
+ int currentId;
38
+ const int dim, tabSize;
39
+ pod_vector<T*> prevTabs;
40
+
41
+ public:
42
+ explicit Allocator(const int dim, const int tabSize = 10000);
43
+ ~Allocator();
44
+
45
+ Allocator(const Allocator& other) = delete;
46
+ Allocator& operator=(const Allocator& other) = delete;
47
+
48
+ void shiftTables();
49
+
50
+ inline T* newConf()
51
+ {
52
+ currentId++;
53
+
54
+ if (currentId >= tabSize)
55
+ shiftTables();
56
+
57
+ return &(currentTab[ currentId * dim ]);
58
+ }
59
+
60
+ inline T* makeCopy(const T* conf)
61
+ {
62
+ T* currentPlace = newConf();
63
+ copyConf<T>( conf, currentPlace, dim );
64
+
65
+ return currentPlace;
66
+ }
67
+ };
68
+
69
+ } // namespace IsoSpec
@@ -0,0 +1,206 @@
1
+ /* This file was taken from Boost, as permitted by Boost licence,
2
+ * with slight modifications. The reason is: we don't want to introduce
3
+ * dependency on the whole Boost just for this one thing.
4
+ *
5
+ * Source: boost random/binomial_distribution.hpp header file, at version 1.71
6
+ *
7
+ * Copyright Steven Watanabe 2010
8
+ * Distributed under the Boost Software License, Version 1.0. (See
9
+ * accompanying file LICENSE_1_0.txt or copy at
10
+ * http://www.boost.org/LICENSE_1_0.txt)
11
+ *
12
+ * See http://www.boost.org for most recent version including documentation.
13
+ *
14
+ */
15
+
16
+ #pragma once
17
+
18
+ #include "isoMath.h"
19
+ #include <cstdlib>
20
+ #include <cstdint>
21
+ #include <cmath>
22
+ #include <limits>
23
+
24
+
25
+ namespace IsoSpec {
26
+
27
+ typedef double RealType;
28
+ typedef int64_t IntType;
29
+
30
+
31
+ static const RealType btrd_binomial_table[10] = {
32
+ 0.08106146679532726,
33
+ 0.04134069595540929,
34
+ 0.02767792568499834,
35
+ 0.02079067210376509,
36
+ 0.01664469118982119,
37
+ 0.01387612882307075,
38
+ 0.01189670994589177,
39
+ 0.01041126526197209,
40
+ 0.009255462182712733,
41
+ 0.008330563433362871
42
+ };
43
+
44
+
45
+ /**
46
+ * The binomial distribution is an integer valued distribution with
47
+ * two parameters, @c t and @c p. The values of the distribution
48
+ * are within the range [0,t].
49
+ *
50
+ * The distribution function is
51
+ * \f$\displaystyle P(k) = {t \choose k}p^k(1-p)^{t-k}\f$.
52
+ *
53
+ * The algorithm used is the BTRD algorithm described in
54
+ *
55
+ * @blockquote
56
+ * "The generation of binomial random variates", Wolfgang Hormann,
57
+ * Journal of Statistical Computation and Simulation, Volume 46,
58
+ * Issue 1 & 2 April 1993 , pages 101 - 110
59
+ * @endblockquote
60
+ */
61
+
62
+
63
+ // computes the correction factor for the Stirling approximation
64
+ // for log(k!)
65
+ static RealType fc(IntType k)
66
+ {
67
+ if(k < 10) { return btrd_binomial_table[k]; }
68
+ else
69
+ {
70
+ RealType ikp1 = RealType(1) / (k + 1);
71
+ return (RealType(1)/12
72
+ - (RealType(1)/360
73
+ - (RealType(1)/1260)*(ikp1*ikp1))*(ikp1*ikp1))*ikp1;
74
+ }
75
+ }
76
+
77
+ IntType btrd(IntType _t, RealType p, IntType m, std::mt19937& urng = random_gen)
78
+ {
79
+ using std::floor;
80
+ using std::abs;
81
+ using std::log;
82
+
83
+ RealType btrd_r = p/(1-p);
84
+ RealType btrd_nr = (_t+1)*btrd_r;
85
+ RealType btrd_npq = _t*p*(1-p);
86
+ RealType sqrt_npq = sqrt(btrd_npq);
87
+ RealType btrd_b = 1.15 + 2.53 * sqrt_npq;
88
+ RealType btrd_a = -0.0873 + 0.0248*btrd_b + 0.01*p;
89
+ RealType btrd_c = _t*p + 0.5;
90
+ RealType btrd_alpha = (2.83 + 5.1/btrd_b) * sqrt_npq;
91
+ RealType btrd_v_r = 0.92 - 4.2/btrd_b;
92
+ RealType btrd_u_rv_r = 0.86*btrd_v_r;
93
+
94
+ while(true) {
95
+ RealType u;
96
+ RealType v = stdunif(urng);
97
+ if(v <= btrd_u_rv_r) {
98
+ u = v/btrd_v_r - 0.43;
99
+ return static_cast<IntType>(floor(
100
+ (2*btrd_a/(0.5 - abs(u)) + btrd_b)*u + btrd_c));
101
+ }
102
+
103
+ if(v >= btrd_v_r) {
104
+ u = stdunif(urng) - 0.5;
105
+ } else {
106
+ u = v/btrd_v_r - 0.93;
107
+ u = ((u < 0)? -0.5 : 0.5) - u;
108
+ v = stdunif(urng) * btrd_v_r;
109
+ }
110
+
111
+ RealType us = 0.5 - abs(u);
112
+ IntType k = static_cast<IntType>(floor((2*btrd_a/us + btrd_b)*u + btrd_c));
113
+ if(k < 0 || k > _t) continue;
114
+ v = v*btrd_alpha/(btrd_a/(us*us) + btrd_b);
115
+ RealType km = abs(k - m);
116
+ if(km <= 15) {
117
+ RealType f = 1;
118
+ if(m < k) {
119
+ IntType i = m;
120
+ do {
121
+ ++i;
122
+ f = f*(btrd_nr/i - btrd_r);
123
+ } while(i != k);
124
+ } else if(m > k) {
125
+ IntType i = k;
126
+ do {
127
+ ++i;
128
+ v = v*(btrd_nr/i - btrd_r);
129
+ } while(i != m);
130
+ }
131
+ if(v <= f) return k;
132
+ else continue;
133
+ } else {
134
+ // final acceptance/rejection
135
+ v = log(v);
136
+ RealType rho =
137
+ (km/btrd_npq)*(((km/3. + 0.625)*km + 1./6)/btrd_npq + 0.5);
138
+ RealType t = -km*km/(2*btrd_npq);
139
+ if(v < t - rho) return k;
140
+ if(v > t + rho) continue;
141
+
142
+ IntType nm = _t - m + 1;
143
+ RealType h = (m + 0.5)*log((m + 1)/(btrd_r*nm))
144
+ + fc(m) + fc(_t - m);
145
+
146
+ IntType nk = _t - k + 1;
147
+ if(v <= h + (_t+1)*log(static_cast<RealType>(nm)/nk)
148
+ + (k + 0.5)*log(nk*btrd_r/(k+1))
149
+ - fc(k)
150
+ - fc(_t - k))
151
+ {
152
+ return k;
153
+ } else {
154
+ continue;
155
+ }
156
+ }
157
+ }
158
+ }
159
+
160
+ IntType invert(IntType t, RealType p, std::mt19937& urng = random_gen)
161
+ {
162
+ RealType q = 1 - p;
163
+ RealType s = p / q;
164
+ RealType a = (t + 1) * s;
165
+ RealType r = pow((1 - p), static_cast<RealType>(t));
166
+ RealType u = stdunif(urng);
167
+ IntType x = 0;
168
+ while(u > r) {
169
+ u = u - r;
170
+ ++x;
171
+ RealType r1 = ((a/x) - s) * r;
172
+ // If r gets too small then the round-off error
173
+ // becomes a problem. At this point, p(i) is
174
+ // decreasing exponentially, so if we just call
175
+ // it 0, it's close enough. Note that the
176
+ // minimum value of q_n is about 1e-7, so we
177
+ // may need to be a little careful to make sure that
178
+ // we don't terminate the first time through the loop
179
+ // for float. (Hence the test that r is decreasing)
180
+ if(r1 < std::numeric_limits<RealType>::epsilon() && r1 < r) {
181
+ break;
182
+ }
183
+ r = r1;
184
+ }
185
+ return x;
186
+ }
187
+
188
+
189
+ IntType boost_binomial_distribution_variate(IntType t_arg, RealType p_arg, std::mt19937& urng = random_gen)
190
+ {
191
+ bool other_side = p_arg > 0.5;
192
+ RealType fake_p = other_side ? 1.0 - p_arg : p_arg;
193
+ IntType m = static_cast<IntType>((t_arg+1)*fake_p);
194
+ IntType result;
195
+ if(m < 11)
196
+ result = invert(t_arg, fake_p, urng);
197
+ else
198
+ result = btrd(t_arg, fake_p, m, urng);
199
+
200
+ if(other_side)
201
+ return t_arg - result;
202
+ else
203
+ return result;
204
+ }
205
+
206
+ } // namespace IsoSpec
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (C) 2015-2020 Mateusz Łącki and Michał Startek.
3
+ *
4
+ * This file is part of IsoSpec.
5
+ *
6
+ * IsoSpec is free software: you can redistribute it and/or modify
7
+ * it under the terms of the Simplified ("2-clause") BSD licence.
8
+ *
9
+ * IsoSpec is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ *
13
+ * You should have received a copy of the Simplified BSD Licence
14
+ * along with IsoSpec. If not, see <https://opensource.org/licenses/BSD-2-Clause>.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ namespace IsoSpec
20
+ {
21
+
22
+ typedef int* Conf;
23
+
24
+ struct ProbAndConfPtr
25
+ {
26
+ // For some reason std::pair isn't trivially copyable...
27
+ double first;
28
+ Conf second;
29
+
30
+ ProbAndConfPtr(double p, Conf c) : first(p), second(c) {}
31
+
32
+ bool operator<(const ProbAndConfPtr& other) const
33
+ {
34
+ return first < other.first;
35
+ }
36
+ };
37
+
38
+ } // namespace IsoSpec
@@ -0,0 +1,179 @@
1
+ /*
2
+ * Copyright (C) 2015-2020 Mateusz Łącki and Michał Startek.
3
+ *
4
+ * This file is part of IsoSpec.
5
+ *
6
+ * IsoSpec is free software: you can redistribute it and/or modify
7
+ * it under the terms of the Simplified ("2-clause") BSD licence.
8
+ *
9
+ * IsoSpec is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ *
13
+ * You should have received a copy of the Simplified BSD Licence
14
+ * along with IsoSpec. If not, see <https://opensource.org/licenses/BSD-2-Clause>.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ #include "platform.h"
20
+
21
+ #define ISOSPEC_ALGO_LAYERED 0
22
+ #define ISOSPEC_ALGO_ORDERED 1
23
+ #define ISOSPEC_ALGO_THRESHOLD_ABSOLUTE 2
24
+ #define ISOSPEC_ALGO_THRESHOLD_RELATIVE 3
25
+ #define ISOSPEC_ALGO_LAYERED_ESTIMATE 4
26
+
27
+
28
+ #ifdef __cplusplus
29
+ extern "C" {
30
+ #else
31
+ #include <stdbool.h>
32
+ #endif
33
+
34
+ ISOSPEC_C_API void * setupIso(int dimNumber,
35
+ const int* isotopeNumbers,
36
+ const int* atomCounts,
37
+ const double* isotopeMasses,
38
+ const double* isotopeProbabilities);
39
+
40
+ ISOSPEC_C_API void * isoFromFasta(const char* fasta, bool use_nominal_masses, bool add_water);
41
+
42
+ ISOSPEC_C_API double getLightestPeakMassIso(void* iso);
43
+ ISOSPEC_C_API double getHeaviestPeakMassIso(void* iso);
44
+ ISOSPEC_C_API double getMonoisotopicPeakMassIso(void* iso);
45
+ ISOSPEC_C_API double getModeLProbIso(void* iso);
46
+ ISOSPEC_C_API double getModeMassIso(void* iso);
47
+ ISOSPEC_C_API double getTheoreticalAverageMassIso(void* iso);
48
+ ISOSPEC_C_API double getIsoVariance(void* iso);
49
+ ISOSPEC_C_API double getIsoStddev(void* iso);
50
+ ISOSPEC_C_API double* getMarginalLogSizeEstimates(void* iso, double target_total_prob);
51
+
52
+
53
+ ISOSPEC_C_API void deleteIso(void* iso);
54
+
55
+
56
+ // ______________________________________________________THRESHOLD GENERATOR
57
+ ISOSPEC_C_API void* setupIsoThresholdGenerator(void* iso,
58
+ double threshold,
59
+ bool _absolute,
60
+ int _tabSize,
61
+ int _hashSize,
62
+ bool reorder_marginals);
63
+ ISOSPEC_C_API double massIsoThresholdGenerator(void* generator);
64
+ ISOSPEC_C_API double lprobIsoThresholdGenerator(void* generator);
65
+ ISOSPEC_C_API double probIsoThresholdGenerator(void* generator);
66
+ ISOSPEC_C_API void get_conf_signatureIsoThresholdGenerator(void* generator, int* space);
67
+ ISOSPEC_C_API bool advanceToNextConfigurationIsoThresholdGenerator(void* generator);
68
+ ISOSPEC_C_API void deleteIsoThresholdGenerator(void* generator);
69
+
70
+
71
+ // ______________________________________________________LAYERED GENERATOR
72
+ ISOSPEC_C_API void* setupIsoLayeredGenerator(void* iso,
73
+ int _tabSize,
74
+ int _hashSize,
75
+ bool reorder_marginals,
76
+ double t_prob_hint);
77
+ ISOSPEC_C_API double massIsoLayeredGenerator(void* generator);
78
+ ISOSPEC_C_API double lprobIsoLayeredGenerator(void* generator);
79
+ ISOSPEC_C_API double probIsoLayeredGenerator(void* generator);
80
+ ISOSPEC_C_API void get_conf_signatureIsoLayeredGenerator(void* generator, int* space);
81
+ ISOSPEC_C_API bool advanceToNextConfigurationIsoLayeredGenerator(void* generator);
82
+ ISOSPEC_C_API void deleteIsoLayeredGenerator(void* generator);
83
+
84
+ // ______________________________________________________ORDERED GENERATOR
85
+ ISOSPEC_C_API void* setupIsoOrderedGenerator(void* iso,
86
+ int _tabSize,
87
+ int _hashSize);
88
+ ISOSPEC_C_API double massIsoOrderedGenerator(void* generator);
89
+ ISOSPEC_C_API double lprobIsoOrderedGenerator(void* generator);
90
+ ISOSPEC_C_API double probIsoOrderedGenerator(void* generator);
91
+ ISOSPEC_C_API void get_conf_signatureIsoOrderedGenerator(void* generator, int* space);
92
+ ISOSPEC_C_API bool advanceToNextConfigurationIsoOrderedGenerator(void* generator);
93
+ ISOSPEC_C_API void deleteIsoOrderedGenerator(void* generator);
94
+
95
+ // ______________________________________________________STOCHASTIC GENERATOR
96
+ ISOSPEC_C_API void* setupIsoStochasticGenerator(void* iso,
97
+ size_t no_molecules,
98
+ double precision,
99
+ double beta_bias);
100
+ ISOSPEC_C_API double massIsoStochasticGenerator(void* generator);
101
+ ISOSPEC_C_API double lprobIsoStochasticGenerator(void* generator);
102
+ ISOSPEC_C_API double probIsoStochasticGenerator(void* generator);
103
+ ISOSPEC_C_API void get_conf_signatureIsoStochasticGenerator(void* generator, int* space);
104
+ ISOSPEC_C_API bool advanceToNextConfigurationIsoStochasticGenerator(void* generator);
105
+ ISOSPEC_C_API void deleteIsoStochasticGenerator(void* generator);
106
+
107
+ ISOSPEC_C_API void* setupThresholdFixedEnvelope(void* iso,
108
+ double threshold,
109
+ bool absolute,
110
+ bool get_confs);
111
+
112
+ ISOSPEC_C_API void* setupTotalProbFixedEnvelope(void* iso,
113
+ double taget_coverage,
114
+ bool optimize,
115
+ bool get_confs);
116
+
117
+ ISOSPEC_C_API void* setupStochasticFixedEnvelope(void* iso,
118
+ size_t no_molecules,
119
+ double precision,
120
+ double beta_bias,
121
+ bool get_confs);
122
+
123
+ ISOSPEC_C_API void* setupBinnedFixedEnvelope(void* iso,
124
+ double target_total_prob,
125
+ double bin_width,
126
+ double bin_middle);
127
+
128
+ ISOSPEC_C_API void freeReleasedArray(void* array);
129
+
130
+ ISOSPEC_C_API void array_add(double* array, size_t N, double what);
131
+ ISOSPEC_C_API void array_mul(double* array, size_t N, double what);
132
+ ISOSPEC_C_API void array_fma(double* array, size_t N, double mul, double add);
133
+
134
+ ISOSPEC_C_API void* setupFixedEnvelope(double* masses, double* probs, size_t size, bool mass_sorted, bool prob_sorted, double total_prob);
135
+ ISOSPEC_C_API void* copyFixedEnvelope(void* other);
136
+ ISOSPEC_C_API void deleteFixedEnvelope(void* tabulator, bool releaseEverything);
137
+
138
+ ISOSPEC_C_API const double* massesFixedEnvelope(void* tabulator);
139
+ ISOSPEC_C_API const double* probsFixedEnvelope(void* tabulator);
140
+ ISOSPEC_C_API const int* confsFixedEnvelope(void* tabulator);
141
+ ISOSPEC_C_API size_t confs_noFixedEnvelope(void* tabulator);
142
+
143
+ ISOSPEC_C_API double empiricAverageMass(void* tabulator);
144
+ ISOSPEC_C_API double empiricVariance(void* tabulator);
145
+ ISOSPEC_C_API double empiricStddev(void* tabulator);
146
+
147
+ ISOSPEC_C_API double wassersteinDistance(void* tabulator1, void* tabulator2);
148
+ ISOSPEC_C_API double orientedWassersteinDistance(void* tabulator1, void* tabulator2);
149
+ ISOSPEC_C_API double abyssalWassersteinDistance(void* tabulator1, void* tabulator2, double abyss_depth, double other_scale);
150
+ //ISOSPEC_C_API double abyssalWassersteinDistanceGrad(void* const* envelopes, const double* scales, double* ret_gradient, size_t N, double abyss_depth_exp, double abyss_depth_the);
151
+
152
+ struct ws_match_res{
153
+ double res1;
154
+ double res2;
155
+ double flow;
156
+ };
157
+
158
+ ISOSPEC_C_API struct ws_match_res wassersteinMatch(void* tabulator1, void* tabulator2, double flow_dist, double other_scale);
159
+
160
+ ISOSPEC_C_API void* addEnvelopes(void* tabulator1, void* tabulator2);
161
+ ISOSPEC_C_API void* convolveEnvelopes(void* tabulator1, void* tabulator2);
162
+
163
+ ISOSPEC_C_API double getTotalProbOfEnvelope(void* envelope);
164
+ ISOSPEC_C_API void scaleEnvelope(void* envelope, double factor);
165
+ ISOSPEC_C_API void normalizeEnvelope(void* envelope);
166
+ ISOSPEC_C_API void shiftMassEnvelope(void* envelope, double d_mass);
167
+ ISOSPEC_C_API void resampleEnvelope(void* envelope, size_t ionic_current, double beta_bias);
168
+ ISOSPEC_C_API void* binnedEnvelope(void* envelope, double width, double middle);
169
+ ISOSPEC_C_API void* linearCombination(void* const * const envelopes, const double* intensities, size_t count);
170
+
171
+ ISOSPEC_C_API void sortEnvelopeByMass(void* envelope);
172
+ ISOSPEC_C_API void sortEnvelopeByProb(void* envelope);
173
+
174
+ ISOSPEC_C_API void parse_fasta_c(const char* fasta, int atomCounts[6]);
175
+
176
+
177
+ #ifdef __cplusplus
178
+ }
179
+ #endif