Helper functions#

Helper functions — prolif.utils#

prolif.utils.get_residues_near_ligand(lig, prot, cutoff=6.0)[source]#

Detects residues close to a reference ligand

Parameters:
Returns:

residues – A list of unique ResidueId that are close to the ligand

Return type:

list

prolif.utils.to_bitvectors(df)[source]#

Converts an interaction DataFrame to a list of RDKit ExplicitBitVector

Parameters:

df (pandas.DataFrame) – A DataFrame where each column corresponds to an interaction between two residues

Returns:

bv – A list of ExplicitBitVect for each frame

Return type:

list

Example

>>> from rdkit.DataStructs import TanimotoSimilarity
>>> bv = prolif.to_bitvectors(df)
>>> TanimotoSimilarity(bv[0], bv[1])
0.42
prolif.utils.to_dataframe(ifp, interactions, count=False, dtype=None, drop_empty=True, index_col='Frame')[source]#

Converts IFPs to a pandas DataFrame

Parameters:
  • ifp (dict) – A dict in the format {<frame number>: {(<residue_id>, <residue_id>): <interactions>}}. <interactions> is either a numpy.ndarray bitvector, or a tuple of dict in the format {<interaction name>: <metadata dict>}.

  • interactions (list) – A list of interactions, in the same order as used to detect the interactions.

  • count (bool) – Whether to output a count fingerprint or not.

  • dtype (object or None) – Cast the dataframe values to this type. If None, uses np.uint8 if count=True, else bool.

  • drop_empty (bool) – Drop columns with only empty values

  • index_col (str) – Name of the index column in the DataFrame

Returns:

df – A 3-levels DataFrame where each ligand residue, protein residue, and interaction type are in separate columns

Return type:

pandas.DataFrame

Example

>>> df = prolif.to_dataframe(results, fp.interactions.keys(), dtype=int)
>>> print(df)
ligand             LIG1.G
protein             ILE59                  ILE55       TYR93
interaction   Hydrophobic HBAcceptor Hydrophobic Hydrophobic PiStacking
Frame
0                       0          1           0           0          0
...

Changed in version 0.3.2: Moved the return_atoms parameter from the run methods to the dataframe conversion code

Changed in version 2.0.0: Removed the return_atoms parameter. Added the count parameter. Removed support for ifp containing np.ndarray bitvectors.