【问题标题】:How to generate ECFP hashing folding data?如何生成 ECFP 哈希折叠数据?
【发布时间】:2021-01-10 15:13:53
【问题描述】:

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

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

我在 python 中使用了一个小指模块来计算每个分子的 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 方法推荐一个合适的散列函数?

【问题讨论】:

    标签: python binary hash-function molecule cheminformatics


    【解决方案1】:

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

    假设您使用的是标准模块并且变量 hash_dict 是您显示的输出。

    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]
    

    我相信这种方式等同于(ish)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
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多