pengxingang / Pocket2Mol

Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets
MIT License
242 stars 65 forks source link

AttributeError: 'NoneType' object has no attribute 'knn_graph' #27

Closed caiyingchun closed 1 year ago

caiyingchun commented 1 year ago

When I run python sample_for_pdb.py --pdb_path ./example/4yhj.pdb --center "32.0,28.0,36.0", I got this:

[2023-06-06 15:24:11,627::sample::INFO] Namespace(bbox_size=23.0, center=[32.0, 28.0, 36.0], config='./configs/sample_for_pdb.yml', device='cuda', outdir='./outputs', pdb_path='./example/4yhj.pdb')
[2023-06-06 15:24:11,628::sample::INFO] {'model': {'checkpoint': './ckpt/pretrained_Pocket2Mol.pt'}, 'sample': {'seed': 2020, 'num_samples': 100, 'beam_size': 300, 'max_steps': 50, 'threshold': {'focal_threshold': 0.5, 'pos_threshold': 0.25, 'element_threshold': 0.3, 'hasatom_threshold': 0.6, 'bond_threshold': 0.4}}}
[2023-06-06 15:24:11,629::sample::INFO] Loading data...
[2023-06-06 15:24:12,419::sample::INFO] Loading main model...
[2023-06-06 15:24:14,959::sample::INFO] Initialization
InitSample:   0%|                                                                                                                                                    | 0/300 [00:00<?, ?it/s]Traceback (most recent call last):
  File "sample_for_pdb.py", line 139, in <module>
    data = transform_data(data, atom_composer)
  File "/home/data/yingchun/Applic/Pocket2Mol-main/utils/datasets/__init__.py", line 44, in transform_data
    data = transform(data)
  File "/home/data/yingchun/Applic/Pocket2Mol-main/utils/transforms.py", line 657, in __call__
    data = self.get_knn_graph(data, self.knn, len_ligand_ctx, len_compose, num_workers=16)
  File "/home/data/yingchun/Applic/Pocket2Mol-main/utils/transforms.py", line 662, in get_knn_graph
    data.compose_knn_edge_index = knn_graph(data.compose_pos, knn, flow='target_to_source', num_workers=num_workers)
  File "/opt/miniconda3/envs/aidd/lib/python3.7/site-packages/torch_geometric/nn/pool/__init__.py", line 130, in knn_graph
    return torch_cluster.knn_graph(x, k, batch, loop, flow, cosine,
AttributeError: 'NoneType' object has no attribute 'knn_graph'
InitSample:   0%|                                                                                                                                                    | 0/300 [00:00<?, ?it/s]

How to solve it?

pengxingang commented 1 year ago

Hi, what are the versions of the packages pytorch geometric and torch_cluster?

caiyingchun commented 1 year ago

Thank you. I foegot to install torch_cluster. Now It woks.