pharmacophore#

Submodules#

pharmacophore.constants#

Hold constant values

pharmacophore.constants.color_convert(color: str = None)[source]#

helper funciton to convert color to rgb. :param color: str

Color to convert to rgb. Can be hex or color name.

Returns:

pharmacophore.draw#

Script to draw pharmacophore

class pharmacophore.draw.Draw(mol: Mol | None = None, features: str | dict | None = 'default')[source]#

Bases: object

atom_number(mol: Mol = None, label: str = 'atomNote', size: tuple = (300, 300))[source]#

Draw query molecule with labeled RDKit atom indices. :param mol: Chem.Mol

A molecule in ROMol format.

Parameters:
  • label – str Determines which style to label the molecule. Defaults to atomNote. In total, can use ‘atomNote’, ‘atomLabel’, and ‘molAtomMapNumber’.

  • size – tuple Determine the size of the molecule to draw.

Returns:

draw_pharm(mol: Mol, features: str | dict | None = None, color: dict = None, savepath: str = None)[source]#

Draw a 2D pharmacophore image :param mol: Chem.Mol

A molecule in ROMol format.

Parameters:
  • features – str Determines which feature algorithm to use. Can use ‘default’ or ‘rdkit’.

  • color – dict Options to modify color of features. Must contain the name of the features. Colors can be given as either distinct name or hex codes.

  • savepath – str Set the savepath to save the image.

Returns:

similarity_maps(refmol: Mol = None, querymol: Mol = None, radius: int = 2, nbits: int = 2048, fpType: str = 'bv', cmap: str | list | None = None, savepath: str = None)[source]#

Generate similarity map between query molecule and reference molecule. Only Morgan fingerprints are used. Image must be in png format. :param refmol: Chem.Mol

Reference molecule. Must be in ROMol format.

Parameters:
  • querymol – Chem.Mol Query molecule. Must be in ROMol format.

  • radius – int Set the radius for the MorganFingerprint. Default to 2.

  • nbits – int Set the number of bits for the generated fingerprint. Default to 2048.

  • fpType – str Set the fingerprint type. Default to ‘bv’. Can only use ‘bv’ or ‘count’

  • cmap – Optional[Union[str, list]] Set the colormap of figure. Uses matplotlib color scheme: https://matplotlib.org/stable/users/explain/colors/colormaps.html

  • savepath – str Set image savepath.

Returns:

class pharmacophore.draw.View(mol: Mol | list[Mol] | None = None, pharmacophore: str | dict | None = 'default')[source]#

Bases: object

view(mol: list[Mol] | Mol, pharmacophore: list = None, color: dict = None, labels: bool = True, window: tuple = (500, 500))[source]#

Generate an interactive py3Dmol image of the molecule and its pharmacophores. Method only works when used in Jupyter notebooks. Must include a list of molecules and a list of pharmacophores generated using Pharmacophore.calc_pharm(). :param mol: Union[list[Chem.Mol], Chem.Mol]

A molecule in ROMol format. Can be a single molecule or a list of molecules.

Parameters:
  • pharmacophore – list A list containing a list of pharmacophore data generated from Pharmacophore.calc_pharm().

  • color – dict A dictionary containing the following: {pharmacophore:color}. The color name can be in hex code or color name. If None given, will use default colors.

  • labels – bool Whether to generate labels overlay on the pharmacophore spheres.

  • window – tuple Set the window size of the py3dmol figure.

Returns:

pharmacophore.pharmacophore#

class pharmacophore.pharmacophore.Pharmacophore(features: str | dict = 'default')[source]#

Bases: object

add_feats(mol: Mol = None, substruct: str = None, type: str = None)[source]#

Optional method to add specific features if not present using default or RDKit rules. :param mol: Chem.Mol

Main molecule in ROMol format.

Parameters:
  • substruct – str A SMARTS string for specific substructure to match

  • type – str Set the type of interaction for substructure. Only ‘Donor’, ‘Acceptor’, ‘Aromatic’, and ‘Hydrophobe’ is allowed!

Returns:

calc_pharm(mol: Mol = None, features: str | dict | None = None)[source]#

Generate a list of pharmacophore features and position from a molecule. :param mol: Chem.Mol

A molecule in ROMol format.

Parameters:

features – str Designate the type of pharmacophore features to calculate from. Will default to “default” settings. This param can also accept “rdkit” to use RDKit default features or give a dictionary containing feature:list pair, where the list contains SMARTS string for a given feature.

Returns:

list A list of pharmacophore features, matching atom index, and position from a molecule.

feature_types(features: str | dict | None = None)[source]#

Output feature types that will be displayed in the pharmacophore model. This will default to ‘default’ settings. However, default RDKit features can also be used or a dictionary containing a dictionary of features with SMARTS string can be used. :param features: Optional[Union[str, dict]]

The feature type to be used in the pharmacophore model. This will default to “default” settings. Using “rdkit” will set the model to default RDKit features. Custom features can be used by giving a dictionary with feature:list pair, where the list contains SMARTS string for a given feature.

Returns:

output_features(feature_list: list | None = None, savepath: str = None, type: str = 'sphere', sphere_size: float = 0.7, transparency: float = 0.2, color: dict = None)[source]#

Output features as a .pml format for visualization in PyMol. :param feature_list: Optional[list]

A list containing features, corresponding atom number, and 3D position. Preferably genreated using the calc_pharm method.

Parameters:
  • savepath – str = None Must be a file in .pml format.

  • type – str = “Sphere” Set the pharmacophore representation. Can be “sphere” or “surface”. If surface is used, transparency can be set for each pharmacophore.

  • sphere_size – float = 0.5 Set size of spheres.

  • transparency – float = 0.2 Set teh transparency of pharmacophore. Only works when the pharmacophore type is set to “surface”.

  • color – dict Set color for the pharmacophores. Must be given as Acceptor: color where color is a tuple for RGB or a string for a specific color to be translated into RGB format.

Returns:

read_sdf(sdf_file: str = None, verbose: bool = False)[source]#

Read sdf files. :param sdf_file: Str

File path to .sdf file.

Parameters:

verbose – Bool Output description when reading .sdf file.

Returns:

list A list of molecules in Chem.Mol format.

to_df(mols: list = None, mol_name: list = None, features: str | dict | None = None)[source]#

From a list of containing Chem.MOl and a list containing molecule names, create a dataframe displaying matching features the molecules. Method will default to “default” settings. Users can use “rdkit” to set the model to default RDKit features, or give a dictionary with feature:list pair, where the list contains SMARTS string for a given feature. :param mols: list

A list containing molecules in Chem.Mol format.

Parameters:
  • mol_name – list A list containing names of molecules.

  • features – Union[str, dict] The feature type to be used in the pharmacophore model. This will default to “default” settings. Using “rdkit” will set the model to default RDKit features. Custom features can be used by giving a dictionary with feature:list pair, where the list contains SMARTS string for a given feature.

Returns:

pharmacophore.pharmacophore.find_matches(mol: Mol = None, patterns: list[Mol] = None, verbose=True)[source]#

Support function to visualize matches between query molecule and features. :param mol: Chem.Mol

Query molecule. Must be in ROMol format.

Parameters:
  • patterns – list[Chem.Mol] A list of molecules to match against the query molecule.

  • verbose – Bool Output messages for matches.

Returns:

pharmacophore.pharmacophore.fix_bond_order(mol: Mol, template_smi: str, savepath: str = None)[source]#

Fix bond order for a given molecule. A template smiles string must be given. :param mol: Chem.Mol

Molecule to fix. Must be in ROMol format.

Parameters:
  • template_smi – str A smiles string for molecule to fix. Recommend canonical smiles string if possible.

  • savepath – str Set the save path for the molecule. Output will be in sdf format.

Returns:

pharmacophore.sar#

class pharmacophore.sar.SAR(data: DataFrame, smi_col: str = 'smiles', act_col: str = 'activity', units: str = 'nM')[source]#

Bases: object

calc_LiPE(smi_col: list | None = None, act_col: list | None = None)[source]#

Calculate the Lipophilic Efficiency (LiPE) for a query molecule. The LiPE is calculated as LipE = pIC50 - LogP :param smi_col: Optional[list]

Designate the smiles cols.

Parameters:

act_col – Optional[list] Designate the activities cols.

Returns:

get_sali(smi_col: list | None = None, bits: int = 1024, radius: int = 2, type: str = 'morgan')[source]#

Calculate the Structure-Activity Landscape Index (SALI) between a pair of molecules. :param smi_col: Optional[list]

Designate the smiles cols.

Returns:

highlight_cliffs(smi_list: list | None = None, ncols: int = 2, subsize: tuple = (400, 400), legend: list = None, highlight_color: str = None, radius: int = 0.3, SVG: bool = False, savepath: str = None)[source]#

Draw and highlight differing structures in 2D. For each molecule, the Maximum Common Substructure (MCS) is identified. Only differing functional groups will be highlighted. Information is pulled from the pd.DataFrame given when initializing class SAR(). :param smi_col: str

Column name containing SMILES strings.

Parameters:
  • ncols – int Set the number of columns for drawn molecules.

  • subsize – tuple Set the drawing size for each molecule.

  • legend – list Set the legend for each moleucle in the grid.

  • highlight_color – str Set the color style of the highlights. Names must be found in Matplotlib.

  • radius – int Set the highlight radius.

  • SVG – bool Whether to output image in SVG format. Defaults to False, giving a .png image.

  • savepath – str Set the savepath for the image.

Returns:

output_cliffs(mols: Mol = None, savepath: str = None)[source]#

Output the activity cliffs for molecule as .pml file for rendering in PyMOL. :param mols: Chem.Mol

Input the RDKit molecule object to generate the activity cliffs.

Parameters:

savepath – str Savepath for the .pml file.

Returns:

view_cliffs(mols: Mol | list[Mol] = None, protein_path: str = None, window: tuple = (500, 500))[source]#

View the activity cliffs of molecules in py3Dmol. Only atoms not found using Maximum Common Substructure (MCS) will be highlighted. :param mols: Union[Chem.Mol, list[Chem.Mol]]

RDKit molecule object for rendering. Should be the same as the smiles given as the pd.DataFrame input when initializing SAR.

Parameters:
  • protein_path – str Filepath to the target protein structure.

  • window – tuple Set the windows size of the visualization window.

Returns: