Commit 76b6a1ab authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Changes

parent eeb43651
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,12 +117,12 @@ class ComplexFeaturizer(object):
    raise NotImplementedError('Featurizer is not defined.')


class MolecularFeaturizer(object):
class MolecularFeaturizer(Featurizer):
  """Abstract class for calculating a set of features for a
  molecule.

  The defining feature of a `MolecularFeaturizer` is that it
  uses SMILES strings and RDKIT molecule objecgs to represent
  uses SMILES strings and RDKIT molecule objects to represent
  small molecules. All other featurizers which are subclasses of
  this class should plan to process input which comes as smiles
  strings or RDKIT molecules. 
+12 −4
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
Basic molecular features.
"""

import numpy as np
from deepchem.feat.base_classes import MolecularFeaturizer


@@ -12,7 +13,6 @@ class MolecularWeight(MolecularFeaturizer):
  ----
  This class requires RDKit to be installed.
  """
  name = ['mw', 'molecular_weight']

  def _featurize(self, mol):
    """
@@ -22,6 +22,10 @@ class MolecularWeight(MolecularFeaturizer):
    ----------
    mol : RDKit Mol
        Molecule.

    Returns
    -------
    np.ndarray of length 1 containing the molecular weight.
    """
    try:
      from rdkit.Chem import Descriptors
@@ -29,7 +33,7 @@ class MolecularWeight(MolecularFeaturizer):
      raise ValueError("This class requires RDKit to be installed.")
    wt = Descriptors.ExactMolWt(mol)
    wt = [wt]
    return wt
    return np.asarray(wt)


class RDKitDescriptors(MolecularFeaturizer):
@@ -40,11 +44,15 @@ class RDKitDescriptors(MolecularFeaturizer):
  See http://rdkit.org/docs/GettingStartedInPython.html
  #list-of-available-descriptors.

  Attributes
  ----------
  descriptors: list
    List of RDKit descriptor names used in this class.

  Note
  ----
  This class requires RDKit to be installed.
  """
  name = 'descriptors'

  # (ytz): This is done to avoid future compatibility issues like inclusion of
  # the 3D descriptors or changing the feature size.
@@ -105,4 +113,4 @@ class RDKitDescriptors(MolecularFeaturizer):
    rval = []
    for desc_name, function in self.descList:
      rval.append(function(mol))
    return rval
    return np.asarray(rval)
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ class RawFeaturizer(MolecularFeaturizer):
  def __init__(self, smiles=False):
    """Initialize this featurizer.

    Parameter
    ---------
    Parameters
    ----------
    smiles: bool, optional (default False)
      If True, encode this molecule as a SMILES string. Else as a RDKit mol.
    """