Skip to content

Commit c6018f2

Browse files
committed
refactor(residue): use group_state_mut in tests
1 parent 82d6588 commit c6018f2

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

crates/polychem/src/polymers/residue.rs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -246,31 +246,17 @@ mod tests {
246246
snapshots.push(alanine.clone());
247247

248248
// Add an amidation named modification to the C-terminal
249-
// FIXME: Replace all of these with .group_state_mut()!
250-
assert!(alanine.functional_groups.contains_key(&C_TERMINAL));
251-
alanine.functional_groups.insert(
252-
C_TERMINAL,
253-
GroupState::Modified(NamedMod::new(&POLYMER_DB, "Am").unwrap()),
254-
);
249+
let amidation = GroupState::Modified(NamedMod::new(&POLYMER_DB, "Am").unwrap());
250+
*alanine.group_state_mut(&C_TERMINAL).unwrap() = amidation;
255251
snapshots.push(alanine.clone());
256252

257253
// Add an amidation named modification to the N-terminal (ignoring that that's impossible)
258-
assert!(alanine.functional_groups.contains_key(&N_TERMINAL));
259-
alanine.functional_groups.insert(
260-
N_TERMINAL,
261-
GroupState::Modified(NamedMod::new(&POLYMER_DB, "Am").unwrap()),
262-
);
254+
*alanine.group_state_mut(&N_TERMINAL).unwrap() = amidation;
263255
snapshots.push(alanine.clone());
264256

265257
// Out of functional groups, so adding more amidations changes nothing
266-
alanine.functional_groups.insert(
267-
N_TERMINAL,
268-
GroupState::Modified(NamedMod::new(&POLYMER_DB, "Am").unwrap()),
269-
);
270-
alanine.functional_groups.insert(
271-
C_TERMINAL,
272-
GroupState::Modified(NamedMod::new(&POLYMER_DB, "Am").unwrap()),
273-
);
258+
*alanine.group_state_mut(&N_TERMINAL).unwrap() = amidation;
259+
*alanine.group_state_mut(&C_TERMINAL).unwrap() = amidation;
274260
snapshots.push(alanine.clone());
275261

276262
// But they can be replaced with bonds
@@ -283,9 +269,7 @@ mod tests {
283269
},
284270
)
285271
.unwrap();
286-
alanine
287-
.functional_groups
288-
.insert(N_TERMINAL, GroupState::Donor(peptide_bond));
272+
*alanine.group_state_mut(&N_TERMINAL).unwrap() = GroupState::Donor(peptide_bond);
289273
snapshots.push(alanine.clone());
290274

291275
// Residues can be protonated

0 commit comments

Comments
 (0)