Structure Calculations — mdpath.src.structure

This module contains the class StructureCalculations which handels all structure related calculations based on the initial PDB file and the class DihedralAngles which calculates the dihedral angle movements over the course of the given trajectory.

Classes

StructureCalculations DihedralAngles

class mdpath.src.structure.DihedralAngles(traj: Universe, first_res_num: int, last_res_num: int, num_residues: int)[source]

Bases: object

Calculate dihedral angle movements for residues in a molecular dynamics (MD) trajectory.

Attributes:

traj (mda.Universe): MDAnalysis Universe object containing the trajectory.

first_res_num (int): The first residue number in the trajectory.

last_res_num (int): The last residue number in the trajectory.

num_residues (int): The total number of residues in the trajectory.

calc_dihedral_angle_movement(res_id: int) tuple[source]

Calculates dihedral angle movement for a residue over the course of the MD trajectory.

Args:

res_id (int): Residue number.

Returns:

tuple[int, np.ndarray] | None: Tuple of (residue_id, dihedral_angles) if successful, None if failed.

calculate_dihedral_movement_parallel(num_parallel_processes: int) DataFrame[source]

Parallel calculation of dihedral angle movement for all residues in the trajectory.

Args:

num_parallel_processes (int): Amount of parallel processes.

Returns:

pd.DataFrame: DataFrame with all residue dihedral angle movements.

class mdpath.src.structure.StructureCalculations(pdb: str)[source]

Bases: object

Calculate residue surroundings and distances between residues in a PDB structure.

Attributes:

pdb (str): Path to the PDB file.

first_res_num (int): First residue number in the PDB file.

last_res_num (int): Last residue number in the PDB file.

num_residues (int): Total number of residues in the PDB file.

calculate_close_and_far(dist: float)[source]

Calculates both close and far residue pairs in a single KDTree pass.

Args:

dist (float): Distance cutoff for residue pairs.

Returns:

df_close (pd.DataFrame): Close residue pairs. df_far (pd.DataFrame): Far residue pairs.

calculate_distance(atom1: tuple, atom2: tuple) float[source]

Calculates the distance between two atoms.

Args:

atom1 (tuple): Coordinates of the first atom.

atom2 (tuple): Coordinates of the second atom.

Returns:

distance (float): Normalized distance between the two atoms.

calculate_residue_suroundings(dist: float, mode: str) DataFrame[source]

Calculates residues that are either close to or far away from each other in a PDB structure.

Args:

dist (float): Distance cutoff for residue pairs.

mode (str): ‘close’ to calculate close residues, ‘far’ to calculate faraway residues.

Returns:

pd.DataFrame: Pandas dataframe with residue pairs and their distance.

res_num_from_pdb() tuple[source]

Gets first and last residue number from a PDB file.

Returns:

first_res_num (int): First residue number.

last_res_num (int): Last residue number.