如何生成ECFP哈希折叠数据



我正在尝试将化学结构转换为ECFP数据。买,我的折叠台阶有问题。

我通过D.Rogers和M.Hahn的论文(J.Chem.Inf.Model.,Vol.50,No.52010(了解生成ECFP数据的所有过程

我在python中使用了一个pinky模块来计算每个分子的ECFP。(https://github.com/ubccr/pinky/blob/master/pinky/fingerprints/ecfp.py)

该函数的输出如下

{6456320269923861509: 1,
-3040533427843102467: 2,
-7329542376511023568: 1,
-5821485132112031149: 1,
-643847807504931861: 1,
3054809300354049582: 1,
-3679727481768249355: 1,
-2240115528993944325: 1,
5159885938473603439: 1,
1268207003089618622: 1,
267156486644197995: 1,
6401915128722912935: 1,
-8944122298402911035: 1,
-7116035920000285502: 1}

我知道它是什么,它意味着什么。

但我不知道如何将这些数据转换为二进制数据形式。

在此网站中(https://docs.chemaxon.com/display/docs/extended-connectivity-fingerprint-ecfp.md),将上述标识符转换为固定长度的比特串(折叠过程(

如何将上述原子标识符转换为固定长度的比特串?

有人能为ECFP方法推荐一个合适的哈希函数吗?

我认为这里不需要散列函数,因为您显示的字典中的键似乎已经是原子邻域的散列了。我相信将其表示为固定长度的位向量就像bit_index=hash%n_bits:一样简单

假设您使用的是标准模块,变量hashdict就是您所显示的输出。

n_bits = 1024  # Number of bits in fixed-length fingerprint
fp = [0 for _ in range(n_bits)]  # The fingerprint as a python list
# I ignore the counts here for a binary output
for nbrhood_hash in hash_dict.keys():
bit = nbrhood_hash % n_bits
fp[bit] = 1
# Take a look at non-zero indexes
indexes = [ix for ix, bit in enumerate(fp) if bit > 0]
indexes
>>> [5, 194, 197, 251, 253, 367, 558, 560, 595, 619, 679, 702, 1003, 1013]

我相信这种方式相当于RDKit包:

from rdkit import Chem
from rdkit.Chem import AllChem
mol = Chem.MolFromSmiles('CC(C)Oc1ccc(-c2nc(-c3cccc4c3CC[C@H]4NCCC(=O)O)no2)cc1C#N')
# Sparse ECFP
fp_sparse = AllChem.GetMorganFingerprint(mol, 2)
# BitVector ECFP (fixed length)
fp_bitvect = AllChem.GetMorganFingerprintAsBitVect(mol, 2, nBits=n_bits)
# Convert hashes from sparse fingerprint into fixed-length indicies
bit_set = set()
for nbrhood_hash in fp_sparse.GetNonzeroElements().keys():
bit = nbrhood_hash % n_bits  # Same as before
bit_set.add(bit)
# Check these are equivalent to the rdkit fixed-length fingerprint
set(fp_bitvect.GetOnBits()) == bit_set
>>> True

最新更新