Unverified Commit 80cbecc6 authored by Bharath Ramsundar's avatar Bharath Ramsundar Committed by GitHub
Browse files

Merge pull request #2139 from deepchem/weavefix

Fixing typo and adding chirality test
parents 9a76353f 6ca0b890
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ def bond_features(bond, use_chirality=False):
  ]
  if use_chirality:
    bond_feats = bond_feats + one_of_k_encoding_unk(
        str(bond.GetStereo()), GraphConvCoonstants.possible_bond_stereo)
        str(bond.GetStereo()), GraphConvConstants.possible_bond_stereo)
  return np.array(bond_feats)


+14 −2
Original line number Diff line number Diff line
@@ -55,10 +55,8 @@ def test_weave_single_carbon():
  """Test that single carbon atom is featurized properly."""
  mols = ['C']
  featurizer = dc.feat.WeaveFeaturizer()
  #from rdkit import Chem
  mol_list = featurizer.featurize(mols)
  mol = mol_list[0]
  #mol = featurizer._featurize(Chem.MolFromSmiles("C"))

  # Only one carbon
  assert mol.get_num_atoms() == 1
@@ -70,6 +68,20 @@ def test_weave_single_carbon():
  assert mol.get_pair_features().shape == (1 * 1, 14)


def test_chiral_weave():
  """Test weave features on a molecule with chiral structure."""
  mols = ["F\C=C\F"]
  featurizer = dc.feat.WeaveFeaturizer(use_chirality=True)
  mol_list = featurizer.featurize(mols)
  mol = mol_list[0]

  # Only 4 atoms
  assert mol.get_num_atoms() == 4

  # Test feature sizes for chirality
  assert mol.get_num_features() == 78


def test_weave_alkane():
  """Test on simple alkane"""
  mols = ['CCC']