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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#![doc = include_str!("../README.md")]
#![allow(dead_code)]
#![warn(clippy::all, clippy::pedantic, clippy::nursery, missing_docs)]
#![allow(
    clippy::must_use_candidate,
    clippy::cast_precision_loss,
    clippy::cast_possible_truncation,
    clippy::cast_sign_loss,
    clippy::wildcard_imports,
    clippy::module_name_repetitions,
    clippy::suboptimal_flops,
    clippy::too_many_lines
)]

#[cfg(feature = "align")]
/// Only available with feature `align`.
pub mod align;

#[cfg(feature = "identification")]
/// Only available with feature `identification`.
pub mod identification;

#[cfg(feature = "imgt")]
/// Only available with feature `imgt`.
pub mod imgt;

#[cfg(test)]
mod fragmentation_tests;
#[cfg(test)]
mod pro_forma_parse_tests;
#[macro_use]
mod helper_functions;
#[macro_use]
mod formula;

#[doc(hidden)]
#[path = "shared/csv.rs"]
pub mod csv;

pub mod aminoacid_properties;
mod aminoacids;
mod complex_peptide;
mod element;
pub mod error;
pub mod fragment;
mod fragmentation;
pub mod glycan;
mod isobaric_sets;
mod isotopes;
mod itertools_extension;
mod linear_peptide;
pub mod model;
pub mod modification;
mod molecular_charge;
mod multi;
mod multi_formula;
mod neutral_loss;
pub mod ontologies;
pub mod placement_rule;
mod protease;
pub mod rawfile;
mod sequence_element;
pub mod spectrum;
pub mod system;
mod tolerance;

pub use crate::complex_peptide::ComplexPeptide;
pub use crate::element::*;
pub use crate::formula::*;
pub use crate::isobaric_sets::{building_blocks, find_isobaric_sets};
pub use crate::linear_peptide::LinearPeptide;
pub use crate::model::Model;
pub use crate::modification::Modification;
pub use crate::molecular_charge::MolecularCharge;
pub use crate::multi::*;
pub use crate::multi_formula::*;
pub use crate::neutral_loss::*;
pub use crate::protease::*;
pub use crate::sequence_element::SequenceElement;
pub use crate::spectrum::{AnnotatedSpectrum, MassMode, RawSpectrum};
pub use crate::tolerance::*;
pub use aminoacids::AminoAcid;
pub use fragment::Fragment;

#[macro_use]
extern crate uom;

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
mod test {
    use super::*;

    #[test]
    fn simple_fragments() {
        let peptide = ComplexPeptide::pro_forma("WFWF")
            .unwrap()
            .singular()
            .unwrap();
        let fragments = peptide
            .generate_theoretical_fragments(system::Charge::new::<system::e>(1.0), &Model::all());
        println!("{}", fragments.len());
        println!("{fragments:?}");
    }

    #[test]
    fn simple_matching() {
        let model = Model::all();
        let spectrum = rawfile::mgf::open("data/example.mgf").unwrap();
        let peptide = ComplexPeptide::pro_forma("WFWF").unwrap();
        let fragments =
            peptide.generate_theoretical_fragments(system::Charge::new::<system::e>(1.0), &model);
        let annotated = spectrum[0].annotate(peptide, &fragments, &model, MassMode::Monoisotopic);
        println!("{annotated:?}");
    }
}