Plotting#
Plot residues — prolif.plotting.residues
#
New in version 2.0.0.
- prolif.plotting.residues.display_residues(mol: Molecule, residues_slice: slice | None = None, *, size: tuple[int, int] = (200, 140), mols_per_row: int = 4, use_svg: bool = True, sanitize: 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 (slice | None = 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.
sanitize (bool = True) – Sanitize the residues before displaying.
versionchanged: (..) – 2.1.0: Added
sanitize
parameter that defaults to False for easier debugging.
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: dict | None = None, tight_layout_kwargs: dict | None = None) Axes [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 (dict | None = None) – Other parameters passed to
matplotlib.pyplot.subplots()
.tight_layout_kwargs (dict | None = 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, water_mol: Molecule | None = None)[source]#
Creates a py3Dmol plot of interactions.
- Parameters:
- LIGAND_STYLE#
Style object passed to
3Dmol.js
for the ligand.
- RESIDUES_STYLE#
Style object passed to
3Dmol.js
for the protein residues involved in interactions.
- PROTEIN_STYLE#
Style object passed to
3Dmol.js
for the entire protein.
- PEPTIDE_STYLE#
Style object passed to
3Dmol.js
for the ligand as a peptide if appropriate.
- 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.
- PROTEIN_RING_INTERACTIONS#
Which interactions should be displayed using the centroid instead of using
PROTEIN_DISPLAYED_ATOM
for the protein.
- BRIDGED_INTERACTIONS#
For bridged-interactions such as WaterBridge. The key is the interaction name, and the value is the name of the molecule in the metadata indices dictionary.
- 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:
- .. versionchanged:: 2.1.0
Added
water_mol
parameter to the constructor to display waters involved in WaterBridge interactions. Addedsave_png
method to save the current state of the 3D viewer to a PNG. Addedremove_hydrogens
parameter to thedisplay
andcompare
methods to remove non-polar hydrogens that aren’t involved in an interaction. Addedonly_interacting
parameter to thedisplay
andcompare
methods to show all protein residues in the vicinity of the ligand, or only the ones participating in an interaction.
- compare(other: Complex3D, *, size: tuple[int, int] = (900, 600), display_all: bool = False, linked: bool = True, color_unique: str | None = 'magentaCarbon', only_interacting: bool = True, remove_hydrogens: Union[bool, Literal['ligand', 'protein', 'water']] = True) Complex3D [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 (str | None = "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.only_interacting (bool = True) – Whether to show all protein residues in the vicinity of the ligand, or only the ones participating in an interaction.
remove_hydrogens (bool | Literal["ligand", "protein", "water"] = True) – Whether to remove non-polar hydrogens (unless they are involved in an interaction).
versionadded: (..) – 2.0.1:
versionchanged: (..) – 2.1.0: Added
only_interacting=True
andremove_hydrogens=True
parameters. Non-polar hydrogen atoms that aren’t involved in interactions are now hidden. Added support for waters involved in WaterBridge interactions.
- display(size: tuple[int, int] = (650, 600), display_all: bool = False, only_interacting: bool = True, remove_hydrogens: Union[bool, Literal['ligand', 'protein', 'water']] = True) Complex3D [source]#
Display as a py3Dmol widget view.
- Parameters:
size (tuple[int, int] = (650, 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.only_interacting (bool = True) – Whether to show all protein residues in the vicinity of the ligand, or only the ones participating in an interaction.
remove_hydrogens (bool | Literal["ligand", "protein", "water"] = True) – Whether to remove non-polar hydrogens (unless they are involved in an interaction).
versionchanged: (..) – 2.1.0: Added
only_interacting=True
andremove_hydrogens=True
parameters. Non-polar hydrogen atoms that aren’t involved in interactions are now hidden. Added support for waters involved in WaterBridge interactions.
- classmethod from_fingerprint(fp: Fingerprint, lig_mol: Molecule, prot_mol: Molecule, water_mol: Molecule | None = None, *, 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.
water_mol (Optional[Molecule]) – Additional molecule (e.g. waters) to display.