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. |
search |
Search for synthesis records matching the given filters, returning lightweight hits. |
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
search
search(
*,
text: str | None = None,
created_by: str | list[str] | None = None,
created_by_name: str | list[str] | None = None,
smiles: str | list[str] | None = None,
product_created: str | list[str] | None = None,
chemical_name: str | list[str] | None = None,
cas: str | list[str] | None = None,
reactant_name: str | list[str] | None = None,
reactant_cas: str | list[str] | None = None,
product_name: str | list[str] | None = None,
product_cas: str | list[str] | None = None,
project_id: SearchProjectId
| list[SearchProjectId]
| None = None,
inventory_id: SearchInventoryId
| list[SearchInventoryId]
| None = None,
facet_text: str | None = None,
facet_field: str | None = None,
contains_field: str | list[str] | None = None,
contains_text: str | list[str] | None = None,
source_field: str | list[str] | None = None,
sort_by: str | None = None,
order: OrderBy | None = None,
max_items: int | None = None,
) -> Iterator[SynthesisSearchItem]
Search for synthesis records matching the given filters.
Returns lightweight
SynthesisSearchItem hits, best for
free-text lookups and pulling IDs. Results are returned as a lazily paginated
iterator. Pass a hit's ID to
get_by_id to fetch the
fully populated Synthesis.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against synthesis names and metadata. |
None
|
created_by
|
str or list[str]
|
Filter by creator user ID(s). |
None
|
created_by_name
|
str or list[str]
|
Filter by creator display name(s). |
None
|
smiles
|
str or list[str]
|
Filter by SMILES structure(s). |
None
|
product_created
|
str or list[str]
|
Filter by product-created flag(s). |
None
|
chemical_name
|
str or list[str]
|
Filter by chemical name(s). |
None
|
cas
|
str or list[str]
|
Filter by CAS number(s). |
None
|
reactant_name
|
str or list[str]
|
Filter by reactant name(s). |
None
|
reactant_cas
|
str or list[str]
|
Filter by reactant CAS number(s). |
None
|
product_name
|
str or list[str]
|
Filter by product name(s). |
None
|
product_cas
|
str or list[str]
|
Filter by product CAS number(s). |
None
|
project_id
|
SearchProjectId or list[SearchProjectId]
|
Filter by Project ID(s) (format |
None
|
inventory_id
|
SearchInventoryId or list[SearchInventoryId]
|
Filter by linked Inventory ID(s) (format |
None
|
facet_text
|
str
|
Text to match within a facet search. |
None
|
facet_field
|
str
|
Field to search within for facet filtering. |
None
|
contains_field
|
str or list[str]
|
Field(s) to apply a "contains" search to. |
None
|
contains_text
|
str or list[str]
|
Text value(s) for the "contains" search. |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned on each search hit. |
None
|
sort_by
|
str
|
Attribute to sort results by. |
None
|
order
|
OrderBy
|
The order in which to sort results ( |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matching items. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[SynthesisSearchItem]
|
A lazily paginated iterator of matching lightweight synthesis hits. |
Source code in src/albert/collections/synthesis.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
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
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |