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

rf = RFScore() TypeError: 'module' object is not callable #174

Open
SanFran-Me opened this issue Nov 6, 2023 · 2 comments
Open

rf = RFScore() TypeError: 'module' object is not callable #174

SanFran-Me opened this issue Nov 6, 2023 · 2 comments

Comments

@SanFran-Me
Copy link

import os
import pandas as pd
import csv
import oddt
from oddt.scoring.functions import RFScore

oddt.toolkit = oddt.toolkits.rdk

rf = rfscore(version=1, n_jobs=-1)
# rf.load('/path/to/your/model.pkl')

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)
            writer.writerow({'pdb_id': pdb_id, 'rf_score_v1': score})
ref_df = pd.read_csv("2016_core_affinity.csv", sep='\t')
result_df = pd.read_csv("result_csv.csv")

BUT IT RAISES ERROR:

Traceback (most recent call last):
  File "oddt_rfscore_Coreset.py", line 9, in <module>
    rf = RFScore(version=1, n_jobs=-1)
TypeError: 'module' object is not callable
@SanFran-Me
Copy link
Author

SanFran-Me commented Nov 6, 2023

I saw the source code od RFScore:

def load(self, filename=None, version=1, pdbbind_version=2016):
        if filename is None:
            fname = 'RFScore_v%i_pdbbind%i.pickle' % (version, pdbbind_version)

BUT I did not find any RFScore_v?_pdbbind?.pickle...
So if I want to use the default pkl, what do I need to do?

@RJ-Li
Copy link

RJ-Li commented Nov 7, 2023

I also do not know how to train models on CASF-2016 refined-set and get its pkl model file(for further re-training).
The only thing I know is that there is a csv containing affinity and descriptors in oddt-master/oddt/scoring/functions/RFScore/rfscore_descs_v1.csv

And when I tried:

rf = RFScore.load('/path/to/your/model.pkl')
AttributeError: module 'oddt.scoring.functions.RFScore' has no attribute 'load'

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

2 participants