Correct hanlding of reactions

while converting from System to PositiveSystem
This commit is contained in:
elvis
2025-09-08 19:04:26 +02:00
parent 49051358f0
commit 2571148e74
6 changed files with 232 additions and 53 deletions

View File

@ -236,4 +236,27 @@ impl PositiveReaction {
products: products.to_positive_set(IdState::Positive),
}
}
/// returns the reactants that are equal
pub fn differ_only_one_element(&self, other: &Self) -> Option<PositiveSet> {
if self.products != other.products {
return None
}
let mut found = false;
for el in self.reactants.iter() {
match other.reactants.identifiers.get(el.0) {
None => return None,
Some(s) => {
if s != el.1 {
if found {
return None
} else {
found = true
}
}
}
}
}
Some(self.reactants.intersection(&other.reactants))
}
}