Utilities

Contents

Utilities#

The export submodule saves ACVs in different formats. The jupyter submodule provides functions to interact with NGLView inside the Jupyter environment (notebook or lab) and establishes an xmlrpc connection to control a PyMOL session from a Jupyter notebook.

Export#

fretraj.export.open_dx(grid_3d, xyz_min, d_xyz)[source]#

Return an OpenDX formatted string

Parameters:
  • density (ndarray) – 3-dimensional array of grid points with a shape given by n_xyz

  • xyz_min (list) – origin coordinates of the grid

  • d_xyz (list) – grid spacing in x-,y- and z-direction

Returns:

str – OpenDX formatted string

fretraj.export.pdb(cloud_xyzqt, mp)[source]#

Returns a PDB formatted string

Parameters:
  • cloud_xyzq (ndarray) – array of x-,y-,z-coordinates and corresponding weights with a shape [n_gridpts(+), 4]

  • tag (ndarray) – one-dimensional array of length n_gridpts

Returns:

str – PDB formatted string

Notes

the PDB properties are as follows:

entry

PyMOL

pos.

ATOM / HETATM

[1-6]

atom serial number

(id)

[7-11]

atom name

(name)

[12-16]

alternate loc. indicator

(alt)

[17]

residue name

(resn)

[18-20]

[21]

chain identifier

(chain)

[22]

residue seq. number

(resi)

[23-26]

residue insertion code

[27]

[28-30]

x coordinate (in A)

[31-38]

y coordinate (in A)

[39-46]

z coordinate (in A)

[47-54]

occupancy

[55-60]

temperature factor

[61-66]

[67-66]

element

(element)

[77-78]

charge

(fc)

[79-80]

fretraj.export.xyz(cloud_xyzqt, mp, write_weights=True, encode_element=False)[source]#

Return an XYZ formatted string

Parameters:
  • cloud_xyzq (ndarray) – array of x-,y-,z-coordinates and corresponding weights with a shape [n_gridpts(+), 4]

  • mp (ndarray) – mean position

  • write_weights (bool, optional=True) – include weights in XYZ file (5th column)

  • encode_element (bool, optional=False)

Returns:

str – XYZ formatted string

Jupyter#

fretraj.jupyter._change_model(model)[source]#

Change the current model

Parameters:

model (int)

fretraj.jupyter._on_slider_value_change(change)[source]#

Updates the view upon changing the slider value

Parameters:

change (dict)

Notes

See also: https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html

fretraj.jupyter.connect2pymol()[source]#

Establish an RPC connection to run PyMOL commands from the command line or from a Jupyter notebook

Notes

Start a PyMOL server session from a terminal: >>> pymol -R

On Windows you may create a shortcut that executes the command C:path oPyMOLWin.exe -R

fretraj.jupyter.model_slider(n_models)[source]#

A slider widget for multi-model structures

Parameters:

n_models (int) – number of models in the structure

Returns:

int_slider (ipywidgets.IntSlider)

Notes

See also: https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html

fretraj.jupyter.nglview_multimodel_ACV(biomol_filename, volume1_filename, volume2_filename)[source]#

Create a nglview multi-model structure scene with donor and acceptor accessible-contact volumes (ACV)

Parameters:
  • structure_filename (str) – multi-model PDB of the biomolecule

  • volume1_filename, volume2_filename (str) – multi-model PDB of the donor and acceptor accessible-contact volume

Returns:

  • view (nglview.NGLWidget)

  • n_model (int)

fretraj.jupyter.nglview_trajectory(traj_biomol)[source]#

Create a nglview trajectory scene

Parameters:

traj_biomol (mdtraj.Trajectory) – trajectory of the biomolecule

Returns:

view (nglview.NGLWidget)

fretraj.jupyter.nglview_trajectory_ACV(traj_biomol, traj_volume1_FV, traj_volume2_FV, traj_volume1_CV, traj_volume2_CV)[source]#

Create a nglview trajectory scene with donor and acceptor accessible-contact volumes (ACV)

Parameters:
  • traj_biomol (mdtraj.Trajectory) – trajectory of the biomolecule

  • traj_volume1_FV, traj_volume2_FV (mdtraj.Trajectory) – trajectory of the donor and acceptor free volume

  • traj_volume1_CV, traj_volume2_CV (mdtraj.Trajectory) – trajectory of the donor and acceptor contact volume

Returns:

view (nglview.NGLWidget)

fretraj.jupyter.nglview_trajectory_AV(traj_biomol, traj_volume1, traj_volume2, surface_representation=False)[source]#

Create a nglview trajectory scene with donor and acceptor accessible volumes (AV)

Parameters:
  • traj_biomol (mdtraj.Trajectory) – trajectory of the biomolecule

  • traj_volume1, traj_volume2 (mdtraj.Trajectory) – trajectory of the donor and acceptor accessible volume

  • surface_representation (bool (default: False)) – show a surface representation (instead of spacefill, which is faster)

Returns:

view (nglview.NGLWidget)

fretraj.jupyter.render_view(view, gui=False)[source]#

Display an nglview scene with or without a GUI

Parameters:
  • view (nglview.NGLWidget)

  • gui (bool) – display the scene within a GUI window (useful for interacting with components and representations)