-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrdkit_process.py
More file actions
30 lines (23 loc) · 929 Bytes
/
Copy pathrdkit_process.py
File metadata and controls
30 lines (23 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.DataStructs import DiceSimilarity
import numpy as np
import matplotlib.pyplot as plt
sanitize_flags = Chem.SANITIZE_ALL ^ Chem.SANITIZE_PROPERTIES
input_path = '/home/jmuhlich/Dropbox (HMS)/Shimada DTP overlap/input/Chem2D_Jun2016.sdf'
# Change this to SmilesMolSupplier or whatever you need for your data.
mol_supplier = Chem.SDMolSupplier(input_path, sanitize=False)
fingerprints = []
for mol in mol_supplier:
try:
Chem.SanitizeMol(mol, sanitize_flags)
except ValueError as err:
smiles = Chem.MolToSmiles(mol)
print("ERROR! skipping molecule due to error: %s < %s >" % (err, smiles))
pass
fp = AllChem.GetMorganFingerprint(mol, 2)
fingerprints.append(fp)
compare_fp = fingerprints[0]
similarity = [DiceSimilarity(compare_fp, fp2) for fp2 in fingerprints]
plt.hist(similarity, bins=200, log=True)
plt.show()