IsoSpec 2.2.1
fasta.h
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
18#pragma once
19
20namespace IsoSpec{
21
22// We will work with C H N O S Se tuples */
23extern const int aa_isotope_numbers[6];
24
25extern const double aa_elem_masses[19];
26
27extern const double aa_elem_nominal_masses[19];
28
29extern const double aa_elem_probabilities[19];
30
31extern const int aa_symbol_to_elem_counts[256*6];
32
33inline void parse_fasta(const char* fasta, int atomCounts[6])
34{
35 memset(atomCounts, 0, sizeof(decltype(atomCounts[0]))*6);
36
37 for(size_t idx = 0; fasta[idx] != '\0'; ++idx)
38 {
39 const int* counts = &aa_symbol_to_elem_counts[fasta[idx]*6];
40 for(int ii = 0; ii < 6; ++ii)
41 atomCounts[ii] += counts[ii];
42 }
43}
44
45} // namespace IsoSpec