Commit 40b2ff42 authored by nd-02110114's avatar nd-02110114
Browse files

Merge branch 'master' into refactor-complex-feat

parents 38311a7d bc2be073
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ from deepchem.feat.binding_pocket_features import BindingPocketFeaturizer

# molecule featurizers
from deepchem.feat.molecule_featurizers import AtomicCoordinates
from deepchem.feat.molecule_featurizers import BPSymmetryFunctionInput
from deepchem.feat.molecule_featurizers import CircularFingerprint
from deepchem.feat.molecule_featurizers import CoulombMatrix
from deepchem.feat.molecule_featurizers import CoulombMatrixEig
+6 −8
Original line number Diff line number Diff line
@@ -50,8 +50,13 @@ class ElementPropertyFingerprint(MaterialCompositionFeaturizer):
    data_source: str of "matminer", "magpie" or "deml" (default "matminer")
      Source for element property data.
    """
    try:
      from matminer.featurizers.composition import ElementProperty
    except ModuleNotFoundError:
      raise ValueError("This class requires matminer to be installed.")

    self.data_source = data_source
    self.ep_featurizer = ElementProperty.from_preset(self.data_source)

  def _featurize(self, composition: PymatgenComposition) -> np.ndarray:
    """
@@ -69,14 +74,7 @@ class ElementPropertyFingerprint(MaterialCompositionFeaturizer):
      stoichiometry. Some values may be NaN.
    """
    try:
      from matminer.featurizers.composition import ElementProperty
    except ModuleNotFoundError:
      raise ValueError("This class requires matminer to be installed.")

    ep = ElementProperty.from_preset(self.data_source)

    try:
      feats = ep.featurize(composition)
      feats = self.ep_featurizer.featurize(composition)
    except:
      feats = []

+6 −8
Original line number Diff line number Diff line
@@ -54,9 +54,14 @@ class SineCoulombMatrix(MaterialStructureFeaturizer):
    flatten: bool (default True)
      Return flattened vector of matrix eigenvalues.
    """
    try:
      from matminer.featurizers.structure import SineCoulombMatrix as SCM
    except ModuleNotFoundError:
      raise ValueError("This class requires matminer to be installed.")

    self.max_atoms = max_atoms
    self.flatten = flatten
    self.scm = SCM(flatten=False)

  def _featurize(self, struct: PymatgenStructure) -> np.ndarray:
    """
@@ -74,15 +79,8 @@ class SineCoulombMatrix(MaterialStructureFeaturizer):
      2D sine Coulomb matrix with shape (max_atoms, max_atoms),
      or 1D matrix eigenvalues with shape (max_atoms,).
    """

    try:
      from matminer.featurizers.structure import SineCoulombMatrix as SCM
    except ModuleNotFoundError:
      raise ValueError("This class requires matminer to be installed.")

    # Get full N x N SCM
    scm = SCM(flatten=False)
    sine_mat = scm.featurize(struct)
    sine_mat = self.scm.featurize(struct)

    if self.flatten:
      eigs, _ = np.linalg.eig(sine_mat)
+8 −5
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@ class CircularFingerprint(MolecularFeaturizer):
      Whether to calculate SMILES strings for fragment IDs (only applicable
      when calculating sparse fingerprints).
    """
    try:
      from rdkit import Chem  # noqa
      from rdkit.Chem import rdMolDescriptors  # noqa
    except ModuleNotFoundError:
      raise ValueError("This class requires RDKit to be installed.")

    self.radius = radius
    self.size = size
    self.chiral = chiral
@@ -76,11 +82,8 @@ class CircularFingerprint(MolecularFeaturizer):
    np.ndarray
      A numpy array of circular fingerprint.
    """
    try:
    from rdkit import Chem
    from rdkit.Chem import rdMolDescriptors
    except ModuleNotFoundError:
      raise ValueError("This class requires RDKit to be installed.")

    if self.sparse:
      info: Dict = {}
+8 −5
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ class CoulombMatrix(MolecularFeaturizer):
    seed: int, optional (default None)
      Random seed to use.
    """
    try:
      from rdkit import Chem  # noqa
      from rdkit.Chem import AllChem  # noqa
    except ModuleNotFoundError:
      raise ValueError("This class requires RDKit to be installed.")

    self.max_atoms = int(max_atoms)
    self.remove_hydrogens = remove_hydrogens
    self.randomize = randomize
@@ -116,11 +122,8 @@ class CoulombMatrix(MolecularFeaturizer):
    np.ndarray
      The coulomb matrices of the given molecule
    """
    try:
    from rdkit import Chem
    from rdkit.Chem import AllChem
    except ModuleNotFoundError:
      raise ValueError("This class requires RDKit to be installed.")

    # Check whether num_confs >=1 or not
    num_confs = len(mol.GetConformers())
Loading