Quickstart
Create a Drug Discovery pipeline in minutes
Was this helpful?
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.")# 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}'")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)