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
use crate::RegulatoryGraph;
impl PartialEq for RegulatoryGraph {
fn eq(&self, other: &Self) -> bool {
if self.variables != other.variables {
return false;
}
for self_reg in self.regulations() {
if let Some(other_reg) = other.find_regulation(self_reg.regulator, self_reg.target) {
if self_reg != other_reg {
return false;
}
} else {
return false;
}
}
for other_reg in other.regulations() {
if let Some(self_reg) = self.find_regulation(other_reg.regulator, other_reg.target) {
if self_reg != other_reg {
return false;
}
} else {
return false;
}
}
true
}
}
impl Eq for RegulatoryGraph {}
#[cfg(test)]
mod tests {
use crate::RegulatoryGraph;
#[test]
fn test_regulation_order_equivalence() {
let mut a = RegulatoryGraph::new(vec!["a".to_string(), "b".to_string()]);
let mut b = RegulatoryGraph::new(vec!["a".to_string(), "b".to_string()]);
a.add_string_regulation("a -> b").unwrap();
a.add_string_regulation("b -| a").unwrap();
b.add_string_regulation("b -| a").unwrap();
b.add_string_regulation("a -> b").unwrap();
assert_eq!(a, b);
}
}