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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Module used to create the [`IsAminoAcid`] trait
use crate::{
chemistry::{MassMode, MolecularFormula, MultiChemical, SatelliteLabel},
quantities::Multi,
sequence::SequencePosition,
system::Mass,
};
use std::borrow::Cow;
/// A general trait to define amino acids.
pub trait IsAminoAcid: MultiChemical {
/// The full name for this amino acid.
fn name(&self) -> Cow<'_, str>;
/// The three letter code for this amino acid. Or None if there is no common three letter
/// definition for this amino acid.
fn three_letter_code(&self) -> Option<Cow<'_, str>>;
/// The one letter code for this amino acid. Or None if there is no common single character
/// definition for this amino acid.
#[doc(alias = "code")]
fn one_letter_code(&self) -> Option<char>;
/// The ProForma definition for this amino acid. If this is not a simple amino acid it can be
/// defined as an amino acid with an additional modification. For example `X[H9C2N2]` could be
/// used if Arginine was not defined as `R` in ProForma.
fn pro_forma_definition(&self) -> Cow<'_, str>;
/// The monoisotopic mass of this amino acid. Should be redefined for better performance.
fn monoisotopic_mass(&self) -> Cow<'_, Multi<Mass>> {
Cow::Owned(
self.formulas()
.iter()
.map(MolecularFormula::monoisotopic_mass)
.collect(),
)
}
/// The average weight of this amino acid. Should be redefined for better performance.
fn average_weight(&self) -> Cow<'_, Multi<Mass>> {
Cow::Owned(
self.formulas()
.iter()
.map(MolecularFormula::average_weight)
.collect(),
)
}
/// The mass with a given mass mode for this amino acid. Should be redefined for better performance.
fn mass(&self, mode: MassMode) -> Cow<'_, Multi<Mass>> {
Cow::Owned(self.formulas().iter().map(|f| f.mass(mode)).collect())
}
/// The molecular formula of the side chain of the amino acid. The `sequence_index` and
/// `peptidoform_index` are used to keep track of ambiguous amino acids.
fn side_chain(
&self,
sequence_index: SequencePosition,
peptidoform_index: usize,
peptidoform_ion_index: usize,
) -> Cow<'_, Multi<MolecularFormula>>;
/// The molecular formulas that can fragment for satellite ions (d and w). Commonly the fragment
/// after the second carbon into the side chain. `MolecularFormula::default()` can be returned
/// if no satellite ions are possible. The `sequence_index` and `peptidoform_index` are used to
/// keep track of ambiguous amino acids.
fn satellite_ion_fragments(
&self,
sequence_index: SequencePosition,
peptidoform_index: usize,
peptidoform_ion_index: usize,
) -> Option<Cow<'_, [(SatelliteLabel, MolecularFormula)]>>;
}