pub fn create_iter_body_gaps(
bodies: &HashMap<isize, Vec<(isize, &str, &Atom)>>,
) -> Vec<Gap>Expand description
Creates a list of gaps between different bodies in a protein structure.
This function analyzes the spatial relationships between separate bodies of a protein
structure and generates a list of Gap instances representing the distances between
randomly selected pairs of atoms from different bodies.
§Arguments
bodies- A reference to aHashMap<isize, Vec<(isize, &str, &pdbtbx::Atom)>>representing the bodies of the protein structure, as returned by thefind_bodiesfunction.
§Returns
A Vec<Gap> containing Gap instances that represent the distances between pairs of
atoms from different bodies.
§Algorithm
- Initializes a random number generator with a fixed seed (42) for reproducibility.
- Iterates over all unique pairs of bodies.
- For each pair of bodies with at least 2 atoms each:
a. Randomly selects 2 atoms from each body.
b. Creates 2
Gapinstances, one for each pair of selected atoms. - Collects all created
Gapinstances into a vector.
§Notes
- The function uses a fixed random seed (42) for reproducibility. This means that for the same input, it will always produce the same output.
- Only bodies with at least 2 atoms are considered for gap creation.
- The function creates 2 gaps for each pair of bodies, using different randomly selected atoms.
- The
Gapinstances contain information about the chain, atom names, residue numbers, and the distance between the selected atoms. - This function assumes that the input
bodiesHashMap is structured as expected, with each value being a vector of tuples (residue number, chain ID, atom reference).
§Safety
This function uses unwrap() on the results of choose_multiple(). It assumes that
the bodies contain at least 2 atoms each, as checked earlier in the function.