File: radiolabelling.cpp

package info (click to toggle)
isospec 2.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,472 kB
  • sloc: cpp: 9,530; python: 2,095; makefile: 180; ansic: 100; sh: 88
file content (50 lines) | stat: -rw-r--r-- 2,478 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <cassert>
#include <IsoSpec++/fixedEnvelopes.h>

using namespace IsoSpec;

int main()
{
  // Calculates the isotopic distribution of isotopically labelled glucose, where two of the carbons are replaced with 14C
  // We assume that radiolabelling is 95% efficient (that is, there is a 95% chance for each of the radiolabel atoms to be 14C, and
  // a 5% chance of them being either 12C or 13C, with the probability of each of those proportional to their standard isotopic abundances)


  {
    // First, we construct the glucose molecule WITHOUT the radiolabel atoms - that is C4 instead of C6
    Iso i("C4H12O6");

    // Then, we add the special "element", representing the radiolabel, with custom isotopic distribution (of 3 possible isotopes) and 2 atoms
    const double radiocarbon_masses[3] = {12.0, 13.0033548352, 14.003241989};
    const double radiocarbon_probs[3] = {0.05*0.989211941850466, 0.05*0.010788058149533084, 0.95}; // The standard isotopic distribution of nonradio-carbon multiplied by 0.05, and 0.95 of 14C

    i.addElement(2, 3, radiocarbon_masses, radiocarbon_probs);

    // Additional radiolabel elements can be added by more calls to addElement

    FixedEnvelope iso = FixedEnvelope::FromTotalProb(std::move(i), 0.99, true, true);

    std::cout << "The first configuration has the following parameters: " << std::endl;
    std::cout << "Mass: " << iso.masses()[0] << std::endl;
    std::cout << "probability: " << iso.probs()[0] << std::endl;

    const int* configs = iso.confs();

    // Successive isotopologues are ordered by the appearance in the formula of the element, then by nucleon number, and concatenated into one array
    std::cout << "12C atoms: " << configs[0] + configs[7] << std::endl; // Counting the normal and unsuccesfully radiolabelled atoms
    std::cout << "13C atoms: " << configs[1] + configs[8] << std::endl;
    std::cout << "14C atoms: " << configs[9] << std::endl;
    std::cout << "Protium atoms: " << configs[2] << std::endl;
    std::cout << "Deuterium atoms " << configs[3] << std::endl;
    std::cout << "16O atoms: " << configs[4] << std::endl;
    std::cout << "17O atoms: " << configs[5] << std::endl;
    std::cout << "18O atoms: " << configs[6] << std::endl;


    std::cout << "Probabilities of the remaining computed configurations of the distribution are: " << std::endl;

    for(int ii = 1; ii<iso.confs_no(); ii++)
        std::cout << iso.probs()[ii] << std::endl;
  }
}