Skip to content

Commit 6211212

Browse files
authored
Merge pull request #57 from MatteoLacki/github_issue_56_fastas
Added docs and another function on C++ side.
2 parents 123171f + a23c37f commit 6211212

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

IsoSpec++/fasta.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ extern const double aa_elem_probabilities[19];
3030

3131
extern const int aa_symbol_to_elem_counts[256*6];
3232

33+
//! Count elemental composition of an unmodificed sequence of amino acids, resulting in CHNOSSe counts.
34+
/*!
35+
WARNING!!! This function does not add the terminating H and OH groups, resulting in a residue backbone skeleton formula.
36+
If you don't know what that means, you should probably be using parse_fasta_full function.
37+
*/
3338
inline void parse_fasta(const char* fasta, int atomCounts[6])
3439
{
3540
memset(atomCounts, 0, sizeof(decltype(atomCounts[0]))*6);
@@ -42,4 +47,21 @@ inline void parse_fasta(const char* fasta, int atomCounts[6])
4247
}
4348
}
4449

50+
//! Turn an input FASTA aminoacid sequence into atom counts, in CHNOSSe order.
51+
/*!
52+
Unlike parse_fasta, this function includes the H and OH groups at the N- and C- termini of the skeleton, resulting in a formula of a full (inert) molecule.
53+
*/
54+
inline 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+
4567
} // namespace IsoSpec

0 commit comments

Comments
 (0)