-
Notifications
You must be signed in to change notification settings - Fork 7
Description
The Frame and the Topology structs share methods to access and modify the topology of a system. These methods, defined as a trait, would allow writing functions that can accept both a Frame and a Topology. Having more than one trait would also allow sharing methods with TopologyRef.
From a quick look at the documentation, I would suggest two traits:
AccessTopologycould be defined forTopology,TopologyRef, andFrame. It could have the following methods:atomsize
MulateTopologycould be defined forTopologyandFrameand have:atom_mutresizeadd_atomremoveadd_bondadd_bond_with_orderremove_bondadd_residueclear_bonds
Counterintuitively, neither Topology nor TopologyRef have iter_atoms, which would work well in the AccessTopology trait. Since Frame does not have any method to access residues, bonds, angles, or dihedrals (bond, angle, and dihedral return the measure of the connection, not the connection itself), the AccessTopology trait could also be named AccessAtoms.
With these traits, it would be possible to write code like:
fn do_something_with_the_atoms(source: &impl AccessTopology) {
for atom in source.iter_atoms() {
// something
}
}
fn main() {
let frame: Frame = ...;
let topology: Topology = ...;
do_something_with_the_atoms(frame);
do_something_with_the_atoms(topology);
}If there is interest, I'd be happy to work on a pull request.