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

Docking Score Oracle #63

Closed
andrewdchen opened this issue Mar 12, 2021 · 35 comments
Closed

Docking Score Oracle #63

andrewdchen opened this issue Mar 12, 2021 · 35 comments

Comments

@andrewdchen
Copy link

Thanks for providing this tool! I'm looking forward to using it in our own molecular generation projects. I'm trying to follow the code snippet provided here: Docking Scores

After following the 4 instructions in that page, I'm consistently running into this error:

>>> oracle2 = Oracle(name='docking_score', software='vina', pyscreener_path='/global/home/users/adchen/pyscreener', pdbids=['5WIU'], center=(-18.2,14.4,-16.1), size=(15.4, 13.9, 14.5), buffer=10, path='./my_test/', num_worker=1, ncpu=4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/oracles.py", line 21, in __init__
    self.assign_evaluator()
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/oracles.py", line 163, in assign_evaluator
    self.evaluator_func = docking_meta(**self.kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/chem_utils.py", line 1686, in __init__
    self.scorer = screener(**kwargs)
  File "/global/home/users/adchen/pyscreener/pyscreener/docking/vina.py", line 107, in __init__
    path=path, verbose=verbose, **kwargs)
  File "/global/home/users/adchen/pyscreener/pyscreener/docking/base.py", line 93, in __init__
    self.receptors = receptors
  File "/global/home/users/adchen/pyscreener/pyscreener/docking/base.py", line 333, in receptors
    receptors = [self.prepare_receptor(receptor) for receptor in receptors]
  File "/global/home/users/adchen/pyscreener/pyscreener/docking/base.py", line 333, in <listcomp>
    receptors = [self.prepare_receptor(receptor) for receptor in receptors]
  File "/global/home/users/adchen/pyscreener/pyscreener/docking/vina.py", line 128, in prepare_receptor
    sp.run(args, stderr=sp.PIPE, check=True)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'prepare_receptor': 'prepare_receptor'

Relevant system details:

- CentOS Linux 7 (Core)
- Python 3.7 

If you could shine some light on this error, that would be great!
Thanks!

@futianfan
Copy link
Collaborator

https://ccsb.scripps.edu/adfr/downloads/ Please install adfr first.

@andrewdchen
Copy link
Author

adfr is installed already. Do you know what else could be causing this?

@futianfan
Copy link
Collaborator

have you exported the bin path of adfr executable file?

@andrewdchen
Copy link
Author

I added export PATH=/global/home/users/adchen/ADFRsuite_x86_64Linux_1.0/myFolder/bin:$PATH to my .bashrc file.

@futianfan
Copy link
Collaborator

That's also what i did.

@kexinhuang12345
Copy link
Collaborator

Hey, thanks for the interest. @wenhao-gao, have you encountered this issue before?

@wenhao-gao
Copy link
Collaborator

When you type "prepare_receptor" in terminal, does it show the follwoing:
"prepare_receptor4: receptor filename must be specified.
Usage: prepare_receptor4.py -r filename
......"
Also, what shell are you using? The default configuration file can be something as .bash_profile or .zshrc.

@andrewdchen
Copy link
Author

andrewdchen commented Mar 16, 2021

@wenhao-gao When I type prepare_receptor in the terminal, it says the command is not found. I'm using bash. Are there installation steps that I'm missing?

@wenhao-gao
Copy link
Collaborator

I think the problem is just the path. You can first check if your system run your bashrc file when you log in, by adding some simple echo commands. If bashrc doesn't work, you may want to see if your system is using other scripts. Another point might be your path to adfr bin directory. You can check it by going to that directory and check prepare_receptor command there.

@andrewdchen
Copy link
Author

I have confirmed that my system is sourcing the bash.rc file with echo commands. And when I inspect the adfr bin directory ./prepare_receptor works but not prepare_receptor. It does seem like something is wrong with my path...

@wenhao-gao
Copy link
Collaborator

When you simply run export PATH=/global/home/users/adchen/ADFRsuite_x86_64Linux_1.0/myFolder/bin:$PATH, does it work?

@andrewdchen
Copy link
Author

It does work! But then I run into another issue that seems to have to do with a function in oracles.py, full traceback here:

>>> from tdc import Oracle
>>> oracle2=Oracle(name='Docking_Score', software='vina', pyscreenr_path = '/global/home/users/adchen/pyscreener', pdbids=['5WIU'], center=(-18.2, 14.4, -16.1), size=(15.4,13.9,14.5), buffer=10, path='./my_test/', num_workers=1, ncpu=4)
adding gasteiger charges to peptide
Warning: hydrogens,  ['HG', 'HG', 'HG1', 'HG1', 'HG1', 'HG', 'HH', 'HG', 'HG', 'HG1', 'HG', 'HH', 'HG', 'HG1', 'HG', 'HH', 'HH', 'HG', 'HG', 'HG', 'HH', 'HG1', 'HG1', 'HZ3', 'HG1', 'HG1', 'HG', 'HG1', 'HG1', 'HH', 'HH', 'HG1', 'HG1', 'HG1', 'HG', 'HG', 'HG1', 'HH', 'HG', 'HH', 'HG1']  , with no bonds!
>>> oracle2('c1ccccc1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/oracles.py", line 200, in __call__
    return self.evaluator_func(*args, **kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/chem_utils.py", line 1689, in __call__
    final_score = self.scorer(test_smiles)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/vina.py", line 110, in __call__
    return self.dock(*args, **kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/base.py", line 187, in dock
    recordsss = self.dock_ensemble(*smis_or_files, **kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/base.py", line 262, in dock_ensemble
    recordsss = self.run_docking(ligands)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/vina.py", line 244, in run_docking
    with self.Pool(self.distributed, self.num_workers, self.ncpu) as pool:
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/base.py", line 748, in Pool
    return Pool(max_workers=num_workers)
UnboundLocalError: local variable 'Pool' referenced before assignment
>>>

@futianfan
Copy link
Collaborator

I met the same issue and fixed it. Please check coleygroup/pyscreener#5 for solutions.

@futianfan
Copy link
Collaborator

Please check the following link for updating pyscreener.
https://github.com/futianfan/pyscreener/tree/tianfan_dev.

@andrewdchen
Copy link
Author

Thanks for the fix, it certainly is a hacky way to get around it, and I'm not sure why you need to import Pool twice. But now I'm running into the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/oracles.py", line 200, in __call__
    return self.evaluator_func(*args, **kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tdc/chem_utils.py", line 1689, in __call__
    final_score = self.scorer(test_smiles)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/vina.py", line 110, in __call__
    return self.dock(*args, **kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/base.py", line 187, in dock
    recordsss = self.dock_ensemble(*smis_or_files, **kwargs)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/base.py", line 262, in dock_ensemble
    recordsss = self.run_docking(ligands)
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/pyscreener-0+untagged.80.g15cce4c.dirty-py3.7.egg/pyscreener/docking/vina.py", line 249, in run_docking
    desc='Docking', unit='ligand')
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/site-packages/tqdm/std.py", line 1167, in __iter__
    for obj in iterable:
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/concurrent/futures/process.py", line 483, in _chain_from_iterable_of_lists
    for element in iterable:
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
    yield fs.pop().result()
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/global/home/users/adchen/miniconda3/envs/gcpn3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
FileNotFoundError: [Errno 2] No such file or directory: 'vina': 'vina'

Have you run into this before?

Thanks again!

@futianfan
Copy link
Collaborator

vina is executable, you can find the installation guide and download site from http://vina.scripps.edu/.

@andrewdchen
Copy link
Author

I installed vina already, but am still running into this error. My vina installation is located here: /global/home/users/adchen/autodock_vina_1_1_2_linux_x86

@futianfan
Copy link
Collaborator

have you run "export PATH=/global/home/users/adchen/autodock_vina_1_1_2_linux_x86/bin:$PATH" ? make sure running "vina" is ok before using docking oracle.

@davidegraff
Copy link

Hi @andrewdchen- the docking_score oracle uses the pyscreener library (of which I'm the author) in the backend. It's essentially a wrapper around already existing docking software and relies on all of the software being located on your path. You must be able able to run vina and prepare_receptor straight from your terminal without needing to specify their location before you utilize the docking_score oracle

@andrewdchen
Copy link
Author

Hi @davidegraff, thanks for hopping over to this thread.

vina and prepare_receptor runs straight from the terminal after I manually type export PATH=/global/home/users/adchen/autodock_vina_1_1_2_linux_x86/bin:$PATH.

But then when I jump into my python interpreter I get the error from above.

@davidegraff
Copy link

after typing export PATH=/global/home/users/adchen/autodock_vina_1_1_2_linux_x86/bin:$PATH, what's the output of the following commands?

$ echo $PATH
[...]
$ which vina
[...]
$ which prepare_receptor
[...]
$ python
>>> import subprocess
>>> subprocess.run(['vina'])
[...]
>>> subprocess.run(['prepare_receptor'])
[...]

@andrewdchen
Copy link
Author

So if I just type export PATH=/global/home/users/adchen/autodock_vina_1_1_2_linux_x86/bin:$PATH I get

$ echo $PATH
/global/home/users/adchen/autodock_vina_1_1_2_linux_x86/bin:/global/home/users/adchen/miniconda3/envs/gcpn3/bin:/usr/local/bin:/global/home/users/adchen/miniconda3/envs/my-rdkit-env/bin:/global/home/users/adchen/miniconda3/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/ibutils/bin:/global/home/users/adchen/.local/bin:/global/home/users/adchen/bin:/global/home/users/adchen/.linuxbrew/bin
$ which vina
~/autodock_vina_1_1_2_linux_x86/bin/vina
$ which prepare_receptor
/usr/bin/which: no prepare_receptor in ... (path variable above)

$ python
>>> import subprocess
>>> subprocess.run(['vina'])
...
CompletedProcess(args=['vina'], returncode=1)
>>> subprocess.run(['prepare_receptor'])
...
FileNotFoundError: [Errno 2] No such file or directory: 'prepare_receptor': 'prepare_receptor'

But if I manually type both export statements:

  • export PATH=/global/home/users/adchen/autodock_vina_1_1_2_linux_x86/bin:$PATH
  • export PATH=/global/home/users/adchen/ADFRsuite_x86_64Linux_1.0/myFolder/bin:$PATH

then the code snippet from tdc does work!

I still need to diagnose my .bashrc to understand why adding these doesn't automatically add them to my $PATH but otherwise I think I have enough of a working version that you can close this issue. Thanks for the quick responses @everyone, really appreciate it!

@davidegraff
Copy link

it's an unfortunate aspect of pyscreener that it relies so heavily on your PATH being configured correctly, but that's bound to happen when all it does is call external software. The only alternative would be to manually pass in the paths for all the executables, but that's arguably more cumbersome than configuring your PATH. What your issue seems to be above is that you're only adding the location of the Vina executable to your path (e.g., autodock_vina_1_1_2_linux_x86/bin.) You also need to have the prepare_receptor executable on your path as well, which is why it works when you run both of the export statements at the end of your post, but why it didn't work inside the python interpreter when you only ran that first statement.

To avoid having to type those statements in every shell before you run pyscreener, you can do one of two things:

  1. add those statements to your .bash_profile
  2. create a symbolic to both vina and prepare_receptor inside $HOME/bin or $HOME/.local/bin by going into either directory and typing ln -s path/to/<vina/prepare_receptor> (it doesn't matter which really- the only difference is the visibility of the directory)

@kexinhuang12345
Copy link
Collaborator

Glad it is solved! We will update the installation instruction accordingly. Thanks so much for the help

@YifanDengWHU
Copy link

Hi, I came across the same issue in the ADFR. After I added these two softwares to my bashrc, and source ~/.basrhc. I typed "prepare_receptor" in the terminal, it would say prepare_receptor: command not found, while it is OK for vina.
I tried to use export PATH=/home/dyf/ADFRsuite_x86_64Linux_1.0/myFolder/bin:$PATH directly, it doesn't work, either.
Also, I can't use the python in tdc_env after I added ADFR to path, when I typed python in terminal, it would say python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
image

@davidegraff
Copy link

I’m going to guess that’s because you put the ADFR bin at the front of your PATH instead of the end. If you type which python it’s likely that you’re getting the python that’s packed with ADFR rather than your normal python

@YifanDengWHU
Copy link

Thanks for your reply!
So should I change it into export PATH="$PATH:/home/dyf/ADFRsuite_x86_64Linux_1.0/myFolder/bin/"? However, it still doesn't work. And yes, the which python will get the python inside ADFR.

@davidegraff
Copy link

if you change that in your configuration file and restart your shell, what's the output of which python?

@YifanDengWHU
Copy link

It will be like this, the prepare_receptor still doesn't work:
image

@davidegraff
Copy link

and is the ADFR bin still under your $PATH?

@YifanDengWHU
Copy link

Yes, when I echo $PATH,
image

@davidegraff
Copy link

Hmm odd! It looks like you’ve got a bunch of repeated folders on your path, so I would also clean that up as well and see if that fixes anything. I’d also just double check and see if the prepare_receptor binary is under the directory you added to your PATH

@YifanDengWHU
Copy link

I reboot the system and it is like
image
There aren't repeated folders now (the mnt/c/xxx are from Windows path, I tried to install them in my Windows first. There are some problems so I turned to WSL).
I wonder how the ADFRsuite_x86_64Linux_1.0/myFolder/bin should be like? Since we added this to the PATH, mine look likes this:
image
I wonder whether there is a problem with the ADFR installation.

@davidegraff
Copy link

Yeah if there is no prepare_receptor binary in any of the folders on your path then you’ll always get this issue. It might just be an issue with your ADFR install

@YifanDengWHU
Copy link

Thank you so much! I just checked the installation of ADFR on WSL, it didn't finish. Let me check why this would happen...
image

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

6 participants