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

Predicting a Binding Site (predict.py): TypeError: sequence item 0: expected str instance, numpy.float32 found #36

Open
Foly93 opened this issue May 27, 2024 · 2 comments

Comments

@Foly93
Copy link

Foly93 commented May 27, 2024

OS: Ubuntu 22.04
mamba: 1.5.5
conda: 23.11.0

Hi,

I am trying to use your program to predict binding sites in a protein PDB. when I run

python ~/DeepPocket/predict.py -p 1A9N_frame_0.pdb -c ~/DeepPocket/first_model_fold1_best_test_auc_85001.pth.tar -s ~/DeepPocket/seg0_best_test_IOU_91.pth.tar -r 3

I get the following terminal message:

/home/luis/DeepPocket/rank_pockets.py:87: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  all_probs.append(F.softmax(output).detach().cpu())
Traceback (most recent call last):
  File "/home/luis/DeepPocket/predict.py", line 106, in <module>
    fout.write(''.join(confidence_types))
TypeError: sequence item 0: expected str instance, numpy.float32 found

I have tried to circumvent the TypeError by changing line 106 in predict.py from fout.write(''.join(confidence_types)) to fout.write(''.join(str(confidence_types))), but that only led to yet another more cryptic error after prompting the aforementioned python command:

Traceback (most recent call last):
  File "/home/luis/DeepPocket/predict.py", line 122, in <module>
    test(seg_model, seg_eptest, seg_gmaker,device,dx_name, args)
  File "/home/luis/DeepPocket/segment_pockets.py", line 145, in test
    output_pocket_pdb(dx_name+'_pocket'+str(count)+'.pdb',prot_prody,pred_aa)
  File "/home/luis/DeepPocket/segment_pockets.py", line 85, in output_pocket_pdb
    pocket=prot_prody.select(sel_str)
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/prody/atomic/atomic.py", line 232, in select
    return SELECT.select(self, selstr, **kwargs)
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/prody/atomic/select.py", line 894, in select
    indices = self.getIndices(atoms, selstr, **kwargs)
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/prody/atomic/select.py", line 952, in getIndices
    torf = self.getBoolArray(atoms, selstr, **kwargs)
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/prody/atomic/select.py", line 1003, in getBoolArray
    parser = self._getParser(selstr)
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/prody/atomic/select.py", line 1102, in _getParser
    parser.enablePackrat()
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/pyparsing/util.py", line 265, in _inner
    return fn(*args, **kwargs)
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/pyparsing/core.py", line 1132, in enable_packrat
    ParserElement.packrat_cache = _FifoCache(cache_size_limit)  # type: ignore[assignment]
  File "/home/luis/miniforge3/envs/DeepPocketEnv/lib/python3.9/site-packages/pyparsing/util.py", line 105, in __init__
    keyring = [object()] * size
TypeError: can't multiply sequence by non-int of type 'Forward'

Do you have an idea how to fix these issues?

Cheers Foly

@RishalAggarwal
Copy link
Collaborator

thank you for the fix on the initial error, it seems like your second error seems to be related prody/pyparsing compatibility, maybe this would help: prody/ProDy#1856

@Foly93
Copy link
Author

Foly93 commented Jun 5, 2024

Hi,

it does work now, with both these issues fixed.

Maybe it is helpful for future users to provide a YAML file for easy python environment setup. I attached my environment YAML file to this message, which creates (a hopefully working) environment via

mamba env create -n DeepPocketEnv -f DeepPocketEnv.yaml

or instead of mamba, conda and micromamba should also work.

Cheers, Luis

DeepPocketEnv.zip

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