Quickstart

Create a Drug Discovery pipeline in minutes

The Pending AI platform offers a variety of capabilities to assist different targeted pipelines. This quick-start guide demonstrates how to build a simple Python script to generate and screen batches of novel structures.

Prerequisites: Install Python 3.9 or later (latest recommended). See here for more information. Create a Pending AI account with access to the different services.

Getting Started

Start by installing the Pending AI Python library. For more information see our Installation guide.

pip install pendingai

You can check this was installed correctly using pendingai --version.

Setting up the Client

The SDK provides a client interface for accessing the Pending AI platform seamlessly. Since an authenticated session is needed for using the different services associated with your account, the client can create and store cached session information.

Creating an authenticated client
from pendingai import PendingAiClient

pai = PendingAiClient()
pai.authentication.login()

Note: The following examples will no longer include the above snippet but it is recommended to start each script by checking the authenticated session status.

Create a screening campaign

For this pipeline we wish to run a script capable of leveraging novel molecule generation (PAI Generator) with high-throughput synthetic accessibility screening (PAI Retro).

1

Generate a novel batch of structures

A user has the fine-grained control over selecting which model is used by listing and checking the individual status for each and sampling from that particular model id - sampling via any available model is also possible.

Select and sample from a generative model
pai = PendingAiClient()

# Iterate over the models and check their status
models = pai.generator.models.list(size=5)
for model in models:
    model_status = pai.generator.models.status(model.id)
    print(f"Model '{model.id}' has status '{model_status.status}'")
    
# Sample a batch of structures from any model
sample_random = pai.generator.generate.call(n=1000)

# Sample a batch of structures from a target model
sample_target = pai.generator.generate.call(models[0].id, n=1000)
print(f"Sampled {len(sample_target.smiles)} structures.")
Example of sampled structures from the generative model.
2

Submit the batch for retrosynthesis

The PAI Retro service requires submitting to a retrosynthesis engine with a collection of building block libraries of purchasable structures. With those resource IDs, the batch can be submitted with additional parameters to control the synthesis jobs.

Submit a retrosynthesis batch
# Retrieve a retrosynthesis engine to submit the batch to
engine = pai.retrosynthesus.engines.list()[0].id
# Retrieve building block libraries to define the synthesis context
libraries = [lib.id for lib in pai.retrosynthesus.libraries.list()]

# Batch submission uses the set of generated SMILES and resource ids
batch = pai.retrosynthesis.batch.create(
    smiles=sample_target.smiles,
    engine=engine,
    libraries=libraries,
    number_of_routes=1,
    processing_time=60,
)
print(f"Batch submitted with ID '{batch.id}'")

Note: Be sure to track the batch id or attach additional identifying metadata so it can be found easily when batches are listed (pai.retrosynthesis.batches.list()).

3

Retrieve the screening result summary

Batch screening can be time consuming depending on the number of jobs submitted. A polling strategy should be employed when checking the progress and retrieving results. Once the batch is completed, results can be retrieved, inspected, and saved for further analysis.

Retrieve synthetic accessibility results
import time
import json

while True:
    time.sleep(5)  # Poll every 5 seconds
    batch_status = pai.retrosynthesis.batches.status(batch.id)
    if batch_status.status == "completed":
        # All jobs have completed and have available results
        results = pai.retrosynthesis.batches.result(batch.id)
        break
        
# Inspect the batch results
num_synthesizable = sum([1 for job in results if job.synthesizable])
print(f"Found {num_synthesizable} synthesizable structures!") 
        
# Save the batch results to file
with open("results.json", "w") as fp:
    json.dump(results, fp, indent=2)
    

🎉 Well done! You've created your first pipeline to aid in increasing the speed of your Drug Discovery process. For more help in creating pipeline components, see the different Guides we have made and reach out for any more suggestions.