From 186a66643f8de9c4383259055325d20aeed8c86e Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Fri, 5 Jul 2024 13:25:10 +0200 Subject: [PATCH 1/2] use GetMorganGenerator --- tests/test_estimators/test_similarity_transformation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_estimators/test_similarity_transformation.py b/tests/test_estimators/test_similarity_transformation.py index bc1704b0..b304f80a 100644 --- a/tests/test_estimators/test_similarity_transformation.py +++ b/tests/test_estimators/test_similarity_transformation.py @@ -7,7 +7,7 @@ import numpy as np import numpy.typing as npt from rdkit import Chem -from rdkit.Chem import AllChem +from rdkit.Chem import rdFingerprintGenerator from rdkit.DataStructs import BulkTanimotoSimilarity from scipy import sparse from sklearn.neighbors import KNeighborsClassifier @@ -78,9 +78,10 @@ def _calculate_rdkit_self_similarity( Self similarity. """ fp_list = [] + morgan_generator = rdFingerprintGenerator.GetMorganGenerator(radius=2) for smi in compound_list: mol = Chem.MolFromSmiles(smi) - fp_list.append(AllChem.GetMorganFingerprintAsBitVect(mol, 2)) + fp_list.append(morgan_generator.GetFingerprint(mol)) sim = [] for fp1 in fp_list: sim.append(BulkTanimotoSimilarity(fp1, fp_list)) From 6a7335e65867e42f2dbffaa9f683b461814cdfec Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Fri, 12 Jul 2024 16:38:33 +0200 Subject: [PATCH 2/2] update tests to new fp --- tests/utils/fingerprints.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/utils/fingerprints.py b/tests/utils/fingerprints.py index 1ba96396..5973d004 100644 --- a/tests/utils/fingerprints.py +++ b/tests/utils/fingerprints.py @@ -7,7 +7,7 @@ from rdkit import Chem # pylint: disable=no-name-in-module -from rdkit.Chem.AllChem import GetMorganFingerprintAsBitVect +from rdkit.Chem import rdFingerprintGenerator as rdkit_fp from rdkit.DataStructs import ExplicitBitVect from scipy import sparse @@ -34,9 +34,10 @@ def make_sparse_fp( Feature matrix. """ vector_list = [] + morgan_fp = rdkit_fp.GetMorganGenerator(radius=radius, fpSize=n_bits) for smiles in smiles_list: mol = Chem.MolFromSmiles(smiles) # pylint: disable=no-member - vector = GetMorganFingerprintAsBitVect(mol, radius=radius, nBits=n_bits) + vector = morgan_fp.GetFingerprintAsNumPy(mol) vector_list.append(sparse.csr_matrix(vector)) return sparse.vstack(vector_list)