Plotting#
Plot residues — prolif.plotting.residues
#
New in version 2.0.0.
- prolif.plotting.residues.display_residues(mol: Molecule, residues_slice: Optional[slice] = None, *, size: Tuple[int, int] = (200, 140), mols_per_row: int = 4, use_svg: bool = True) Any [source]#
Display a grid image of the residues in the molecule. The hydrogens are stripped and the 3D coordinates removed for a clearer visualisation.
- Parameters:
mol (prolif.Molecule) – The molecule to show residues from.
residues_slice (Optional[slice] = None) – Optionally, a slice of residues to display, e.g.
slice(20)
for the first 20 residues, orslice(<start>, <stop>, <step>)
for a more complex selection.size (Tuple[int, int] = (200, 140)) – Size of each residue image.
mols_per_row (int = 4) – Number of residues displayed per row.
use_svg (bool = True) – Generate an SVG or PNG image.
Plot interactions as a barcode — prolif.plotting.barcode
#
New in version 2.0.0.
- class prolif.plotting.barcode.Barcode(df: DataFrame)[source]#
Creates a barcode plot of interactions.
- Parameters:
df (pandas.DataFrame) – The DataFrame as obtained from
Fingerprint.to_dataframe()
- display(figsize: Tuple[int, int] = (8, 10), dpi: int = 100, interactive: bool = False, n_frame_ticks: int = 10, residues_tick_location: Literal['top', 'bottom'] = 'top', xlabel: str = 'Frame', subplots_kwargs: Optional[dict] = None, tight_layout_kwargs: Optional[dict] = None)[source]#
Generate and display the barcode plot.
- Parameters:
figsize (Tuple[int, int] = (8, 10)) – Size of the matplotlib figure.
dpi (int = 100) – DPI used for the matplotlib figure.
interactive (bool) – Add hover interactivity to the plot (only relevant for notebooks). You may need to add
%matplotlib notebook
or%matplotlib ipympl
for it to work as expected.n_frame_ticks (int = 10) – Number of ticks on the X axis. May use ±1 tick to have them evenly spaced.
residues_tick_location (Literal["top", "bottom"] = "top") – Whether the Y ticks appear at the top or at the bottom of the series of interactions of each residue.
xlabel (str = "Frame") – Label displayed for the X axis.
subplots_kwargs (Optional[dict] = None) – Other parameters passed to
matplotlib.pyplot.subplots()
.tight_layout_kwargs (Optional[dict] = None) – Other parameters passed to
matplotlib.figure.Figure.tight_layout()
.
- classmethod from_fingerprint(fp: Fingerprint) Barcode [source]#
Creates a barcode object from a fingerprint.
Plot interactions in 3D — prolif.plotting.complex3d
#
New in version 2.0.0.
- class prolif.plotting.complex3d.Complex3D(ifp: IFP, lig_mol: Molecule, prot_mol: Molecule)[source]#
Creates a py3Dmol plot of interactions.
- Parameters:
- LIGAND_STYLE#
Style object passed to
3Dmol.js
for the ligand.- Type:
Dict[str, Dict] = {“stick”: {“colorscheme”: “cyanCarbon”}}
- RESIDUES_STYLE#
Style object passed to
3Dmol.js
for the protein residues involved in interactions.- Type:
Dict[str, Dict] = {“stick”: {}}
- PROTEIN_STYLE#
Style object passed to
3Dmol.js
for the entire protein.- Type:
Dict[str, Dict] = {“cartoon”: {“style”: “edged”}}
- PEPTIDE_STYLE#
Style object passed to
3Dmol.js
for the ligand as a peptide if appropriate.- Type:
Dict[str, Dict] = “cartoon”: {“style”: “edged”, “colorscheme”: “cyanCarbon”}
- PEPTIDE_THRESHOLD#
Ligands with this number of residues or more will be displayed using
PEPTIDE_STYLE
in addition to theLIGAND_STYLE
.- Type:
int = 2
- LIGAND_DISPLAYED_ATOM#
Which atom should be used to display an atom-to-atom interaction for the ligand. Refers to the order defined in the SMARTS pattern used in interaction definition. Interactions not specified here use
0
by default.
- PROTEIN_DISPLAYED_ATOM#
Same as
LIGAND_DISPLAYED_ATOM
for the protein.
- LIGAND_RING_INTERACTIONS#
Which interactions should be displayed using the centroid instead of using
LIGAND_DISPLAYED_ATOM
for the ligand.- Type:
Set[str]
- PROTEIN_RING_INTERACTIONS#
Which interactions should be displayed using the centroid instead of using
PROTEIN_DISPLAYED_ATOM
for the protein.- Type:
Set[str]
- RESIDUE_HOVER_CALLBACK#
JavaScript callback executed when hovering a residue involved in an interaction.
- Type:
- INTERACTION_HOVER_CALLBACK#
JavaScript callback executed when hovering an interaction line.
- Type:
- compare(other: Complex3D, *, size: Tuple[int, int] = (900, 600), display_all: bool = False, linked: bool = True, color_unique: Optional[str] = 'magentaCarbon') view [source]#
Displays the initial complex side-by-side with a second one for easier comparison.
- Parameters:
other (Complex3D) – Other
Complex3D
object to compare to.size (Tuple[int, int] = (900, 600)) – The size of the py3Dmol widget view.
display_all (bool = False) – Display all occurences for a given pair of residues and interaction, or only the shortest one. Not relevant if
count=False
in theFingerprint
object.linked (bool = True) – Link mouse interactions (pan, zoom, translate) on both views.
color_unique (Optional[str] = "magentaCarbon",) – Which color to use for residues that have interactions that are found in one complex but not the other. Use
None
to disable the color override.versionadded: (..) – 2.0.1:
- display(size: Tuple[int, int] = (650, 600), display_all: bool = False) view [source]#
Display as a py3Dmol widget view.
- classmethod from_fingerprint(fp: Fingerprint, lig_mol: Molecule, prot_mol: Molecule, *, frame: int) Complex3D [source]#
Creates a py3Dmol plot of interactions.
- Parameters:
fp (prolif.fingerprint.Fingerprint) – The fingerprint object already executed using one of the
run
orrun_from_iterable
methods.frame (int) – The frame number chosen to select which interactions are going to be displayed.
lig_mol (Molecule) – The ligand molecule to display.
prot_mol (Molecule) – The protein molecule to display.
Plot a Ligand Interaction Network — prolif.plotting.network
#
New in version 0.3.2.
Changed in version 2.0.0: Replaced LigNetwork.from_ifp
with LigNetwork.from_fingerprint
which works
without requiring a dataframe with atom indices.
- class prolif.plotting.network.LigNetwork(df, lig_mol, use_coordinates=False, flatten_coordinates=True, kekulize=False, molsize=35, rotation=0, carbon=0.16)[source]#
Creates a ligand interaction diagram
- Parameters:
df (pandas.DataFrame) – Dataframe with a 4-level index (ligand, protein, interaction, atoms) and
weight
anddistance
columns for valueslig_mol (rdkit.Chem.rdChem.Mol) – Ligand molecule
use_coordinates (bool) – If
True
, uses the coordinates of the molecule directly, otherwise generates 2D coordinates from scratch. See alsoflatten_coordinates
.flatten_coordinates (bool) – If this is
True
anduse_coordinates=True
, generates 2D coordinates that are constrained to fit the 3D conformation of the ligand as best as possible.kekulize (bool) – Kekulize the ligand
molsize (int) – Multiply the coordinates by this number to create a bigger and more readable depiction
rotation (int) – Rotate the structure on the XY plane
carbon (float) – Size of the carbon atom dots on the depiction. Use 0 to hide the carbon dots
- COLORS#
Dictionnary of colors used in the diagram. Subdivided in several dictionaries:
“interactions”: mapping between interactions types and colors
“atoms”: mapping between atom symbol and colors
“residues”: mapping between residues types and colors
- Type:
- RESIDUE_TYPES#
Mapping between residue names (3 letter code) and types. The types are then used to define how each residue should be colored.
- Type:
Notes
You can customize the diagram by tweaking
LigNetwork.COLORS
andLigNetwork.RESIDUE_TYPES
by adding or modifying the dictionaries inplace.Changed in version 2.0.0: Replaced
LigNetwork.from_ifp
withLigNetwork.from_fingerprint
which works without requiring a dataframe with atom indices. Replacedmatch3D
parameter withuse_coordinates
andflatten_coordinates
to give users more control and allow them to provide their own 2D coordinates. Added support for displaying peptides as the “ligand”. Changed the default color for VanDerWaals.- classmethod from_fingerprint(fp, ligand_mol, kind='aggregate', frame=0, display_all=False, threshold=0.3, **kwargs)[source]#
Helper method to create a ligand interaction diagram from a
Fingerprint
object.Notes
Two kinds of diagrams can be rendered: either for a designated frame or by aggregating the results on the whole IFP and optionnally discarding interactions that occur less frequently than a threshold. In the latter case (aggregate), only the group of atoms most frequently involved in each interaction is used to draw the edge.
- Parameters:
fp (prolif.fingerprint.Fingerprint) – The fingerprint object already executed using one of the
run
orrun_from_iterable
methods.lig (rdkit.Chem.rdChem.Mol) – Ligand molecule
kind (str) – One of
"aggregate"
or"frame"
frame (int) – Frame number (see
ifp
). Only applicable forkind="frame"
display_all (bool) – Display all occurences for a given pair of residues and interaction, or only the shortest one. Only applicable for
kind="frame"
. Not relevant ifcount=False
in theFingerprint
object.threshold (float) – Frequency threshold, between 0 and 1. Only applicable for
kind="aggregate"
kwargs (object) – Other arguments passed to the
LigNetwork
class
Changed in version 2.0.0: Added the
display_all
parameter.