Skip to main content

wazy

tests PyPI version

Pretrained Bayesian Optimization of Amino Acid Sequences. This is actively developed research code - things can break and the API may change. Please use caution and open an issue if things are unexpected!

Colab

Click the button below to use the algorithm in Google Colab

Open In Colab

Colab Peptide Binder

To use AlphaFold with Wazy to design peptides that bind to specific proteins, click the button below.

Open In Colab

installing

pip install wazy

Quickstart

You can use an ask/tell style interface to design a peptide.

We can tell a few examples of sequences we know and their scalar labels. Let's try a simple example where the label is the number of alanines. You'll also want your labels to vary from about -5 to 5. We'll start by importing and building a BOAlgorithm class. In this example, I re-use the same key for simplicity.

import wazy
import jax
key = jax.random.PRNGKey(0)
boa = wazy.BOAlgorithm()

Now we can tell it a few examples.

boa.tell(key, "GGGG", 0)
boa.tell(key, "GAHK", 1)
boa.tell(key, "DAAE", 2)
boa.tell(key, "DAAA", 3)

We can predict on new values. This will return both a predicted label and its uncertainty and its epistemic uncertainty.

boa.predict(key, "LPAH")
# Output:
(5.823452, 69.99278, 24.500998)

The accuracy is poor - $5.8\pm 70$. Let's now use Bayesian optimization to choose which sequence to try next:

boa.ask(key)
# Output
('DAAV', 6.901945)

The first value is the sequence to try next. The second is an indicator in how valuable (value of acquisition function) it finds that sequence. Now we can tell it the value:

boa.tell(key, "DAAV", 2)

We can also choose the sequence length:

boa.ask(key, length=6)
# Output
('DAAATA', 5.676821)

We can try our new prediction to see if it improved.

boa.tell(key, "DAAATA", 4)
boa.predict(key, "LPAH")
# Output
(2.0458677, 13.694655, 1.0933837)

Which is indeed closer to the true answer of 1. Finally, we can ask for the best sequence:

boa.ask(key, "max", length=5)
# Output
('DAAAA', 3.8262398)

Key

If you are going to use this process in a loop, be sure to split the key:

s = "START"
for i in range(10):
  key, _ = jax.random.split(key)
  boa.tell(key, s, 4)
  s, _ = boa.ask(key, "max", length=5)

Batching

You can increase the number of returned sequences by using the batch_ask, which uses an ad-hoc regret minimization strategy to spread out the proposed sequences:

boa.batch_ask(key, N=3)
# returns 3 seqs

and you can add a multiplier to batch sequences (no overhead), but they may be similar

boa.batch_ask(key, N=3, return_seqs = 10)
# returns 30 seqs

Citation

Please cite Yang et. al.

@article{yang2022now,
  title={Now What Sequence? Pre-trained Ensembles for Bayesian Optimization of Protein Sequences},
  author={Yang, Ziyue and Milas, Katarina A and White, Andrew D},
  journal={bioRxiv},
  year={2022},
  publisher={Cold Spring Harbor Laboratory}
}

Metadata

Release files for wazy 0.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wazy 0.12.1
File Size Uploaded
wazy-0.12.1.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wazy 0.12.1
File Interpreter ABI Platform
wazy-0.12.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.4 kB

Release files / wazy-0.12.1.tar.gz

Download URL wazy-0.12.1.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3bf85464d095a0330d6a8dbd9944c04a81e2b8e705b0f2b0055ea3d339570664
BLAKE2b-256 checksum
How to use checksums
019801a7535dba563f121b39bc6d62fcc10376936db2721861708a7ff248d667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.15

Release files / wazy-0.12.1-py3-none-any.whl

Download URL wazy-0.12.1-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7ccd123b5ccfe0f7196d6f5ec66b51caede573af0c38f8b5e9d52ea00667b5d
BLAKE2b-256 checksum
How to use checksums
377f38f3b43617a32275f045fc98fdd4432586cb93370d664aabc86c279a7418
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.15

Release history Release notifications | RSS feed

This release

0.12.1 This release

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page