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
#![allow(dead_code)]
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
#![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(test)]
mod fragmentation_tests;
#[macro_use]
mod formula;

pub mod align;
mod aminoacids;
mod element;
mod fragment;
mod glycan;
mod helper_functions;
mod isotopes;
mod model;
mod modification;
mod ontologies;
mod peptide;
mod placement_rules;
pub mod rawfile;
mod spectrum;
mod system;

pub use crate::element::*;
pub use crate::formula::*;
pub use crate::fragment::*;
pub use crate::glycan::*;
pub use crate::model::*;
pub use crate::peptide::*;
pub use crate::spectrum::*;
pub use crate::system::f64::*;
pub use aminoacids::AminoAcid;
pub use fragment::Fragment;
pub use model::Model;
pub use peptide::Peptide;
pub use uom::num_traits::Zero;

#[macro_use]
extern crate uom;

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

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

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