Skip to content

Commit 7ba4b09

Browse files
committed
Adds documentation to the new lambo tasks
1 parent 806e5c9 commit 7ba4b09

File tree

3 files changed

+232
-15
lines changed

3 files changed

+232
-15
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# DDR3 docking (using TDC)
2+
3+
![Type of objective function: discrete](https://img.shields.io/badge/Type-discrete_inputs-blue)
4+
![Environment to run this objective function: poli lambo](https://img.shields.io/badge/Environment-poli____base-teal
5+
)
6+
7+
## About
8+
9+
This objective function computes the docking score of a small molecule w.r.t. the protein `3pbl`, [which is the canonical example in the Therapeutics Data Common's docking oracles](https://tdcommons.ai/functions/oracles/#docking-scores). Under the hood, it uses pyscreener, vina and the ADFR suite.
10+
11+
## Prerequisites
12+
13+
### Installing AutoDock Vina
14+
15+
#### Download the files
16+
17+
[Download AutoDock Vina from the Center for Computational Structural Biology's website](https://vina.scripps.edu/downloads/). Uncompress them.
18+
19+
#### Add the binary folder to the path.
20+
21+
Add this to the path by including `export PATH=path/to/AutoDock_vina/bin:$PATH` in your `~/.bashrc` or `~/.zshrc`.
22+
23+
```bash
24+
# In your ~/.bashrc or ~/.zshrc
25+
export PATH=path/to/AutoDock_vina/bin:$PATH
26+
```
27+
28+
### Installing the ADFR suite
29+
30+
#### Download the files
31+
32+
[Download the installable files](https://ccsb.scripps.edu/adfr/downloads/). It's likely that you will have to run the `./install.sh` script inside the folder, and thus you might have to change its permissions for execution using `chmod +x`
33+
34+
#### Install it
35+
36+
After running `./install.sh`, you should be able to find `.../bin/prepare_receptor`.
37+
38+
#### Add `prepare_receptor` to the path
39+
40+
For the docking to run, `pyscreener` needs access to the `prepare_receptor` binary. However, adding all of the ADFR `bin` folder is sometimes problematic, since it has a version of Python inside.
41+
42+
Thus, we recommend creating a symlink. Write this in your `~/.bashrc` or `~/.zshrc`:
43+
44+
```bash
45+
# In your ~/.bashrc or ~/.zshrc
46+
ln -sf /path/to/ADFR/bin/prepare_receptor /path/to/AutoDock_vina/bin
47+
```
48+
49+
### Create the `poli__lambo` environment
50+
51+
#### Create the environment from the yml file
52+
53+
This can easily be done by running
54+
55+
```bash
56+
# From the base of the poli repo
57+
conda env create --file src/poli/objective_repository/ddr3_docking/environment.yml
58+
```
59+
60+
This particular example _doesn't_ need to have the `lambo` package installed.
61+
62+
### Making sure you're all set
63+
64+
If the set-up above was successful, you should be able to run
65+
66+
```bash
67+
which vina
68+
# /path/to/your/bin/vina
69+
```
70+
71+
and
72+
73+
```bash
74+
which prepare_receptor
75+
# /path/to/your/bin/prepare_receptor
76+
```
77+
78+
## How to run
79+
80+
You can only run this objective function either in the `poli__lambo` environment, or as an isolated process (which runs this environment underneath).
81+
82+
:::{warning}
83+
Running this objective function will create an `./oracle` folder on your working directory, where it will download the relevant `.pdb` files.
84+
:::
85+
86+
::::{tab-set}
87+
88+
:::{tab-item} (Isolated) in the `poli__lambo` environment
89+
90+
After the setup described above, you can simply run the following code from
91+
92+
```python
93+
from pathlib import Path
94+
95+
import numpy as np
96+
97+
from poli import objective_factory
98+
99+
# How to create
100+
problem_info, f, x0, y0, run_info = objective_factory.create(
101+
name="ddr3_docking",
102+
force_register=True
103+
)
104+
105+
# Example input:
106+
print(x0) # [['c' '1' 'c' 'c' 'c' 'c' 'c' '1']]
107+
108+
# Querying:
109+
print(y0) # [[-4.1]]
110+
```
111+
112+
:::
113+
114+
::::
115+
116+
## See also
117+
118+
- [an internal link of sorts]()

docs/protein-optimization/using_poli/objective_repository/foldx_rfp_lambo.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,58 @@
11
# Protein (RFP) stability and SASA (using `foldx`,`lambo`)
22
![Type of objective function: discrete](https://img.shields.io/badge/Type-discrete_inputs-blue)
3-
![Environment to run this objective function: poli protein](https://img.shields.io/badge/Environment-poli____lambo
4-
)
3+
![Environment to run this objective function: poli protein](https://img.shields.io/badge/Environment-poli____lambo-teal)
54

65
## About
76

87
This objective function returns stability using `foldx` and SASA, _exactly_ as done in the `lambo` implementation.
98

109
## Prerequisites
1110

12-
- Have `foldx` installed, and available in your home directory. We expect the following files to be there:
11+
### `foldx`
12+
13+
We need you to have `foldx` installed, and available in your home directory. We expect the following files to be there:
1314
- `~/foldx/foldx`: the binary. You might need to rename it.
1415
- `~/foldx/rotabase.txt`: a text file necessary for `foldx` to run.
15-
- Have `lambo` checked out, preferrably in the home directory, specifically containing:
16-
- `lambo.tasks.proxy_rfp.proxy_rfp.ProxyRFPTask`
17-
- the rfp data: see `~/lambo/assets/fpbase`
1816

19-
## How to run
17+
### Python environment
2018

21-
You can either run this objective function in your current environment (assuming that you have the correct dependencies installed), or you can run it in an isolated environment.
19+
We expect you to have [cloned and installed the `lambo` repository](https://github.com/samuelstanton/lambo). Since there are some files we can't install automatically using `pip install git+...`, we ask you to create a `conda` environment for the lambo tasks:
2220

23-
::::{tab-set}
21+
```
22+
# From the root of the poli repository
23+
conda env create --file src/poli/objective_repository/foldx_rfp_lambo/environment.yml
24+
```
2425

25-
:::{tab-item} In current environment
26+
Activate the environment you just created using
27+
```
28+
conda activate poli__lambo
29+
```
30+
### `lambo`
2631

27-
You will have to install the following two dependencies:
32+
We also need `lambo`'s tasks to be available in Python's path for `poli__lambo`:
2833

2934
```bash
30-
pip install -r ~/lambo/requirements.txt
35+
# In the poli__lambo environment
36+
git clone https://github.com/samuelstanton/lambo # For reference, we use 431b052
37+
cd lambo
38+
pip install -e .
3139
```
3240

33-
This contains: `pytorch botorch python-levenshtein wandb biopython hydra-core pymoo pandas deepchem transformers selfies jupyter seaborn pyscreener` and other packages.
41+
In particular, we need
42+
- `lambo.tasks.proxy_rfp.proxy_rfp.ProxyRFPTask`
43+
- the rfp data: see `~/lambo/assets/fpbase`
44+
45+
Make sure the data is avaliable.
46+
47+
## How to run
48+
49+
You can only run this objective function either in the `poli__lambo` environment, or as an isolated process (which runs this environment underneath).
50+
51+
::::{tab-set}
52+
53+
:::{tab-item} (Isolated) in the `poli__lambo` environment
3454

35-
Then run
55+
After the setup described above, you can simply run the following code from
3656

3757
```python
3858
from pathlib import Path
@@ -50,7 +70,7 @@ problem_info, f, x0, y0, run_info = objective_factory.create(
5070
print(x0)
5171

5272
# Querying:
53-
print(y0) # The stability of your wildtype
73+
print(y0) # [[-11189.00587946 -39.8155 ], ...]
5474
```
5575

5676
You could also pass an `problem: ProblemSetupInformation` to the create method. For the alphabet reference by default, [we use this encoding](https://github.com/MachineLearningLifeScience/poli/blob/44cad2a5c95f209aeb24d4893d162b3359ca91a3/src/poli/core/util/proteins/defaults.py#L1).
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Objective function name
2+
3+
![Type of objective function: discrete](https://img.shields.io/badge/Type-discrete_inputs-blue)
4+
![Environment to run this objective function: poli lambo](https://img.shields.io/badge/Environment-poli____lambo-teal
5+
)
6+
7+
## About
8+
9+
This objective function computes the penalized logP _exactly_ as is done in the `lambo` implementation.[^1]
10+
11+
[^1]: If you check carefully, you might have noticed that they add to their implementation the empirical means and standard deviations of the ZINC dataset for the values they compute.
12+
13+
To do so, we import their scoring function.
14+
15+
## Prerequisites
16+
17+
### Python environment
18+
19+
We expect you to have [cloned and installed the `lambo` repository](https://github.com/samuelstanton/lambo). Since there are some files we can't install automatically using `pip install git+...`, we ask you to create a `conda` environment for the lambo tasks:
20+
21+
```
22+
# From the root of the poli repository
23+
conda env create --file src/poli/objective_repository/foldx_rfp_lambo/environment.yml
24+
```
25+
26+
Activate the environment you just created using
27+
```
28+
conda activate poli__lambo
29+
```
30+
31+
### `lambo`
32+
33+
We also need `lambo`'s tasks to be available in Python's path for `poli__lambo`:
34+
35+
```bash
36+
# In the poli__lambo environment
37+
git clone https://github.com/samuelstanton/lambo # For reference, we use 431b052
38+
cd lambo
39+
pip install -e .
40+
```
41+
42+
## How to run
43+
44+
You can either run this objective function in your current environment (assuming that you have the correct dependencies installed), or you can run it in an isolated environment.
45+
46+
You can only run this objective function either in the `poli__lambo`, or as an isolated process (which runs this environment underneath).
47+
48+
::::{tab-set}
49+
50+
:::{tab-item} (Isolated) in the `poli__lambo` environment
51+
52+
After the setup described above, you can simply run the following code from
53+
54+
```python
55+
import numpy as np
56+
57+
from poli import objective_factory
58+
59+
# Using create
60+
_, f, x0, y0, _ = objective_factory.create(name="penalized_logp_lambo")
61+
62+
# An example input
63+
print(x0)
64+
65+
# The example's output
66+
print(y0)
67+
68+
# Terminating the isolated process (if it was created)
69+
f.terminate()
70+
```
71+
72+
:::
73+
74+
::::
75+
76+
### Other keyword arguments:
77+
78+
- `penalized: bool = True`. Whether we are evaluating penalized logP or not.
79+
- `string_representation: str = "SMILES"`. Can be either `"SMILES"` or `"SELFIES"`.

0 commit comments

Comments
 (0)