rustyms/
lib.rs

1#![doc = include_str!("../README.md")]
2#![expect(macro_use_extern_crate)] // Could not get uom to work without
3use bincode as _;
4
5#[cfg(feature = "align")]
6/// Only available with feature `align`.
7pub mod align;
8
9#[cfg(feature = "identification")]
10/// Only available with feature `identification`.
11pub mod identification;
12
13#[cfg(feature = "imgt")]
14/// Only available with feature `imgt`.
15pub mod imgt;
16
17#[cfg(test)]
18mod fragmentation_tests;
19#[macro_use]
20mod helper_functions;
21
22/// Contains all things related to annotations (MS2 spectrum annotations that is).
23pub mod annotation;
24/// Contains all things related to the underlying chemistry.
25pub mod chemistry;
26/// Contains all things related to fragments and fragmentation.
27pub mod fragment;
28pub mod glycan;
29mod isobaric_sets;
30pub mod ontology;
31mod parse_json;
32/// Contains all things related to tolerances and structures to handle multiple mass/formula options.
33pub mod quantities;
34#[cfg(feature = "rand")]
35/// Only available with features `rand`.
36mod rand;
37/// Contains all things related to sequences, amongst others amino acids and peptidoforms.
38pub mod sequence;
39pub mod spectrum;
40pub mod system;
41
42/// A subset of the types and traits that are envisioned to be used the most, importing this is a good starting point for working with the crate
43pub mod prelude {
44    pub use crate::annotation::{
45        AnnotatableSpectrum,
46        model::{FragmentationModel, MatchingParameters},
47    };
48    pub use crate::chemistry::{
49        Chemical, Element, MassMode, MolecularCharge, MolecularFormula, MultiChemical,
50    };
51    pub use crate::fragment::Fragment;
52    pub use crate::isobaric_sets::{
53        BuildingBlocks, TerminalBuildingBlocks, building_blocks, find_isobaric_sets,
54    };
55    pub use crate::sequence::{
56        AminoAcid, CheckedAminoAcid, CompoundPeptidoformIon, HasCompoundPeptidoformIon,
57        HasPeptidoformImpl, HasPeptidoformIon, IsAminoAcid, Peptidoform, PeptidoformIon, Protease,
58        SequenceElement, SequencePosition,
59    };
60    pub use crate::spectrum::RawSpectrum;
61}
62
63#[macro_use]
64extern crate uom;
65
66#[cfg(test)]
67#[expect(clippy::missing_panics_doc)]
68mod test {
69    use crate::prelude::*;
70
71    use super::*;
72
73    #[test]
74    fn simple_fragments() {
75        let peptide = Peptidoform::pro_forma("WFWF", None)
76            .unwrap()
77            .into_linear()
78            .unwrap();
79        let fragments = peptide.generate_theoretical_fragments(
80            system::isize::Charge::new::<system::e>(1),
81            FragmentationModel::all(),
82        );
83        println!("{}", fragments.len());
84        println!("{fragments:?}");
85    }
86
87    #[test]
88    fn simple_matching() {
89        let model = FragmentationModel::all();
90        let parameters = MatchingParameters::default();
91        let spectrum = spectrum::mgf::open("data/example.mgf").unwrap();
92        let peptide = CompoundPeptidoformIon::pro_forma("WFWF", None).unwrap();
93        let fragments = peptide
94            .generate_theoretical_fragments(system::isize::Charge::new::<system::e>(1), model);
95        let annotated =
96            spectrum[0].annotate(peptide, &fragments, &parameters, MassMode::Monoisotopic);
97        println!("{annotated:?}");
98    }
99}