Sample

class chemotion_api.elements.sample.Sample(generic_segments: GenericSegments, session: Connection, json_data: dict | None = None, id: int | None = None, element_type: str | None = None)

A chemotion Sample object. It extends the chemotion_api.elements.abstract_element.AbstractElement

Usage:

>>> from chemotion_api import Instance
>>> import logging
>>> try:
>>>     instance = Instance('http(d)://xxx.xxx.xxx').test_connection().login('<USER>', "<PASSWORD>")
>>> except ConnectionError as e:
>>>     logging.error(f"A connection to Chemotion ({instance.host_url}) cannot be established")
>>> # Get the sample with ID 1
>>> s = instance.get_sample(1)
>>> # Set the real amount to 3.7 g
>>> s.properties["real_amount"]["value"] = 3.7
>>> s.properties["real_amount"]["unit"] = "g"
>>> # Set the boiling point range from 40 to 50
>>> s.properties["boiling_point_lowerbound"] = 40
>>> s.properties["boiling_point_upperbound"] = 50
>>> # Set the external label to "Sample_X334D"
>>> s.properties["external_label"] = "Sample_X334D"
>>> # Save the structure Image
>>> with open("./sample_structure.svg", "wb+") as f:
>>>     f.write(s.load_image().content)
>>> # Save the sample
>>> s.save()
load_image() Response

Loads the sample structure as svg image

Returns:

Response with the svg as content

property molecule: Molecule

The molecule of the sample

property properties: dict

The properties property contains all data which can be altered through the chemotion api from the main tab of the sample.

Key solvent:

{chemotion_api.elements.abstract_element.SolventList}

Key description:

{string}

Key external_label:

{str}

Key boiling_point_lowerbound:

{float}

Key boiling_point_upperbound:

{float}

Key melting_point_lowerbound:

{float}

Key melting_point_upperbound:

{float}

Key target_amount:

{dict} has a unit {str} (‘l’, ‘g’ or ‘mol’) and an amount {float}. The amount of the sample used as starting material or reactant.

Key molarity:

{dict} with value: float and unit: str

Key real_amount:

{dict} has a unit {str} (‘l’, ‘g’ or ‘mol’) and an amount {float}. The amount of sample obtained from a reaction.

Key stereo:

{str}

Key location:

{str}

Key is_top_secret:

{bool}

Key is_restricted:

{bool}

Key purity:

{float}

Key density:

{float}

Key user_labels:

{list}

Key decoupled:

{bool}

Key waste:

{bool}

Key metrics:

{str}

Key sum_formula:

{str}

Key equivalent:

{str}

Key coefficient:

{str}

Key reaction_description:

{str}

Readonly properties:

Key name:

{str, readonly}

Key short_label:

{str, readonly}

Returns:

Element properties

split()

Splits the sample.

Returns:

A new sample object

Return type:

chemotion_api.elements.sample.Sample

toggle_decoupled()

Decoupls the sample from the molecule

class chemotion_api.elements.sample.Molecule(data)

Contains the Molecule information. This class extents MutableMapping and can be used as normal dict object. However, it ensures that the following keys are set and used if the sample which contains the molecule is saved.

Key:

“boiling_point” {float}

Key:

“cano_smiles” {str}

Key:

“density” {float}

Key:

“inchikey” {str}

Key:

“inchistring” {str}

Key:

“melting_point” {float}

class chemotion_api.elements.sample.SolventList(session: Connection, *args)

In generale it contains a list of molecules. It allows to add molecules from the solvents list.

add_new_name(name: str)

Add a solvent from the solvent list by name

Parameters:

name – Solvent Name

add_new_smiles(smiles: str)

Add a solvent by smiles code

Parameters:

smiles – Smiles code