Synthesis
albert.collections.synthesis.SynthesisCollection
Bases: BaseCollection
Manage synthesis (reaction) records on the Albert platform.
A synthesis record documents a chemical reaction on a drawing canvas: the reactants and products of the reaction, drawn as chemical structures (via the Ketcher structure editor) and laid out in a reaction worksheet table. Each row of that table is a reaction participant (a reactant or a product), and its quantities (mass, moles, equivalents, concentration) can be filled in.
A synthesis always belongs to a block inside a Notebook (see
NotebookCollection); the parent notebook
is supplied when the record is created. Synthesis records are referenced by
their Synthesis ID (format SYN..., e.g. "SYNA1").
A typical flow is: create the record, draw the reaction and push the
canvas with update_canvas_data, initialize the reactant/product table
with create_reactant_productant_table, then set per-row quantities with
update_reactant_row_values.
This collection is accessed as client.synthesis.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for synthesis requests. |
Methods:
| Name | Description |
|---|---|
create |
Create a synthesis record for a notebook Ketcher block. |
get_by_id |
Get a single synthesis record by its ID. |
update |
Update an existing synthesis record. |
update_canvas_data |
Replace the drawn reaction (SMILES, canvas data, and preview image). |
update_reactant_row_values |
Set the quantities (mass, moles, eq, concentration) for one reactant row. |
create_reactant_productant_table |
Initialize the reactant/product table and reveal the reaction worksheet. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/synthesis.py
create
create(
*,
parent_id: NotebookId | str,
name: str,
block_id: str | None = None,
smiles: str | None = None,
) -> Synthesis
Create a synthesis record for a notebook Ketcher block.
Use this to start documenting a reaction inside a notebook. The new record
is empty; draw the reaction and push it with update_canvas_data, and
build out the reactant/product table with
create_reactant_productant_table.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
NotebookId or str
|
The Notebook ID that owns the synthesis record (format |
required |
name
|
str
|
A human-readable name for the synthesis. |
required |
block_id
|
str
|
The Ketcher block ID to associate with the synthesis. A new ID is generated when not provided. |
None
|
smiles
|
str
|
An initial reaction SMILES string to seed the canvas. |
None
|
Returns:
| Type | Description |
|---|---|
Synthesis
|
The created synthesis record, populated with its assigned Synthesis ID. |
Source code in src/albert/collections/synthesis.py
get_by_id
get_by_id(
*,
id: SynthesisId,
include_recommendations: bool = False,
include_predictions: bool = False,
version: str | None = None,
) -> Synthesis
Get a synthesis record by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
SynthesisId
|
The Synthesis ID to retrieve (format |
required |
include_recommendations
|
bool
|
When True, include reaction recommendations in the response. Defaults to False. |
False
|
include_predictions
|
bool
|
When True, include reaction predictions in the response. Defaults to False. |
False
|
version
|
str
|
A specific version of the record to retrieve. Defaults to the latest. |
None
|
Returns:
| Type | Description |
|---|---|
Synthesis
|
The fully populated synthesis record. |
Source code in src/albert/collections/synthesis.py
update_canvas_data
update_canvas_data(
*,
synthesis_id: SynthesisId,
smiles: str,
data: str,
png: str,
) -> Synthesis
Update the Ketcher canvas data for a synthesis record.
Use this to save the drawn reaction after editing it in the structure editor. It replaces the reaction SMILES, the serialized canvas, and the rendered preview image together.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
synthesis_id
|
SynthesisId
|
The Synthesis ID to update (format |
required |
smiles
|
str
|
The updated reaction SMILES string. |
required |
data
|
str
|
The serialized canvas data from the structure editor. |
required |
png
|
str
|
The base64-encoded PNG preview of the canvas. |
required |
Returns:
| Type | Description |
|---|---|
Synthesis
|
The updated synthesis record. |
Source code in src/albert/collections/synthesis.py
update
Update an existing synthesis record.
Fetch the record with get_by_id, modify the updatable fields on the
returned object, then pass it here. Only the fields listed in Notes are
sent; other differences are ignored. If nothing changed, the existing
record is returned unmodified.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
synthesis
|
Synthesis
|
The synthesis record containing updated fields. Its |
required |
Returns:
| Type | Description |
|---|---|
Synthesis
|
The updated synthesis record. |
Raises:
| Type | Description |
|---|---|
AlbertException
|
If the synthesis record is missing an ID. |
Notes
The following fields can be updated: name, status,
hide_reaction_worksheet.
Source code in src/albert/collections/synthesis.py
update_reactant_row_values
update_reactant_row_values(
*,
synthesis_id: SynthesisId,
row_id: str,
values: ReactantValues,
) -> Synthesis
Update the quantities for a single reactant row.
Sets the mass, moles, equivalents, and concentration for one row of the
reaction worksheet table. The row is identified by its row ID, which can be
read from Synthesis.reactants (each
ReactionParticipant has a row_id)
or from Synthesis.row_sequence.reactants.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
synthesis_id
|
SynthesisId
|
The Synthesis ID to update (format |
required |
row_id
|
str
|
The reactant row ID to update. |
required |
values
|
ReactantValues
|
The quantities to apply to the reactant row. |
required |
Returns:
| Type | Description |
|---|---|
Synthesis
|
The updated synthesis record. |
Source code in src/albert/collections/synthesis.py
create_reactant_productant_table
create_reactant_productant_table(
*, synthesis_id: SynthesisId
) -> Synthesis
Initialize the reactant/product table for a synthesis.
Sets up the reaction worksheet so quantities can be entered: it seeds the first reactant row (concentration 100), reveals the reaction worksheet, and attaches the backing inventory. If the table has already been initialized (the record already has an inventory ID) or there are no reactant rows to seed, the record is returned unchanged.
Call this after the reaction has been drawn (see
update_canvas_data) and before setting per-row quantities with
update_reactant_row_values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
synthesis_id
|
SynthesisId
|
The Synthesis ID to initialize (format |
required |
Returns:
| Type | Description |
|---|---|
Synthesis
|
The synthesis record with its reactant/product table initialized. |
Source code in src/albert/collections/synthesis.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |