IsoSpec
Loading...
Searching...
No Matches
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
34
38inline void parse_fasta(const char* fasta, int atomCounts[6])
39{
40 memset(atomCounts, 0, sizeof(decltype(atomCounts[0]))*6);
41
42 for(size_t idx = 0; fasta[idx] != '\0'; ++idx)
43 {
44 const int* counts = &aa_symbol_to_elem_counts[fasta[idx]*6];
45 for(int ii = 0; ii < 6; ++ii)
46 atomCounts[ii] += counts[ii];
47 }
48}
49
51
54inline void parse_fasta_full(const char* fasta, int atomCounts[6])
55{
56 parse_fasta(fasta, atomCounts);
57 // Add terminal water (H2O) for either precursor or fragment.
58 const int H_INDEX = 1; // Indexing: 0=C, 1=H, 2=N, 3=O, 4=S, 5=Se
59 const int O_INDEX = 3;
60
61 atomCounts[H_INDEX] += 2;
62 atomCounts[O_INDEX] += 1;
63}
64
65
66
67} // namespace IsoSpec
void parse_fasta(const char *fasta, int atomCounts[6])
Count elemental composition of an unmodificed sequence of amino acids, resulting in CHNOSSe counts.
Definition fasta.h:38
void parse_fasta_full(const char *fasta, int atomCounts[6])
Turn an input FASTA aminoacid sequence into atom counts, in CHNOSSe order.
Definition fasta.h:54