mdigest.utils package

Submodules

mdigest.utils.imports module

mdigest.utils.pdbhandler module

mdigest.utils.pdbhandler.center_pdb(pdb_df, shift)
mdigest.utils.pdbhandler.df_to_pdb(input_dataframe, desired_outname, protonation=False, charge_arr=False, split_by_chain=False, split_by_segid=False)

Advanced df to PDB with customization of chainIDs segIDs, and charges

Parameters: input_dataframe: pd.DataFrame, desired_outname: str, protonation: bool, charge_arr: False or np.ndarray split_by_chain: bool, split_by_segid: bool

mdigest.utils.pdbhandler.fill_topology_df(topo_df_mdt, coord_array)

This function completes the topology data frame from MDtraj for later saving the topology to PDB format.

topo_df_mdt: topology from mdtraj.to_dataframe()[0]:

which only contains the following columns: [‘serial’, ‘name’, ‘element’, ‘resSeq’, ‘resName’, ‘chainID’,’segmentID’]

coord_array: array of coordinates from mdtraj.trajectory.xyz or average_structure.xyz

Return type:

return topo_df_mdt: topology dataframe completed of all fields

mdigest.utils.pdbhandler.mdatopology_to_dataframe(mda_u, frame, selection='all')
mdigest.utils.pdbhandler.read_pdb_file(filename)
mdigest.utils.pdbhandler.select_frame(mda_u, frame)

mdigest.utils.simulation module

class mdigest.utils.simulation.MDAUniverse

Bases: object

General class to handle and align the MDA Universe

align_traj(inmem=True, aligntoavg=False, strict=True, center=False)

Use MDAnalysis to align trajectory with respect to a reference

This function assumes that atoms in reference traj and mobile traj are in the same order. if not use align_mdtraj() which allows to select different atoms in mobile and reference.

Parameters:
  • inmem (bool,) –

  • aligntoavg (bool,) –

  • strict (bool,) –

  • center (bool,) –

compute_rmsd(superposition=False)
find_shift(box_size=None, offset=0)
Find how much to shift each coordinate to recenter the

trajectory in the centrer of the box

load_universe(topo, traj, topo_ref, traj_ref)
set_name(name)
set_selection(atm_selection, segIDs)
Parameters:
  • atm_selection (str) –

  • string (Atom selection using MDAnalysis selection) –

  • segIDs (Example) –

  • select (which segids to) –

  • selection (Example) –

  • segIDs

set_selection_ref(atm_selection, segIDs)

Example selection : ‘not resid 455’ Example segIDs : ‘*’

set_selection_rmsd(selection)
source_universe(universe, reference=None)
class mdigest.utils.simulation.MDTUniverse

Bases: object

adjust_topology()
align_md_traj()

Align MDTraj Trajectory

Parameters:
  • self.mdt_u (mobile mdtraj universe) –

  • self.mdt_ref_u (reference mdtraj universe) –

  • self.selection_string (selection string for alignment) –

:param : :type : return self.aligned

calc_rmsd_2frames(ref, frame)

RMSD calculation between a reference and a frame. This function is “jitted” for better performances

centroid()

Compute the centroid of a distance matrix

compute_angles()
compute_dihed()
compute_distances()
find_shift(box_size=None, offset=0)

Find how much to shift each coordinate to recenter the trajectory in the centrer of the box

load_universe(topo, traj, topo_ref, traj_ref)
set_distances_cache(dist_cache)
set_logfile(log)
set_mapping_chainid(mapping)
set_mapping_segid(mapping)
set_name(name)
set_selection(group_selection)
set_selection_alignment(atm_selection)
set_selection_alignment_ref(atm_selection)
set_use_frame(frame)
source_universe(traj, reference=None)
mdigest.utils.simulation.pkl_dump(todump, filename)

mdigest.utils.toolkit module

mdigest.utils.toolkit.print_screen_logfile(string, opened_logfile)

Print string on screen and write it on logfile

Parameters:
  • string (str,) – string to print and write

  • opened_logfile (file) – opened logfile

mdigest.utils.toolkit.reduce_mdt_trajectory(mdt_u, selection)

Reduce the trajectory according to the selection string

Parameters:
  • mdt_u (mdtraj.Trajectory,) –

  • selection (str,) –

Returns:

a reduced trajectory (mdtraj.Trajectory)

Return type:

reduced, mdtraj.Trajectory object

mdigest.utils.toolkit.reduce_trajectory(mda_u, selection, initial=0, final=-1, step=1)

Reduce the trajectory according to the selection string

Parameters:
  • mda_u (mda.Universe,) –

  • selection (str) –

  • initial (int,) –

  • final (int or -1,) –

  • step (int,) –

Returns:

a reduced trajectory (mdAnalysis.Universe.trajectory)

Return type:

returns reduced: mda.Universe object

mdigest.utils.toolkit.write_universe(mda_u, path, filename, chainid=False, initial=0, final=-1, step=1)

Write a trajectory and corresponding pdb to file

:param : :type : params trajectory: mdAnalysis.Universe.trajectory, :param : :type : params path: str, :param : :type : params filename: str, :param : if True, write chainid to pdb :type : params chainid: bool, :param : :type : params ititial: int, :param : :type : params final: int or -1 :param : :type : params step: int

Returns:

reduced – a reduced trajectory (mdAnalysis.Universe.trajectory)

Return type:

mda.Universe object,

Module contents