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:
lig (prolif.molecule.Molecule or prolif.residue.Residue) – Select residues that are near this ligand/residue
prot (prolif.molecule.Molecule) – Protein containing the residues
cutoff (float) – If any interatomic distance between the ligand reference points and a residue is below or equal to this cutoff, the residue will be selected
- Returns:
residues – A list of unique
ResidueId
that are close to the ligand- Return type:
- 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:
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 anumpy.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
, usesnp.uint8
ifcount=True
, elsebool
.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:
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 therun
methods to the dataframe conversion codeChanged in version 2.0.0: Removed the
return_atoms
parameter. Added thecount
parameter. Removed support forifp
containingnp.ndarray
bitvectors.