Commit 41575193 authored by Milosz Grabski's avatar Milosz Grabski
Browse files

unit testing

parent d1a57904
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -38,8 +38,7 @@ from deepchem.feat.complex_featurizers import RdkitGridFeaturizer
from deepchem.feat.complex_featurizers import NeighborListAtomicCoordinates
from deepchem.feat.complex_featurizers import NeighborListComplexAtomicCoordinates
from deepchem.feat.complex_featurizers import (
    ComplexNeighborListFragmentAtomicCoordinates,
)
    ComplexNeighborListFragmentAtomicCoordinates,)
from deepchem.feat.complex_featurizers import ContactCircularFingerprint
from deepchem.feat.complex_featurizers import ContactCircularVoxelizer
from deepchem.feat.complex_featurizers import SplifFingerprint
@@ -65,3 +64,6 @@ try:
  from deepchem.feat.smiles_tokenizer import BasicSmilesTokenizer
except ModuleNotFoundError:
  pass

# support classes
from deepchem.feat.molecule_featurizers import GraphMatrix
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ from deepchem.feat.molecule_featurizers.bp_symmetry_function_input import BPSymm
from deepchem.feat.molecule_featurizers.circular_fingerprint import CircularFingerprint
from deepchem.feat.molecule_featurizers.coulomb_matrices import CoulombMatrix
from deepchem.feat.molecule_featurizers.coulomb_matrices import CoulombMatrixEig
from deepchem.feat.molecule_featurizers.molgan_featurizer import GraphMatrix
from deepchem.feat.molecule_featurizers.maccs_keys_fingerprint import MACCSKeysFingerprint
from deepchem.feat.molecule_featurizers.mordred_descriptors import MordredDescriptors
from deepchem.feat.molecule_featurizers.mol2vec_fingerprint import Mol2VecFingerprint
+18 −13
Original line number Diff line number Diff line
import unittest
import numpy as np
from deepchem.feat.molecule_featurizers.molgan_featurizer import GraphMatrix
from deepchem.feat.molecule_featurizers import GraphMatrix


class TestGraphMatrix(unittest.TestCase):
    def test_graph_matrix():

  def test_graph_matrix(self):

    max_atom_count = 5
    atom_array = [7, 7, 7, 8, 8, 8, 9, 6]
@@ -15,7 +16,11 @@ class TestGraphMatrix(unittest.TestCase):
    graph_matrix = GraphMatrix(adjacency_matrix=A, node_features=X)
    assert isinstance(graph_matrix.adjacency_matrix, np.ndarray)
    assert isinstance(graph_matrix.node_features, np.ndarray)
        assert isinstance(graph_matrix.adjacency_matrix.dtype, np.float32)
        assert isinstance(graph_matrix.node_features.dtype, np.float32)
    assert graph_matrix.adjacency_matrix.dtype == np.float32
    assert graph_matrix.node_features.dtype == np.int32
    assert graph_matrix.adjacency_matrix.shape == A.shape
    assert graph_matrix.node_features.shape == X.shape


if __name__ == '__main__':
  unittest.main()
+25 −0
Original line number Diff line number Diff line
import unittest
from deepchem.feat.molecule_featurizers import MolGanFeaturizer
from deepchem.feat.molecule_featurizers import GraphMatrix


class TestMolganFeaturizer(unittest.TestCase):

  def test_featurizer_smiles(self):
    smiles = [
        'C#C[C@@]1(C)[NH2+][CH+]N[C@@H]1C', '[NH-][CH+]Oc1nnon1',
        'Cn1ncc2c1C=CC2', 'O=C[C@@H]1[C@H]2[C@H]3[C@@H]1[C@H]1[C@@H]2[N@@H+]31',
        'C#Cc1[nH]cnc1C#N', 'N#C[C@]1(N)CO[C@H]1CO',
        'C[C@@H]1C(NO)C[C@@H]2O[C@@H]21', 'OC1CC=CC1', 'Cn1c(O)ccc1CO',
        '[NH-]C1OC[C@@]2(C=O)N[C@@H]12', 'incorrect smiles'
    ]

    featurizer = MolGanFeaturizer()
    data = featurizer.featurize(smiles)
    incorrect = list(filter(lambda x: not isinstance(x, GraphMatrix), data))
    assert len(data) == len(smiles)
    assert len(incorrect) == 1


if __name__ == '__main__':
  unittest.main()