Chemotion Instance
The chemotion instance is the foundation of the the python chemtion client. It includes all methods to work with this tool.
- class chemotion_api.Instance(host_url: str)
The instance object is the core object of the Chemotion API. In order for the API to work, a connection to a Chmotion must first be established. an Instance object manges such a connection. To initializes an instance it needs the host URL of the chemotion server as a string.
- Parameters:
host_url – URL for the new
Requestobject
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")
- property all_element_classes: dict[str, dict[str, str]]
- This all_element_classes fetches all information about all elements such as
Sample, Reaction, Wellplate and Research plan and all generic elements
- Returns:
a dictionary which contains all information about all elements
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- property device_manager: DeviceManager
A DeviceManager instance
- Returns:
DeviceManager
- find_user_by_name(name: str) list[Person]
This find_user_by_name methode finds all user by name and returns the three top matches.
- Parameters:
name – Potential name or name snippet of a user
- Returns:
list u matching user
- Raises:
PermissionError – if the userdata cannot be fetched. Make sure that you are logged in.
- get_all_types() list[str]
Generates a list af all JSON LD types in the system. :return: List of JSON LD types
- get_generic_by_label(label: str, id: int) GenericElement
Fetches data of one Generic object from the Chemotion server. Which generic element type It automatically parses the data into a Python-Generic-Object. However, you need to know the correct internally used ID of the Generic element to be able to fetch it. Other methods to get Elements from Chemotion are accessible via the Collection objects
- Parameters:
label – The label of the Genetic Element
id – The Database ID of the desired Element
- Returns:
a Sample object
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- get_generic_by_name(name: str, id: int) GenericElement
Fetches data of one Generic object from the Chemotion server. Which generic element type It automatically parses the data into a Python-Generic-Object. However, you need to know the correct internally used ID of the Generic element to be able to fetch it. Other methods to get Elements from Chemotion are accessible via the Collection objects
- Parameters:
name – The name of the Genetic Element
id – The Database ID of the desired Element
- Returns:
a Sample object
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- get_json_ld_id(id: str) AbstractElement
Use python client internal JSON LD id to fetch element from Chemtion. :param id: JSON LD ID string starting with host url of the element :return: the requested element
- Raises:
ValueError – if the information cannot be fetched. Make sure that your connection is active and the ID is correct.
- get_reaction(id: int) Reaction
Fetches data of one Reaction object from the Chemotion server. It automatically parses the data into a Python-Reaction-Object. However, you need to know the correct internally used ID of the Reaction to be able to fetch it. Other methods to get Elements from Chemotion are accessible via the Collection objects
- Parameters:
id – The Database ID of the desired Element
- Returns:
a Reacton object
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- get_research_plan(id: int) ResearchPlan
Fetches data of one Research Plan object from the Chemotion server. It automatically parses the data into a Python-ResearchPlan-Object. However, you need to know the correct internally used ID of the Research Plan to be able to fetch it. Other methods to get Elements from Chemotion are accessible via the Collection objects
- Parameters:
id – The Database ID of the desired Element
- Returns:
a ResearchPlan object
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- get_root_collection(reload=True) RootCollection
The root collection can be compared to the all collection in the web client of Chemotion. Within this python client it is needed to navigate through all collections. A collection is foundtion of fetching and creating new elements.
- Parameters:
reload – If ture caned information are ignored
- Returns:
- get_sample(id: int) Sample
Fetches data of one Sample object from the Chemotion server. It automatically parses the data into a Python-Sample-Object. However, you need to know the correct internally used ID of the Sample to be able to fetch it. Other methods to get Elements from Chemotion are accessible via the Collection objects
- Parameters:
id – The Database ID of the desired Element
- Returns:
a Sample object
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- get_solvent_list() list[str]
Returns a list of all pre implemented solvents. :return: a list of all pre implemented solvents
- get_user() Admin | Person | Group | Device
This get_user methode initializes a new User object. The user object allows you to read and edit your user data.
- Returns:
a new User instance
- Raises:
PermissionError – if the userdata cannot be fetched. Make sure that you are logged in.
- get_wellplate(id: int) Wellplate
Fetches data of one Wellplate object from the Chemotion server. It automatically parses the data into a Python-Wellplate-Object. However, you need to know the correct internally used ID of the Wellplate to be able to fetch it. Other methods to get Elements from Chemotion are accessible via the Collection objects
- Parameters:
id – The Database ID of the desired Element
- Returns:
a Reacton object
- Raises:
RequestException – (requests.exceptions.RequestException) if the information cannot be fetched. Make sure that your connection is active and you are logged in.
- property host_url: str
The url as string of the instance
- Returns:
host URL
- login(user: str, password: str) TInstance
- This login methode allows you to log in to a chemotion instance.
To do this, you need a valid chemotion user (abbreviation name or e-mail) and password.
- Parameters:
user – abbreviation name or e-mail of a chemotion user
password – The password of the user
- Returns:
the instance itself
- Raises:
ConnectionError – if the logging was not successful.
- login_token(jwt_token: str) TInstance
You can use this login_token method to log in to a chemotion instance. To do this, you need a valid chemotion jwt token. This token can be generated using the get_token method.
- Parameters:
jwt_token – a Java Web Token.
- Returns:
the instance itself
- Raises:
ConnectionError – if the logging was not successful.
- molecule() MoleculeManager
Returns a MoleculeManager instance. This instance allows to create and fetch Molecules form the instance :return: a MoleculeManager instance
- test_connection() TInstance
This test_connection methode simply test if the connection to a chemotion instance can be established. The instance does not need to be logged in to use this methode.
- Returns:
the instance self
- Raises:
ConnectionError – if the connection cannot be established.
- property token: str
The token property returns the JWT (java web token)
- Returns:
JWT