Skip to main content

IsoSpec

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.

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).

Installation

Python

pip install IsoSpecPy

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.9.

To build from source: pip install . from a checkout. A C++20 compiler is required.

R

install.packages("IsoSpecR")

From source: cd src && R CMD build IsoSpecR && R CMD INSTALL IsoSpecR_*.tar.gz.

C++ library

cd src/IsoSpec++
make            # produces libIsoSpec++.so

Or via CMake from the repo root:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
sudo cmake --install build

Requires a C++20 compiler. CMake produces both shared and static libraries and installs headers under ${CMAKE_INSTALL_INCLUDEDIR}/IsoSpec++.

Quick start

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.

Python

import IsoSpecPy

# Isotopologues covering at least 99.9% of the probability mass of water.
iso = IsoSpecPy.IsoTotalProb(formula="H2O1", prob_to_cover=0.999)

for mass, prob in zip(iso.masses, iso.probs):
    print(mass, prob)

# From an amino-acid sequence:
iso = IsoSpecPy.IsoTotalProb(peptide_sequence="AAAPPGQAAC", prob_to_cover=0.999)
print(list(zip(iso.masses, iso.probs)))

# ...optionally carrying [UNIMOD:<id>] modification tags (the notation this
# monorepo's SAGE search-engine fork writes: [UNIMOD:<id>]-SEQUENCE prefix
# for an N-terminal mod, X[UNIMOD:<id>] inline for an internal one,
# SEQUENCE-[UNIMOD:<id>] suffix for a C-terminal one):
iso = IsoSpecPy.IsoTotalProb(peptide_sequence="PEPTC[UNIMOD:4]DEK", prob_to_cover=0.999)
print(list(zip(iso.masses, iso.probs)))

# Mind the water: peptide_sequence= yields the *residue* composition, without
# the terminal H2O of a free peptide, so the masses above are 18.0106 Da
# lighter than the neutral molecule. Add it explicitly for the real peptide
# (the C++ Iso::FromFASTAWithMods below adds it by default -- the two APIs
# differ here, and this is the older Python behaviour kept for compatibility):
iso = IsoSpecPy.IsoTotalProb(peptide_sequence="PEPTC[UNIMOD:4]DEK", formula="H2O1",
                             prob_to_cover=0.999)

# Or get just the composition (element -> atom count), no envelope:
composition = IsoSpecPy.ParsePeptideSequence("PEPTC[UNIMOD:4]DEK")
print(dict(composition))  # {'H': 60, 'C': 39, 'N': 10, 'O': 16, 'S': 1}

Resolves against a table of ~980 Unimod entries embedded in the library (isotope-labelled and glycan/derivatization "brick" modifications are excluded -- they aren't representable as a pure elemental delta). Pass unimod_db_path="/path/to/table.csv" to either function to resolve against a different table instead (same id,name,mono_mass,composition CSV shape as the embedded default).

See Examples/Python/ for radiolabelling, custom elements, binned spectra, and FASTA/Unimod modifications.

C++

#include "IsoSpec++/isoSpec++.h"
#include "IsoSpec++/fixedEnvelopes.h"

using namespace IsoSpec;

int main() {
    FixedEnvelope iso = FixedEnvelope::FromTotalProb("H2O1", 0.999, true, true);

    for (size_t i = 0; i < iso.confs_no(); ++i) {
        std::cout << iso.mass(i) << '\t' << iso.prob(i) << '\n';
    }
}

From a peptide sequence, optionally carrying [UNIMOD:<id>] modification tags (fasta_mods.h; same notation as the Python/R examples above):

#include "IsoSpec++/isoSpec++.h"
#include "IsoSpec++/fasta_mods.h"
#include "IsoSpec++/fixedEnvelopes.h"

using namespace IsoSpec;

int main() {
    FixedEnvelope iso = FixedEnvelope::FromTotalProb(
        Iso::FromFASTAWithMods("PEPTC[UNIMOD:4]DEK"), 0.999, true, true);

    for (size_t i = 0; i < iso.confs_no(); ++i) {
        std::cout << iso.mass(i) << '\t' << iso.prob(i) << '\n';
    }
}

Iso::FromFASTAWithMods takes an optional trailing unimod_db_path argument to resolve against a different Unimod table instead of the one embedded at compile time. For just the composition, no envelope, call parse_fasta_with_mods/parse_fasta_with_mods_full directly (or the allocation-free _into forms, for a hot loop over many sequences) — see fasta_mods.h.

Quickest way to build:

clang++ -std=c++20 water.cpp src/IsoSpec++/unity-build.cpp -o water

(unity-build.cpp is a single translation unit that #includes every source file — see Examples/C++/COMPILING.)

R

library(IsoSpecR)
water <- c(H = 2, O = 1)
IsoSpecify(molecule = water, stopCondition = 0.999)

IsoSpecify only ever takes a raw named-integer-vector molecule -- it has no sequence-string parameter -- so a [UNIMOD:<id>]-annotated peptide sequence takes two calls instead of one: RParsePeptideSequence() to resolve the sequence into a composition, then IsoSpecify() as above.

composition <- RParsePeptideSequence("PEPTC[UNIMOD:4]DEK")
print(composition)  #  H  C  N  O  S
                     # 60 39 10 16  1
IsoSpecify(molecule = composition, stopCondition = 0.999)

Like the Python ParsePeptideSequence, this returns the residue composition without a free peptide's terminal H2O -- add c(H = 2, O = 1) to it for the neutral molecule. A modification whose delta removes more atoms of an element than the bare sequence provides gives a negative count ("G[UNIMOD:11]" nets H -1, S -1); IsoSpecify rejects such a vector rather than quietly dropping those elements.

See Examples/R/ for radiolabelling, full-spectrum extraction, and Unimod-annotated sequences.

Advanced features

  • Alternative algorithms — for cases where IsoTotalProb isn't the right shape:
    • IsoThreshold — all isotopologues with probability above a fixed threshold.
    • IsoStochastic — simulate a measured spectrum by sampling integer ion counts.
    • IsoBinned — histogram-style envelope at a chosen bin width.
  • FASTA/peptide-sequence support — build an Iso directly from an amino-acid sequence, with [UNIMOD:<id>] modification tags recognized inline; optionally include the N/C-terminal water.
  • Custom isotopic tables — override natural abundances per element (e.g. for radio- or stable-isotope labelling). See Examples/*/radiolabelling.*.
  • Fixed-envelope arithmetic — addition, normalization, convolution, Wasserstein distance.
  • Nominal-mass mode — compute distributions over nucleon counts instead of real masses.
  • 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.

Algorithmic details are in the papers cited below; the Supporting Information of each is the better starting point for implementation specifics.

Repository layout

src/IsoSpec++/    C++ core library (the algorithms live here)
src/IsoSpecPy/    Python binding, loaded via cffi
src/IsoSpecR/     R binding, via Rcpp
Examples/         Working examples in each language
tests/            C, C++, and Python test suites
skbuild/          scikit-build-core entry point used when installing the Python wheel

Citation

If IsoSpec is useful in your research, please cite:

The Supporting Information of each paper has the algorithmic detail.

License

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.

Metadata

Release files for IsoSpecPy 2.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for IsoSpecPy 2.5.0
File Size Uploaded
isospecpy-2.5.0.tar.gz 174.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for IsoSpecPy 2.5.0
File
isospecpy-2.5.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
isospecpy-2.5.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
isospecpy-2.5.0-py3-none-win32.whl Python 3 none Windows x86-32 Details
isospecpy-2.5.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
isospecpy-2.5.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
isospecpy-2.5.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
isospecpy-2.5.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
isospecpy-2.5.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
isospecpy-2.5.0-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 5.2 MB

Release files / isospecpy-2.5.0.tar.gz

Download URL isospecpy-2.5.0.tar.gz
Size 174.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dab5d46773d83d774577081d25099e3c311b91cb0a0ae8b270d4311470453c61
BLAKE2b-256 checksum
How to use checksums
8969e43c8cffa9f1470671dfd8790809b22fff38c21b761a1c9e7c7b30d64882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-win_arm64.whl

Download URL isospecpy-2.5.0-py3-none-win_arm64.whl
Size 237.4 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
493f7124d86776435c969aa1f0af980c6a664db1bb003b50db813c31e3ded41b
BLAKE2b-256 checksum
How to use checksums
ce7a76f11e509da462b8b4876dab040342daa28d9bd591d53228ce91eee06134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-win_amd64.whl

Download URL isospecpy-2.5.0-py3-none-win_amd64.whl
Size 243.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
63c40cbb7b0ab66c1e008617627a1ddfaeff14adb91d6e477cc77775fd7c22d3
BLAKE2b-256 checksum
How to use checksums
90f5db1c577b30537e98258ebb99c1bd40e8451b079c97e988b672bbc4e32e88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-win32.whl

Download URL isospecpy-2.5.0-py3-none-win32.whl
Size 233.6 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
e24ce3fc3cd79c40f7ac534e51b074c257856f241a2786af8fb44df2da7d4fc9
BLAKE2b-256 checksum
How to use checksums
eaefee72016b62f317616f1aebfafc8a6f4bc6f293899240fe4d9a4292fb06e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-musllinux_1_2_x86_64.whl

Download URL isospecpy-2.5.0-py3-none-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
114ea1ac992d3f51e749cfe451e277619e88a62bdc04a8c92168923dd33efb05
BLAKE2b-256 checksum
How to use checksums
1d19aaffc43e04096252afe430e994f81ffec1626f398abc21f20dac62b4eed5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-musllinux_1_2_aarch64.whl

Download URL isospecpy-2.5.0-py3-none-musllinux_1_2_aarch64.whl
Size 1.2 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b28f33a9e448dcce14724c8913c686c88495dcf148f66f74b27a7f828944c626
BLAKE2b-256 checksum
How to use checksums
40e4a9c29b436316b2e2e6ec501e698b36853db3b8422c524d5afb1db6e381f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL isospecpy-2.5.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 274.8 kB
Tags Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
4063a4c7323436af8abf246ef5fa602727de58cb24229e871812b3e91dce65d0
BLAKE2b-256 checksum
How to use checksums
ea171273ad72f34206cb2b73debdd442fa539343ebc43a6c2a5528d261dfccbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL isospecpy-2.5.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 259.9 kB
Tags Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
1a2b3f3e8b68b134066c1e0415533825ccd4b7172993e7133858f4e70c3b614c
BLAKE2b-256 checksum
How to use checksums
88a7f3300c2f07f333f8649511917e1e08259505174da9988faf388f780bbedd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-macosx_11_0_arm64.whl

Download URL isospecpy-2.5.0-py3-none-macosx_11_0_arm64.whl
Size 598.8 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
21205879d5352f2bcbfb26be6517ec7536f8aec7444908a2eb58819dcf2b03c3
BLAKE2b-256 checksum
How to use checksums
5501b8c5c77c4b9b54c333ff75a3f9fe34bdc4607c178bb479426aa3d9f1b927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / isospecpy-2.5.0-py3-none-macosx_10_9_x86_64.whl

Download URL isospecpy-2.5.0-py3-none-macosx_10_9_x86_64.whl
Size 644.9 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f4acf3767732f9ed695e14ea316d64caf3e24fa4404adeb2a23e3c6a6f3b73a3
BLAKE2b-256 checksum
How to use checksums
916e56f56defe75088e050f7be0fbdae612719aa3635de071db281f3cfd2d309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.5.0 This release

10 release files

2.4.0

87 release files

2.3.5

77 release files

2.3.4

77 release files

2.3.3

76 release files

2.3.1

76 release files

2.3.0

76 release files

2.2.3

31 release files

2.2.2

38 release files

2.2.1

16 release files

2.1.4

1 release file

2.1.3

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.9.3

1 release file

1.9.2

1 release file

1.9.1

1 release file

1.9.0

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page