IsoSpecPy 2.4.0__cp315-cp315-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.
- IsoSpecPy/Advanced.py +32 -0
- IsoSpecPy/Distributions.py +93 -0
- IsoSpecPy/Formulas.py +71 -0
- IsoSpecPy/IsoSpec++/aligned_ptr.h +622 -0
- IsoSpecPy/IsoSpec++/allocator.h +69 -0
- IsoSpecPy/IsoSpec++/btrd.h +206 -0
- IsoSpecPy/IsoSpec++/conf.h +38 -0
- IsoSpecPy/IsoSpec++/cwrapper.h +223 -0
- IsoSpecPy/IsoSpec++/dirtyAllocator.h +58 -0
- IsoSpecPy/IsoSpec++/element_tables.h +50 -0
- IsoSpecPy/IsoSpec++/fasta.h +70 -0
- IsoSpecPy/IsoSpec++/fixedEnvelopes.h +418 -0
- IsoSpecPy/IsoSpec++/isa_kernel_impl.h +192 -0
- IsoSpecPy/IsoSpec++/isa_kernels.h +172 -0
- IsoSpecPy/IsoSpec++/isoMath.h +107 -0
- IsoSpecPy/IsoSpec++/isoSpec++.h +772 -0
- IsoSpecPy/IsoSpec++/iso_simd.h +48 -0
- IsoSpecPy/IsoSpec++/marginalTrek++.h +617 -0
- IsoSpecPy/IsoSpec++/misc.h +226 -0
- IsoSpecPy/IsoSpec++/mman.h +67 -0
- IsoSpecPy/IsoSpec++/operators.h +150 -0
- IsoSpecPy/IsoSpec++/platform.h +180 -0
- IsoSpecPy/IsoSpec++/platform_incl.h +33 -0
- IsoSpecPy/IsoSpec++/pod_vector.h +401 -0
- IsoSpecPy/IsoSpec++/summator.h +118 -0
- IsoSpecPy/IsoSpecPy.py +924 -0
- IsoSpecPy/IsoSpecPyOld.py +290 -0
- IsoSpecPy/PeriodicTbl.py +34 -0
- IsoSpecPy/__init__.py +19 -0
- IsoSpecPy/__main__.py +25 -0
- IsoSpecPy/approximations.py +122 -0
- IsoSpecPy/confs_passthrough.py +16 -0
- IsoSpecPy/isoFFI.py +263 -0
- bin/IsoSpecCppPy.dll +0 -0
- isospecpy-2.4.0.dist-info/METADATA +159 -0
- isospecpy-2.4.0.dist-info/RECORD +39 -0
- isospecpy-2.4.0.dist-info/WHEEL +5 -0
- isospecpy-2.4.0.dist-info/licenses/LICENCE +35 -0
- lib/IsoSpecCppPy.lib +0 -0
IsoSpecPy/isoFFI.py
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import cffi
|
|
2
|
+
import platform
|
|
3
|
+
import sys
|
|
4
|
+
import glob
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
if False:
|
|
8
|
+
import IsoSpecCppPy
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class IsoFFI:
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.ffi = cffi.FFI()
|
|
14
|
+
self.ffi.cdef(
|
|
15
|
+
"""
|
|
16
|
+
void * setupIso(int dimNumber,
|
|
17
|
+
const int* isotopeNumbers,
|
|
18
|
+
const int* atomCounts,
|
|
19
|
+
const double* isotopeMasses,
|
|
20
|
+
const double* isotopeProbabilities);
|
|
21
|
+
|
|
22
|
+
void * isoFromFasta(const char* fasta, bool use_nominal_masses, bool add_water);
|
|
23
|
+
|
|
24
|
+
double getLightestPeakMassIso(void* iso);
|
|
25
|
+
double getLightestPeakLProbIso(void* iso);
|
|
26
|
+
void getLightestPeakSignature(void* iso, int* space);
|
|
27
|
+
double getHeaviestPeakMassIso(void* iso);
|
|
28
|
+
double getHeaviestPeakLProbIso(void* iso);
|
|
29
|
+
void getHeaviestPeakSignature(void* iso, int* space);
|
|
30
|
+
double getMonoisotopicPeakMassIso(void* iso);
|
|
31
|
+
double getMonoisotopicPeakLProbIso(void* iso);
|
|
32
|
+
void getMonoisotopicPeakSignature(void* iso, int* space);
|
|
33
|
+
double getModeLProbIso(void* iso);
|
|
34
|
+
double getModeMassIso(void* iso);
|
|
35
|
+
double getTheoreticalAverageMassIso(void* iso);
|
|
36
|
+
double getIsoVariance(void* iso);
|
|
37
|
+
double getIsoStddev(void* iso);
|
|
38
|
+
double* getMarginalLogSizeEstimates(void* iso, double target_total_prob);
|
|
39
|
+
|
|
40
|
+
void deleteIso(void* iso);
|
|
41
|
+
|
|
42
|
+
void* setupIsoThresholdGenerator(void* iso,
|
|
43
|
+
double threshold,
|
|
44
|
+
bool _absolute,
|
|
45
|
+
int _tabSize,
|
|
46
|
+
int _hashSize,
|
|
47
|
+
bool reorder_marginals);
|
|
48
|
+
double massIsoThresholdGenerator(void* generator);
|
|
49
|
+
double lprobIsoThresholdGenerator(void* generator);
|
|
50
|
+
double probIsoThresholdGenerator(void* generator);
|
|
51
|
+
bool advanceToNextConfigurationIsoThresholdGenerator(void* generator);
|
|
52
|
+
void deleteIsoThresholdGenerator(void* generator);
|
|
53
|
+
void get_conf_signatureIsoThresholdGenerator(void* generator, int* space);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
void* setupIsoLayeredGenerator(void* iso,
|
|
58
|
+
int _tabSize,
|
|
59
|
+
int _hashSize,
|
|
60
|
+
bool reorder_marginals,
|
|
61
|
+
double t_prob_hint);
|
|
62
|
+
double massIsoLayeredGenerator(void* generator);
|
|
63
|
+
double lprobIsoLayeredGenerator(void* generator);
|
|
64
|
+
double probIsoLayeredGenerator(void* generator);
|
|
65
|
+
bool advanceToNextConfigurationIsoLayeredGenerator(void* generator);
|
|
66
|
+
void deleteIsoLayeredGenerator(void* generator);
|
|
67
|
+
void get_conf_signatureIsoLayeredGenerator(void* generator, int* space);
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
void* setupIsoOrderedGenerator(void* iso,
|
|
71
|
+
int _tabSize,
|
|
72
|
+
int _hashSize);
|
|
73
|
+
double massIsoOrderedGenerator(void* generator);
|
|
74
|
+
double lprobIsoOrderedGenerator(void* generator);
|
|
75
|
+
double probIsoOrderedGenerator(void* generator);
|
|
76
|
+
bool advanceToNextConfigurationIsoOrderedGenerator(void* generator);
|
|
77
|
+
void deleteIsoOrderedGenerator(void* generator);
|
|
78
|
+
void get_conf_signatureIsoOrderedGenerator(void* generator, int* space);
|
|
79
|
+
|
|
80
|
+
void* setupIsoStochasticGenerator(void* iso,
|
|
81
|
+
size_t no_molecules,
|
|
82
|
+
double precision,
|
|
83
|
+
double beta_bias);
|
|
84
|
+
double massIsoStochasticGenerator(void* generator);
|
|
85
|
+
double lprobIsoStochasticGenerator(void* generator);
|
|
86
|
+
double probIsoStochasticGenerator(void* generator);
|
|
87
|
+
bool advanceToNextConfigurationIsoStochasticGenerator(void* generator);
|
|
88
|
+
void deleteIsoStochasticGenerator(void* generator);
|
|
89
|
+
void get_conf_signatureIsoStochasticGenerator(void* generator, int* space);
|
|
90
|
+
|
|
91
|
+
void* setupThresholdFixedEnvelope(void* iso,
|
|
92
|
+
double threshold,
|
|
93
|
+
bool absolute,
|
|
94
|
+
bool get_confs);
|
|
95
|
+
|
|
96
|
+
void* setupTotalProbFixedEnvelope(void* iso,
|
|
97
|
+
double taget_coverage,
|
|
98
|
+
bool optimize,
|
|
99
|
+
bool get_confs);
|
|
100
|
+
|
|
101
|
+
void* setupStochasticFixedEnvelope(void* iso,
|
|
102
|
+
size_t no_molecules,
|
|
103
|
+
double precision,
|
|
104
|
+
double beta_bias,
|
|
105
|
+
bool get_confs);
|
|
106
|
+
|
|
107
|
+
void* setupBinnedFixedEnvelope(void* iso,
|
|
108
|
+
double target_total_prob,
|
|
109
|
+
double bin_width,
|
|
110
|
+
double bin_middle);
|
|
111
|
+
|
|
112
|
+
void* setupFixedEnvelope(double* masses, double* probs, size_t size, bool mass_sorted, bool prob_sorted, double total_prob);
|
|
113
|
+
void* setupFixedEnvelopeWithConfs(double* masses, double* probs, int* confs, size_t size, int allDim, bool mass_sorted, bool prob_sorted, double total_prob);
|
|
114
|
+
void* copyFixedEnvelope(void* other);
|
|
115
|
+
void deleteFixedEnvelope(void* tabulator, bool releaseEverything);
|
|
116
|
+
|
|
117
|
+
const double* massesFixedEnvelope(void* tabulator);
|
|
118
|
+
const double* probsFixedEnvelope(void* tabulator);
|
|
119
|
+
const int* confsFixedEnvelope(void* tabulator);
|
|
120
|
+
size_t confs_noFixedEnvelope(void* tabulator);
|
|
121
|
+
|
|
122
|
+
typedef void (*IsoSpecArrayDeleter)(void* array, size_t size);
|
|
123
|
+
|
|
124
|
+
double* massesFixedEnvelopeWithDeleter(void* tabulator, size_t* size_out, IsoSpecArrayDeleter* deleter_out);
|
|
125
|
+
double* probsFixedEnvelopeWithDeleter(void* tabulator, size_t* size_out, IsoSpecArrayDeleter* deleter_out);
|
|
126
|
+
int* confsFixedEnvelopeWithDeleter(void* tabulator, size_t* size_out, IsoSpecArrayDeleter* deleter_out);
|
|
127
|
+
void freeReleasedArrayWithDeleter(void* array, size_t size, IsoSpecArrayDeleter deleter);
|
|
128
|
+
|
|
129
|
+
double empiricAverageMass(void* tabulator);
|
|
130
|
+
double empiricVariance(void* tabulator);
|
|
131
|
+
double empiricStddev(void* tabulator);
|
|
132
|
+
|
|
133
|
+
double wassersteinDistance(void* tabulator1, void* tabulator2);
|
|
134
|
+
double orientedWassersteinDistance(void* tabulator1, void* tabulator2);
|
|
135
|
+
double abyssalWassersteinDistance(void* tabulator1, void* tabulator2, double abyss_depth, double other_scale);
|
|
136
|
+
// double abyssalWassersteinDistanceGrad(void* const* envelopes, const double* scales, double* ret_gradient, size_t N, double abyss_depth_exp, double abyss_depth_the);
|
|
137
|
+
|
|
138
|
+
struct ws_match_res{
|
|
139
|
+
double res1;
|
|
140
|
+
double res2;
|
|
141
|
+
double flow;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
struct ws_match_res wassersteinMatch(void* tabulator1, void* tabulator2, double flow_dist, double other_scale);
|
|
145
|
+
|
|
146
|
+
void* addEnvelopes(void* tabulator1, void* tabulator2);
|
|
147
|
+
void* convolveEnvelopes(void* tabulator1, void* tabulator2);
|
|
148
|
+
|
|
149
|
+
double getTotalProbOfEnvelope(void* envelope);
|
|
150
|
+
void scaleEnvelope(void* envelope, double factor);
|
|
151
|
+
void normalizeEnvelope(void* envelope);
|
|
152
|
+
void shiftMassEnvelope(void* envelope, double d_mass);
|
|
153
|
+
void resampleEnvelope(void* envelope, size_t ionic_current, double beta_bias);
|
|
154
|
+
void* binnedEnvelope(void* envelope, double width, double middle);
|
|
155
|
+
void* linearCombination(void* const * const envelopes, const double* intensities, size_t count);
|
|
156
|
+
|
|
157
|
+
void sortEnvelopeByMass(void* envelope);
|
|
158
|
+
void sortEnvelopeByProb(void* envelope);
|
|
159
|
+
|
|
160
|
+
void freeReleasedArray(void* array);
|
|
161
|
+
void array_add(double* array, size_t N, double what);
|
|
162
|
+
void array_mul(double* array, size_t N, double what);
|
|
163
|
+
void array_fma(double* array, size_t N, double mul, double add);
|
|
164
|
+
|
|
165
|
+
void parse_fasta_c(const char* fasta, int atomCounts[6]);
|
|
166
|
+
|
|
167
|
+
const char* activeSimdLevel(void);
|
|
168
|
+
|
|
169
|
+
#define NUMBER_OF_ISOTOPIC_ENTRIES 292
|
|
170
|
+
extern const size_t isospec_number_of_isotopic_entries;
|
|
171
|
+
extern const int elem_table_atomicNo[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
172
|
+
extern const double elem_table_probability[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
173
|
+
extern const double elem_table_mass[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
174
|
+
extern const double elem_table_massNo[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
175
|
+
extern const int elem_table_extraNeutrons[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
176
|
+
extern const char* elem_table_element[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
177
|
+
extern const char* elem_table_symbol[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
178
|
+
extern const bool elem_table_Radioactive[NUMBER_OF_ISOTOPIC_ENTRIES];
|
|
179
|
+
"""
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
mod_dir = Path(__file__).resolve().parent
|
|
183
|
+
|
|
184
|
+
if (mod_dir.parent / "setup.py").exists():
|
|
185
|
+
raise ImportError(
|
|
186
|
+
"""Attempted to load IsoSpecPy module from its build directory. This usually
|
|
187
|
+
won't work and is generally a Bad Idea. Please cd somewhere else, or, if you're really
|
|
188
|
+
sure you want to do that, edit the source and disable this check."""
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
libnames = ["IsoSpecCppPy*", "IsoSpec++*"]
|
|
192
|
+
libprefix = ["", "lib", "Lib"]
|
|
193
|
+
extension = [".so", ".dylib", ".dll"]
|
|
194
|
+
try:
|
|
195
|
+
if platform.system() == "Linux":
|
|
196
|
+
extension = [".so", ".pyd"]
|
|
197
|
+
elif platform.system() == "Windows":
|
|
198
|
+
extension = [".dll", ".pyd"]
|
|
199
|
+
except:
|
|
200
|
+
pass
|
|
201
|
+
|
|
202
|
+
prebuilt = ["", "prebuilt-"]
|
|
203
|
+
|
|
204
|
+
def cprod(ll1, ll2):
|
|
205
|
+
res = []
|
|
206
|
+
for l1 in ll1:
|
|
207
|
+
for l2 in ll2:
|
|
208
|
+
res.append(l1 + l2)
|
|
209
|
+
return res
|
|
210
|
+
|
|
211
|
+
paths_to_check = cprod(prebuilt, cprod(libprefix, cprod(libnames, extension)))
|
|
212
|
+
dpc = []
|
|
213
|
+
|
|
214
|
+
for dirpath in [
|
|
215
|
+
mod_dir,
|
|
216
|
+
mod_dir.parent,
|
|
217
|
+
mod_dir.parent / "bin",
|
|
218
|
+
mod_dir.parent / "lib",
|
|
219
|
+
]:
|
|
220
|
+
dpc.extend([dirpath / p for p in paths_to_check])
|
|
221
|
+
|
|
222
|
+
paths_to_check = dpc
|
|
223
|
+
# expand glob patterns using pathlib (keep only actual matches, like glob.glob did)
|
|
224
|
+
expanded = []
|
|
225
|
+
for p in paths_to_check:
|
|
226
|
+
expanded.extend(p.parent.glob(p.name))
|
|
227
|
+
paths_to_check = expanded
|
|
228
|
+
try:
|
|
229
|
+
import importlib
|
|
230
|
+
|
|
231
|
+
paths_to_check.insert(
|
|
232
|
+
0, Path(importlib.util.find_spec("IsoSpecCppPy").origin)
|
|
233
|
+
)
|
|
234
|
+
except (ImportError, AttributeError):
|
|
235
|
+
pass
|
|
236
|
+
|
|
237
|
+
errors = []
|
|
238
|
+
|
|
239
|
+
self.clib = None
|
|
240
|
+
for libpath in set(paths_to_check):
|
|
241
|
+
try:
|
|
242
|
+
self.clib = self.ffi.dlopen(str(libpath))
|
|
243
|
+
self.libpath = libpath
|
|
244
|
+
break
|
|
245
|
+
except (IndexError, OSError) as e:
|
|
246
|
+
errmsg = (
|
|
247
|
+
"Load libIsoSpec++.so, tried: "
|
|
248
|
+
+ str(libpath)
|
|
249
|
+
+ "\n"
|
|
250
|
+
+ "Got error: "
|
|
251
|
+
+ str(type(e))
|
|
252
|
+
+ ": "
|
|
253
|
+
+ str(e)
|
|
254
|
+
)
|
|
255
|
+
errors.append(errmsg)
|
|
256
|
+
|
|
257
|
+
if self.clib == None:
|
|
258
|
+
raise ImportError(
|
|
259
|
+
"Cannot find or load the C++ part of the library\n" + "\n".join(errors)
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
isoFFI = IsoFFI() # This is done while including the module
|
bin/IsoSpecCppPy.dll
ADDED
|
Binary file
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: IsoSpecPy
|
|
3
|
+
Version: 2.4.0
|
|
4
|
+
Summary: IsoSpecPy is a Python library for computing isotopic distributions of molecules.
|
|
5
|
+
Keywords: isotopic distribution,mass spectrometry,chemistry,isotopic envelope,isotopologues
|
|
6
|
+
Author: Michał Startek, Mateusz Łącki
|
|
7
|
+
License-Expression: BSD-2-Clause
|
|
8
|
+
License-File: LICENCE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Project-URL: Homepage, https://github.com/MatteoLacki/IsoSpec
|
|
15
|
+
Project-URL: Repository, https://github.com/MatteoLacki/IsoSpec
|
|
16
|
+
Requires-Python: >=3.6
|
|
17
|
+
Requires-Dist: cffi
|
|
18
|
+
Provides-Extra: testing
|
|
19
|
+
Requires-Dist: pytest; extra == "testing"
|
|
20
|
+
Requires-Dist: OldIsoSpecPy; extra == "testing"
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# IsoSpec
|
|
24
|
+
|
|
25
|
+
IsoSpec is a fine-structure isotopic distribution calculator for chemical formulas — given a molecule, it computes the masses and probabilities of its isotopologues. It is fast enough to handle large molecules (proteins, oligonucleotides) where the full distribution has astronomically many configurations, and it returns provably-optimal subsets that cover a chosen fraction of the total probability mass.
|
|
26
|
+
|
|
27
|
+
IsoSpec is primarily used as a library by mass spectrometry software. It is implemented in C++ (`src/IsoSpec++/`) and shipped with first-class bindings for Python (`IsoSpecPy`, on PyPI) and R (`IsoSpecR`, on CRAN).
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### Python
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install IsoSpecPy
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The wheel bundles the C++ library — no separate native install required. Compatible with CPython and PyPy on Linux, macOS, Windows, and Cygwin/MinGW. Python ≥ 3.6.
|
|
38
|
+
|
|
39
|
+
To build from source: `pip install .` from a checkout. A C++20 compiler is required.
|
|
40
|
+
|
|
41
|
+
### R
|
|
42
|
+
|
|
43
|
+
```r
|
|
44
|
+
install.packages("IsoSpecR")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
From source: `cd src && R CMD build IsoSpecR && R CMD INSTALL IsoSpecR_*.tar.gz`.
|
|
48
|
+
|
|
49
|
+
### C++ library
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cd src/IsoSpec++
|
|
53
|
+
make # produces libIsoSpec++.so
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or via CMake from the repo root:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
|
60
|
+
cmake --build build
|
|
61
|
+
sudo cmake --install build
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Requires a C++20 compiler. CMake produces both shared and static libraries and installs headers under `${CMAKE_INSTALL_INCLUDEDIR}/IsoSpec++`.
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
The most common usage is `IsoTotalProb`: ask for the smallest set of isotopologues whose summed probability covers a chosen fraction of the spectrum (typically 0.99–0.9999). The result is a materialized envelope — arrays of masses and probabilities you can read directly.
|
|
69
|
+
|
|
70
|
+
### Python
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import IsoSpecPy
|
|
74
|
+
|
|
75
|
+
# Isotopologues covering at least 99.9% of the probability mass of water.
|
|
76
|
+
iso = IsoSpecPy.IsoTotalProb(formula="H2O1", prob_to_cover=0.999)
|
|
77
|
+
|
|
78
|
+
for mass, prob in zip(iso.masses, iso.probs):
|
|
79
|
+
print(mass, prob)
|
|
80
|
+
|
|
81
|
+
# From an amino-acid FASTA sequence:
|
|
82
|
+
iso = IsoSpecPy.IsoTotalProb(fasta="AAAPPGQAAC", prob_to_cover=0.999)
|
|
83
|
+
print(list(zip(iso.masses, iso.probs)))
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
See `Examples/Python/` for radiolabelling, custom elements, binned spectra, and FASTA modifications.
|
|
87
|
+
|
|
88
|
+
### C++
|
|
89
|
+
|
|
90
|
+
```cpp
|
|
91
|
+
#include "IsoSpec++/isoSpec++.h"
|
|
92
|
+
#include "IsoSpec++/fixedEnvelopes.h"
|
|
93
|
+
|
|
94
|
+
using namespace IsoSpec;
|
|
95
|
+
|
|
96
|
+
int main() {
|
|
97
|
+
FixedEnvelope iso = FixedEnvelope::FromTotalProb("H2O1", 0.999, true, true);
|
|
98
|
+
|
|
99
|
+
for (size_t i = 0; i < iso.confs_no(); ++i) {
|
|
100
|
+
std::cout << iso.mass(i) << '\t' << iso.prob(i) << '\n';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Quickest way to build:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
clang++ -std=c++20 water.cpp src/IsoSpec++/unity-build.cpp -o water
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
(`unity-build.cpp` is a single translation unit that `#include`s every source file — see `Examples/C++/COMPILING`.)
|
|
112
|
+
|
|
113
|
+
### R
|
|
114
|
+
|
|
115
|
+
```r
|
|
116
|
+
library(IsoSpecR)
|
|
117
|
+
water <- c(H = 2, O = 1)
|
|
118
|
+
IsoSpecify(molecule = water, stopCondition = 0.999)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
See `Examples/R/` for radiolabelling and full-spectrum extraction.
|
|
122
|
+
|
|
123
|
+
## Advanced features
|
|
124
|
+
|
|
125
|
+
- **Alternative algorithms** — for cases where `IsoTotalProb` isn't the right shape:
|
|
126
|
+
- `IsoThreshold` — all isotopologues with probability above a fixed threshold.
|
|
127
|
+
- `IsoStochastic` — simulate a measured spectrum by sampling integer ion counts.
|
|
128
|
+
- `IsoBinned` — histogram-style envelope at a chosen bin width.
|
|
129
|
+
- **FASTA support** — build an `Iso` directly from an amino-acid sequence; optionally include the N/C-terminal water.
|
|
130
|
+
- **Custom isotopic tables** — override natural abundances per element (e.g. for radio- or stable-isotope labelling). See `Examples/*/radiolabelling.*`.
|
|
131
|
+
- **Fixed-envelope arithmetic** — addition, normalization, convolution, Wasserstein distance.
|
|
132
|
+
- **Nominal-mass mode** — compute distributions over nucleon counts instead of real masses.
|
|
133
|
+
- **Streaming generators (for performance)** — the tabulated functions above materialize the full envelope into arrays. For large molecules where that uses too much memory, or for pipelines that consume one configuration at a time (e.g. binning on the fly), use the generator classes instead: `IsoThresholdGenerator`, `IsoLayeredGenerator`, `IsoOrderedGenerator`, `IsoStochasticGenerator`. They yield one isotopologue per call to `advanceToNextConfiguration()` without ever storing the full set. `IsoOrderedGenerator` additionally streams in strict order of decreasing probability.
|
|
134
|
+
|
|
135
|
+
Algorithmic details are in the papers cited below; the Supporting Information of each is the better starting point for implementation specifics.
|
|
136
|
+
|
|
137
|
+
## Repository layout
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
src/IsoSpec++/ C++ core library (the algorithms live here)
|
|
141
|
+
src/IsoSpecPy/ Python binding, loaded via cffi
|
|
142
|
+
src/IsoSpecR/ R binding, via Rcpp
|
|
143
|
+
Examples/ Working examples in each language
|
|
144
|
+
tests/ C, C++, and Python test suites
|
|
145
|
+
skbuild/ scikit-build-core entry point used when installing the Python wheel
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Citation
|
|
149
|
+
|
|
150
|
+
If IsoSpec is useful in your research, please cite:
|
|
151
|
+
|
|
152
|
+
- Łącki, M. K.; Valkenborg, D.; Startek, M. P. *IsoSpec2: Ultrafast Fine Structure Calculator.* Analytical Chemistry **2020**, *92* (14), 9472–9475. <https://doi.org/10.1021/acs.analchem.0c00959>
|
|
153
|
+
- Łącki, M. K.; Startek, M.; Valkenborg, D.; Gambin, A. *IsoSpec: Hyperfast Fine Structure Calculator.* Analytical Chemistry **2017**, *89* (6), 3272–3277. <https://doi.org/10.1021/acs.analchem.6b01459>
|
|
154
|
+
|
|
155
|
+
The Supporting Information of each paper has the algorithmic detail.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
2-clause BSD (see `LICENCE`). If you need different licensing terms, contact the authors. The authors appreciate (but do not require) being told when IsoSpec is used in other software.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
bin/IsoSpecCppPy.dll,sha256=saZ6hcSMpiYaOfbH8Jn3SPxBQz3ZBQN7J8fJAUmoKB8,154624
|
|
2
|
+
IsoSpecPy/__init__.py,sha256=Tjgv2E5pcPq4iSFiuZD4oJiOpqzaMuzkvzQVU843rrE,504
|
|
3
|
+
IsoSpecPy/__main__.py,sha256=Xr6SHPmCkpA3rPFbSBwxd2xl85eEKs6XDTLVWKZxcp4,1034
|
|
4
|
+
IsoSpecPy/Advanced.py,sha256=70LP-AOVr3lsfmCP_zivaXU0auhKWfgt6I8icbptxxg,1090
|
|
5
|
+
IsoSpecPy/approximations.py,sha256=XcNIJlpY6LupKX9bM2Xn2MpPFYYr8UvdkK66_uHq0Vo,4239
|
|
6
|
+
IsoSpecPy/confs_passthrough.py,sha256=Ythe_zSlI2Z69ajCCftubZSqLvHKz2kSRjF1Vc-pE6M,284
|
|
7
|
+
IsoSpecPy/Distributions.py,sha256=-GayrDO1bfs5EdPBMFf5K_b8QRgY-bqgg8qKH7P62fE,2582
|
|
8
|
+
IsoSpecPy/Formulas.py,sha256=blOy63xIfJcfR5WDYHNSCX3CMsdsOvVWpcAraKm67uE,1730
|
|
9
|
+
IsoSpecPy/isoFFI.py,sha256=xd8akGbyF8H4QOQKDsJF_ANv9XRuDUfSsXf1ABHNR1g,11577
|
|
10
|
+
IsoSpecPy/IsoSpec++/aligned_ptr.h,sha256=HvFw6yaNS1QUtltC5yb0QDS8Z3ZMyQMM9dRREHLZR_Y,22709
|
|
11
|
+
IsoSpecPy/IsoSpec++/allocator.h,sha256=dyWhQvpCZnDEby0YMyFbA_dVhYrKwMv8Pk4hLubYaLw,1662
|
|
12
|
+
IsoSpecPy/IsoSpec++/btrd.h,sha256=ZhOCBYgQJ5O6riTdzQaRZiF2UUtDm5gxjmWP6thEbYg,6190
|
|
13
|
+
IsoSpecPy/IsoSpec++/conf.h,sha256=N_dBUbO3RVO9LoSAvjRWtnrjVOqMbcKgbp5q9bJp93M,1008
|
|
14
|
+
IsoSpecPy/IsoSpec++/cwrapper.h,sha256=P7mO-IdyqP2E1DGgeMQhmBZ-OyJVaXZryyokWb1whfs,11405
|
|
15
|
+
IsoSpecPy/IsoSpec++/dirtyAllocator.h,sha256=aB1ebPacCfIPtGXmcxfCP7XJZpu7AuNQrsKlcOE48aI,1472
|
|
16
|
+
IsoSpecPy/IsoSpec++/element_tables.h,sha256=i-ImST2Wgl5WqPOfymndqZSV6UOvHwRWKiiKems4TPM,1844
|
|
17
|
+
IsoSpecPy/IsoSpec++/fasta.h,sha256=urC2lwczY4_dCqrlrD51Joby7JWGj4CMvMIxhSaQyXc,2324
|
|
18
|
+
IsoSpecPy/IsoSpec++/fixedEnvelopes.h,sha256=TB8v7fwATykwTfatHktyrDfxhT790lnaTrAC9ohq_h8,17623
|
|
19
|
+
IsoSpecPy/IsoSpec++/isa_kernel_impl.h,sha256=qKPfLZgYHgBfwQnHUplhMalsS595SPhXTsQhGGHcylA,7974
|
|
20
|
+
IsoSpecPy/IsoSpec++/isa_kernels.h,sha256=NPTB5NYBNY8mZ6fKVt-PtYiFhwXT4g6HVYoWQgw44UA,8753
|
|
21
|
+
IsoSpecPy/IsoSpec++/iso_simd.h,sha256=lkQ7wVZHp9XAMgW4FEIe1t3mWbctJKHueQPKdAX0_B4,2111
|
|
22
|
+
IsoSpecPy/IsoSpec++/isoMath.h,sha256=ac9rDPS1U68tEnlX03mQR0UzteQzucXSZJLX2wy07m4,3631
|
|
23
|
+
IsoSpecPy/IsoSpec++/isoSpec++.h,sha256=Z7BRHnslf-8V8nkjk1LYzAh3HEvHoQOqEUf1sZ9tJzs,34491
|
|
24
|
+
IsoSpecPy/IsoSpec++/marginalTrek++.h,sha256=evkbUfrmU1d4_-ue5pYouBBqN6mnPwQeYS8_H9tCkPU,28095
|
|
25
|
+
IsoSpecPy/IsoSpec++/misc.h,sha256=SymLOhcgtqhI9B0VNpEIxZjbHoxphO_W7BAVb27pSog,5911
|
|
26
|
+
IsoSpecPy/IsoSpec++/mman.h,sha256=RxwibELl7IRwWbn672Gg4-DeDGXXL6tFhM12kIMx5EE,1751
|
|
27
|
+
IsoSpecPy/IsoSpec++/operators.h,sha256=tD5hL-lPpLQ_LOEZMH61eenn-5L67Io-JJ8v7NovUpc,4131
|
|
28
|
+
IsoSpecPy/IsoSpec++/platform.h,sha256=_ysyenKox-wwVMFGD_6V_PEi8lbVfbXl14GGFlyIzJk,7090
|
|
29
|
+
IsoSpecPy/IsoSpec++/platform_incl.h,sha256=6MW4V759ZXdHaHtfH9o5nNmOXj2kCx8E_SiRO1mgBiM,966
|
|
30
|
+
IsoSpecPy/IsoSpec++/pod_vector.h,sha256=wX0UsuFscYrlR4k5nclit6RlYgsam1MSEcVhIYWM-Qs,11844
|
|
31
|
+
IsoSpecPy/IsoSpec++/summator.h,sha256=M-2IV9NU4PTWXIa3fq9Nz3StR9ZT22cZFH1utnmcf98,2425
|
|
32
|
+
IsoSpecPy/IsoSpecPy.py,sha256=_lZGoNLc2dh5HodGdqXDUiQhbwqhBI9GFmY-8n3ngcw,40935
|
|
33
|
+
IsoSpecPy/IsoSpecPyOld.py,sha256=6w1sZBhtyA87zGrAibsAvVDxKfqAZwbmYk_57x70GsI,11383
|
|
34
|
+
IsoSpecPy/PeriodicTbl.py,sha256=8rD2e-IhIrvevvcnaJNWdUXRZfEpSHnqENUifkhtNFw,1368
|
|
35
|
+
lib/IsoSpecCppPy.lib,sha256=wld-7eY4j-o6ABFK_ycKFu9EI0NPCktB84IHvs8pbz4,25190
|
|
36
|
+
isospecpy-2.4.0.dist-info/METADATA,sha256=bvNZ8tgWWyw8W9_Ddml3z5HrLfXwb8FbuvuCG7EV2II,6572
|
|
37
|
+
isospecpy-2.4.0.dist-info/WHEEL,sha256=sOe9ZyOKYW2OWGoOmuTxarYqeA6dIXcgbUUvUoSZ3kk,101
|
|
38
|
+
isospecpy-2.4.0.dist-info/licenses/LICENCE,sha256=gfZw5llAwrHH4rkp5FJuq9VAuamp1x7x8MDmDjj8dpw,1705
|
|
39
|
+
isospecpy-2.4.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
IsoSpec is provided under the terms of 2-clause BSD licence.
|
|
2
|
+
If you require other licensing terms, please contact the authors.
|
|
3
|
+
|
|
4
|
+
We would appreciate if you let us know if you use this library in
|
|
5
|
+
your own software, but you are under no legal obligation to do so.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2015-2025, Michał Startek and Mateusz Łącki
|
|
12
|
+
|
|
13
|
+
All rights reserved.
|
|
14
|
+
|
|
15
|
+
Redistribution and use in source and binary forms, with or without
|
|
16
|
+
modification, are permitted provided that the following conditions are met:
|
|
17
|
+
|
|
18
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
19
|
+
list of conditions and the following disclaimer.
|
|
20
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
21
|
+
this list of conditions and the following disclaimer in the documentation
|
|
22
|
+
and/or other materials provided with the distribution.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
25
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
26
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
27
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
28
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
29
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
30
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
31
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
33
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
|
|
35
|
+
|
lib/IsoSpecCppPy.lib
ADDED
|
Binary file
|