Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for mol in ligands: TypeError: 'NoneType' object is not iterable #175

Open
RJ-Li opened this issue Nov 7, 2023 · 0 comments
Open

for mol in ligands: TypeError: 'NoneType' object is not iterable #175

RJ-Li opened this issue Nov 7, 2023 · 0 comments

Comments

@RJ-Li
Copy link

RJ-Li commented Nov 7, 2023

Please help me checking my script to predict on my ./coreset:

import os
import pandas as pd
import csv
import oddt
from oddt.scoring.functions import RFScore
oddt.toolkit = oddt.toolkits.rdk

# create RFScore model from trained model
# rf = RFScore.load('/path/to/your/model.pkl')

rf = RFScore.rfscore(version=1, n_jobs=-1)

with open('result_csv.csv', 'w', newline='') as csvfile:
    fieldnames = ['pdb_id', 'rf_score_v1']
    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
    writer.writeheader()

    for root, dirs, _ in os.walk('./coreset'):
        for dir in dirs:
            pdb_id = dir 
            ligands_file = os.path.join(root, dir, f'{pdb_id}_ligand.sdf')
            proteins_file = os.path.join(root, dir, f'{pdb_id}_pocket.pdb')
            lig_mol = next(oddt.toolkit.readfile('sdf', ligands_file))
            prot_mol = next(oddt.toolkit.readfile('pdb', proteins_file))
            score = rf.predict(lig_mol, prot_mol)
            print(f'{pdb_id}_ligand.sdf', score)

Traceback (most recent call last):
File "oddt_rfscore_Coreset.py", line 25, in
score = rf.predict(lig_mol, prot_mol)
File "/data2/rjli/mambaforge/envs/oddt/lib/python3.8/site-packages/oddt/scoring/init.py", line 260, in predict
descs = self.descriptor_generator.build(ligands)
File "/data2/rjli/mambaforge/envs/oddt/lib/python3.8/site-packages/oddt/scoring/descriptors/init.py", line 167, in build
for mol in ligands:
TypeError: 'NoneType' object is not iterable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant