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) – Select residues that are near this ligand
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, index_col='Frame', dtype=None, drop_empty=True, return_atoms=False)[source]¶
Converts IFPs to a pandas DataFrame
- Parameters
ifp (list) – A list of dict in the format {key: bitvector}. “key” is a tuple of ligand and protein ResidueId. “bitvector” is either a numpy.ndarray of bits, or a list of bitarray, ligand atom indices, and protein atom indices. Each dictionnary must also contain an entry that will be used as an index, typically a frame number.
interactions (list) – A list of interactions, in the same order as the bitvector.
index_col (str) – The dictionnary key that will be used as an index in the DataFrame
dtype (object or None) – Cast the input of each bit in the bitvector to this type. If None, keep the data as is. Not compatible with
return_atoms=True
drop_empty (bool) – Drop columns with only empty values
return_atoms (bool) – For each residue pair and interaction, return indices of atoms responsible for the interaction instead of bits
- 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 code