Skip to content

Commit 9495614

Browse files
committed
Writes a chapter on how to get started
1 parent d28b728 commit 9495614

File tree

3 files changed

+125
-6
lines changed

3 files changed

+125
-6
lines changed

docs/protein-optimization/_toc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@
44
format: jb-book
55
root: index.md
66
parts:
7+
- caption: Getting started
8+
chapters:
9+
- file: getting_started/getting_started.md
710
- caption: Using poli - the basics
8-
numbered: true
911
chapters:
10-
- file: using_poli/the_basics/intro_to_poli.md
1112
- file: using_poli/the_basics/registering_an_objective_function.md
1213
- file: using_poli/the_basics/defining_a_problem_solver.md
1314
- file: using_poli/the_basics/optimizing_an_objective_function.md
1415
- file: using_poli/the_basics/diving_deeper.md
1516
- caption: Using poli - examples
16-
numbered: true
1717
chapters:
1818
- file: using_poli/optimization_examples/protein-stability-foldx/optimizing_protein_stability.ipynb
1919
- caption: Understanding FoldX
20-
numbered: true
2120
chapters:
2221
- file: understanding_foldx/00-installing-foldx.md
2322
- file: understanding_foldx/01-single-mutation-using-foldx/index.ipynb
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Getting started
2+
3+
In this chapter, we share with you how to install `poli`, and get started with registering objective functions.
4+
5+
## Installing locally
6+
7+
Unfortunately, we only support **Linux** and **MacOS** for now.
8+
9+
### Installing conda
10+
11+
`poli` is built on top of manipulating `conda` environments. It is therefore important for you to **install conda**. [Follow the documentation of Anaconda itself](https://conda.io/projects/conda/en/latest/user-guide/install/index.html).
12+
13+
Test that your installation went through by writing
14+
15+
```bash
16+
$ conda --version
17+
conda 23.7.2
18+
```
19+
20+
It's okay if you have another version. Read more about [supported versions of `conda` (TODO:ADD)]().
21+
22+
### Installing `poli`
23+
24+
We recommend creating an environment called `poli-base`. **The only dependency `poli` has is `numpy`**:
25+
26+
```bash
27+
$ conda create -n poli-base python=3.9
28+
$ conda activate poli-base
29+
$ pip install numpy
30+
```
31+
32+
Right now, we only support two ways of installing `poli`: by cloning the repo and installing, or using `pip` and `git+`. [TODO: change from my fork to MLLS repo after merging]
33+
34+
::::{tab-set}
35+
36+
:::{tab-item} Installing using `pip +git`
37+
38+
If you are not interested in debugging, you can simply run
39+
40+
```bash
41+
# in the poli-base env
42+
pip install git+https://github.com/miguelgondu/poli.git
43+
```
44+
45+
:::
46+
47+
:::{tab-item} Installing for debugging
48+
49+
If you are interested in debugging locally, clone and install as follows:
50+
51+
```bash
52+
# in the `poli-base` env.
53+
$ git clone [email protected]:miguelgondu/poli.git
54+
$ cd ./poli
55+
$ pip install -e .
56+
```
57+
58+
:::
59+
60+
::::
61+
62+
### Testing your installation
63+
64+
To make sure everything went well, you can test your `poli` installation by running
65+
66+
```bash
67+
$ python -c "from poli.core.registry import get_problems ; print(get_problems())"
68+
[]
69+
```
70+
71+
If the installation isn't fresh/the only one in your system, you might actually get some registered problems.
72+
73+
## Running `poli` in Colab
74+
75+
With a little effort, you can run `poli` in Colab. [Check this example](https://colab.research.google.com/drive/1-IISCebWYfu0QhuCJ11wOag8aKOiPtls).
76+
77+
78+
## Your first `poli` script
79+
80+
As you might have noticed, you can get a list of the registered problems using the `get_problems` method inside `poli.core.registry`. You can also get a list of objective functions available for installing/registration using `from poli.objective_repository import AVAILABLE_OBJECTIVES`:
81+
82+
```bash
83+
$ python -c "from poli.objective_repository import AVAILABLE_OBJECTIVES ; print(AVAILABLE_OBJECTIVES)"
84+
[..., 'white_noise']
85+
```
86+
87+
Let's write a small script that installs `white_noise` from the repository:
88+
89+
```python
90+
# see examples/minimal_working_example.py
91+
from poli import objective_factory
92+
93+
problem_info, f, x0, y0, run_info = objective_factory.create(name="white_noise")
94+
95+
x = np.array([[1]]) # must be of shape [b, d], in this case [1, 1].
96+
for _ in range(5):
97+
print(f"f(x) = {f(x)}")
98+
```
99+
100+
If we run this script, `poli` will ask us to confirm that we want to register/install `"white_noise"` as an objective function (you can deactivate this confirmation step by passing the flag `force_register=True` to `.create`). Afterwards, it will print 5 evaluations of the objective function on the same input.
101+
102+

docs/protein-optimization/index.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
# Tutorials on protein optimization
1+
# Tutorials on protein optimization using poli
22

3-
This book contains documentation on how to measure protein's properties (e.g. stability, solubility...) using tools like FoldX. [Work in Progress]
3+
This book contains documentation on how to use `poli` and `poli-baselines`, our tools for creating and optimizing black box objective functions.
4+
5+
At its core, `poli` allows you to isolate calls to complicated objective functions which might, for example, depend on simulators, binaries, or a weird version of the Java runtime.
6+
Our promise is: if you can run your objective function reliably in a `conda` environment, then you can register it and call it from other projects without having to worry about re-installing all the dependencies.
7+
8+
`poli` comes batteries-included. By this, we mean that there are already a collection of black box objective functions you could register and use out-of-the-box. Examples include:
9+
- standard white noise,
10+
- computing the stability of proteins and their mutations from a wildtype `pdb`,
11+
- optimizing the number of jumps Mario performs in a Super Mario Bros level sampled from the latent space of a Variational Autoencoder.
12+
- optimizing the QED and penalized logP of small molecules, presented as either SELFIES or SMILES. [WIP]
13+
14+
On top of `poli`, we provide `poli-baselines`, a collection of black-box optimization algorithms (focusing especially on *discrete* sequences). Examples include
15+
- Random mutations,
16+
- Evolutionary and genetic algorithms like CMA-ES, or NSGA-2 [WIP],
17+
- Bayesian Optimization in latent space [WIP].
18+
19+
A good place to start is the next chapter! [Go to Getting Started](./getting_started/getting_started.md).
20+
21+
## Contents
422

523
```{tableofcontents}
624
```

0 commit comments

Comments
 (0)