TypeError: 'NoneType' 对象不是迭代器 Rdkit VS 代码

问题描述

我正在尝试通过 Lipinski、Ghose 和 RUle of 3 filter 从数据库“part1”中过滤分子,但我不断收到错误消息。 因此,在我运行此脚本后,我在两次提到“进度条”的行中收到错误“对象不是迭代器”。我是新手,希望得到帮助。

以下是我用于过滤分子数据库的脚本。

from rdkit import Chem
from rdkit.Chem import Descriptors


import progressbar

if __name__ == '__main__':


    molecules = Chem.SDMolSupplier('chemspidersdf/part1.sdf')

    results = {
        "Lipinski Rule of 5": 0,"Ghose Filter": 0,"Rule of 3 Filter": 0,}

    print ("Molecule Database Length: " + str(len(molecules)))

    for i in progressbar.ProgressBar(range(len(molecules))):

        molecule = molecules[i]
        if molecule:

            lipinski = False
            rule_of_3 = False
            ghose_filter = False

            molecular_weight = Descriptors.ExactMolWt(molecule)
            logp = Descriptors.MolLogP(molecule)
            h_bond_donor = Descriptors.NumHDonors(molecule)
            h_bond_acceptors = Descriptors.NumHAcceptors(molecule)
            rotatable_bonds = Descriptors.NumRotatableBonds(molecule)
            number_of_atoms = Chem.rdchem.Mol.GetNumAtoms(molecule)
            molar_refractivity = Chem.Crippen.MolMR(molecule)

            # Lipinski
            if molecular_weight <= 500 and logp <= 5 and h_bond_donor <= 5 and h_bond_acceptors <= 5 and rotatable_bonds <= 5:
                lipinski = True
                results["Lipinski Rule of 5"] += 1

            # Ghose Filter
            if molecular_weight >= 160 and molecular_weight <= 480 and logp >= 0.4 and logp <= 5.6 and number_of_atoms >= 20 and number_of_atoms <= 70 and molar_refractivity >= 40 and molar_refractivity <= 130:
                ghose_filter = True
                results["Ghose Filter"] += 1
     
            # Rule of 3
            if molecular_weight <= 300 and logp <= 3 and h_bond_donor <= 3 and h_bond_acceptors <= 3 and rotatable_bonds <= 3:
                rule_of_3 = True
                results["Rule of 3 Filter"] += 1

      

    print (results)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)