create_iter_body_gaps

Function create_iter_body_gaps 

Source
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 a HashMap<isize, Vec<(isize, &str, &pdbtbx::Atom)>> representing the bodies of the protein structure, as returned by the find_bodies function.

§Returns

A Vec<Gap> containing Gap instances that represent the distances between pairs of atoms from different bodies.

§Algorithm

  1. Initializes a random number generator with a fixed seed (42) for reproducibility.
  2. Iterates over all unique pairs of bodies.
  3. For each pair of bodies with at least 2 atoms each: a. Randomly selects 2 atoms from each body. b. Creates 2 Gap instances, one for each pair of selected atoms.
  4. Collects all created Gap instances 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 Gap instances contain information about the chain, atom names, residue numbers, and the distance between the selected atoms.
  • This function assumes that the input bodies HashMap 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.