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
//! Valid trait implementation for mass spectral models.
use traits::Valid;
use super::record::Record;
use super::record_list::RecordList;
impl Valid for Record {
fn is_valid(&self) -> bool {
(
self.num != 0 &&
self.rt >= 0.0 &&
!self.peaks.is_empty() &&
// If the MS level is 2 or higher, check the parents are set.
(
(
self.ms_level >= 2 &&
self.parent_mz != 0.0 &&
self.parent_intensity > 0.0 &&
self.parent_z != 0
)
||
(
self.ms_level == 1 &&
self.parent_mz == 0.0 &&
self.parent_intensity == 0.0 &&
self.parent_z == 0
)
||
self.ms_level == 0
)
)
}
}
impl Valid for RecordList {
#[inline]
fn is_valid(&self) -> bool {
self.iter().all(|ref x| x.is_valid())
}
}