luna.mol.depiction module¶
- class PharmacophoreDepiction(feature_extractor=None, colors=<luna.util.ColorPallete object>, format='png', fig_size=(800, 800), font_size=0.5, circle_dist=0.2, circle_radius=0.3, use_bw_atom_palette=True)[source]¶
Bases:
object
Draw molecules and depict pharmacophoric properties as colored circles.
- Parameters
feature_extractor (
FeatureExtractor
) – Perceive pharmacophoric properties from molecules.colors (
ColorPallete
) – Color scheme for pharmacophoric properties perceived byfeature_extractor
. The default value isATOM_TYPES_COLOR
.format ({‘png’, ‘svg’}) – The output file format. The default value is ‘png’.
figsize (tuple of (float, float)) – Width and height in inches. The default value is (800, 800).
font_size (float) – The font size. The units are, roughly, pixels. The default value is 0.5.
circle_dist (float) – Distance between circles (pharmacophoric properties). The default value is 0.2.
circle_radius – Circles’ radius size of pharmacophoric properties. The default value is 0.3.
use_bw_atom_palette (bool) – Use a black & white palette for atoms and bonds.
Examples
First, let’s read a molecule (glutamine).
>>> from luna.wrappers.base import MolWrapper >>> mol = MolWrapper.from_smiles("N[C@@H](CCC(N)=O)C(O)=O")
Now, create a feature factory and instantiate a new FeatureExtractor object.
>>> from luna.util.default_values import ATOM_PROP_FILE >>> from rdkit.Chem import ChemicalFeatures >>> from luna.mol.features import FeatureExtractor >>> feature_factory = ChemicalFeatures.BuildFeatureFactory(ATOM_PROP_FILE) >>> feature_extractor = FeatureExtractor(feature_factory)
Instantiate a new PharmacophoreDepiction object with the desired configuration. For example, you can provide a color scheme for pharmacophoric properties, the image size, and its format.
>>> from luna.util.default_values import ATOM_TYPES_COLOR >>> from luna.mol.depiction import PharmacophoreDepiction pd = PharmacophoreDepiction(feature_extractor=feature_extractor, colors=ATOM_TYPES_COLOR, fig_size=(500, 500), format="svg")
Finally, you can draw the molecule with annotated pharmacophoric properties.
>>> pd.plot_fig(mol, "output.svg")
- plot_fig(mol_obj, output=None, atm_types=None, legend=None)[source]¶
Draw the molecule
mol_obj
and depict its pharmacophoric properties.- Parameters
mol_obj (
MolWrapper
,rdkit.Chem.rdchem.Mol
, oropenbabel.pybel.Molecule
) – The molecule.output (str) – The output file where the molecule will be drawn. If None, returns a drawing object (
MolDraw2DCairo
orMolDraw2DSVG
).atm_types (dict or None) – A pre-annotated dictionary for mapping atoms and pharmacophoric properties. If None, try to perceive properties with
feature_extractor
.legend (str) – A title for the figure.
- Returns
drawer
- Return type
None or a drawing object (
MolDraw2DCairo
orMolDraw2DSVG
)