|
6 | 6 | Welcome to brainpy's documentation! |
7 | 7 | =================================== |
8 | 8 |
|
9 | | -:mod:`brainpy` is a small Python library implementing the *B*afflingly *R*ecursive |
10 | | -*A*lgorithm for *I*sotopic Patter*N* generation. It includes three implementations, |
| 9 | +:mod:`brainpy` is a small Python library implementing the *B* afflingly *R* ecursive |
| 10 | +*A* lgorithm for *I* sotopic Patter *N* generation. It includes three implementations, |
11 | 11 | a pure-Python object oriented implementation, a :title-reference:`Cython` accelerated |
12 | 12 | version of the object oriented implementation, and a pure :title-reference:`C` implementation, |
13 | 13 | listed in order of ascending speed. The C implementation is used by default when available. |
14 | 14 |
|
15 | 15 |
|
16 | 16 | BRAIN takes an elemental composition represented by any :class:`Mapping`-like Python object |
17 | 17 | and uses it to compute its aggregated isotopic distribution. All isotopic variants of the same |
18 | | -number of neutrons are collapsed into a single peak, meaning it does not consider isotopic fine |
19 | | -structure. |
| 18 | +number of neutrons are collapsed into a single centroid peak, meaning it does not consider |
| 19 | +isotopic fine structure. |
20 | 20 |
|
21 | | -.. code-block:: python |
| 21 | +.. plot:: |
| 22 | + :include-source: |
22 | 23 |
|
23 | 24 | from brainpy import isotopic_variants |
24 | 25 |
|
25 | | - leucine = dict(C=6, H=13, O=2, N=1) |
26 | | - theoretical_isotopic_cluster = isotopic_variants(leucine, n_peaks=6, charge=1) |
| 26 | + peptide = {'H': 53, 'C': 34, 'O': 15, 'N': 7} |
| 27 | + theoretical_isotopic_cluster = isotopic_variants(peptide, npeaks=5, charge=1) |
27 | 28 | for peak in theoretical_isotopic_cluster: |
28 | 29 | print(peak.mz, peak.intensity) |
29 | 30 |
|
| 31 | + # produce a theoretical profile using a gaussian peak shape |
| 32 | + import numpy as np |
| 33 | + grid = np.arange(theoretical_isotopic_cluster[0].mz - 1, |
| 34 | + theoretical_isotopic_cluster[-1].mz + 1, 0.02) |
| 35 | + intensity = np.zeros_like(grid) |
| 36 | + sigma = 0.002 |
| 37 | + for i, mz in enumerate(grid): |
| 38 | + for peak in theoretical_isotopic_cluster: |
| 39 | + intensity[i] += peak.intensity * np.exp(-(mz - peak.mz) ** 2 / (2 * sigma) |
| 40 | + ) / (np.sqrt(2 * np.pi) * sigma) |
| 41 | + |
| 42 | + intensity = (intensity / intensity.max()) * 100 |
| 43 | + |
| 44 | + # draw the profile |
| 45 | + from matplotlib import pyplot as plt |
| 46 | + plt.plot(grid, intensity) |
| 47 | + plt.xlabel("m/z") |
| 48 | + plt.ylabel("Relative intensity") |
| 49 | + |
| 50 | + |
30 | 51 | .. automodule:: brainpy |
31 | 52 |
|
32 | 53 | .. autofunction:: isotopic_variants |
|
0 commit comments