Research Plan

class chemotion_api.elements.research_plan.ResearchPlan(*args, **kwargs)

A chemotion Research Plan object. It extends the chemotion_api.elements.abstract_element.AbstractElement

Usage:

>>> from chemotion_api import Instance
>>> from chemotion_api.collection import Collection
>>> from chemotion_api.elements.research_plan import Table
>>> 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 reaction with ID 1
>>> plan = instance.get_research_plan(1)
>>> # Add a table
>>> table: Table = plan.add_table()
>>> table.add_columns('Name')
>>> table.add_row('Martin')
>>> # Add a simple Text
>>> plan.add_richtext("Hallo")
>>> plan.save()
add_image(image_path: str) dict

Adds an image to the Research plan

Parameters:

image_path – file path to image

Returns:

body container

add_richtext(text: str) dict

Adds a text block to the Research plan

Parameters:

text – to be added

Returns:

body container

add_table() Table

Adds a new table to the Research plan

Returns:

Table object

property body

Body is list which contains the same values as the Properties. Each entry has a type and a value filed. The type can be one of: richtext, ketcher, table, image, sample or reaction

Returns:

List of body entries

class chemotion_api.elements.research_plan.Table(columns, rows)

Table is a dict subclass. It contains additional table management methods

Usage:

>>> from chemotion_api import Instance
>>> from chemotion_api.collection import Collection
>>> 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 reaction with ID 1
>>> plan = instance.get_research_plan(1)
>>> # Add a new Table
>>> table = plan.add_table()
>>> # Add a new column Name, age
>>> name_col_id, age_col_id = table.add_columns("Name", "Age")
>>> table.add_columns("Is Developer")
>>> table.add_row('Mr. X', False, **{age_col_id: 40}).add_row('Mr. Y')
>>> table.set_entry(1, age_col_id, 30)
>>> age_average = sum(table.get_column(age_col_id)) / len(table)
>>> print(f'Average age {age_average}')
>>> plan.save()
>>> plan_test = instance.get_research_plan(plan.id)
>>> table = plan_test.body[0]['value']
>>> age_average = sum(table.get_column(age_col_id)) / len(table)
>>> assert age_average == 35
>>> assert table.get_column(name_col_id) == ['Mr. X', 'Mr. Y']
add_columns(*labels: str) list[str]

Adds one or more columns to the table. It adds a column for each label give as an argument

Parameters:

labels – labels of columns to be added

Returns:

list of the column IDs

add_row(*entries, **placed_entries) Self

Adds row to the table. You can create the table empty or filled. To fill the fields, the values can be entered as named arguments or as arguments without a keyword. For named arguments, you must use the column id

Parameters:
  • entries – non-keyworded arguments entries

  • placed_entries – keyworded arguments entries

Returns:

Self

column_id_by_label(label: str) str

Finds a column ID of a column with a give label

Parameters:

label – Label of the column

Returns:

Column id

column_ids_by_labels(*labels: str) list[str]

Finds all column IDs of columns with a given labels

Parameters:

labels – Labels of the column

Returns:

Column id

get_column(column_id: str) list

Adds an entry to the table

Parameters:

column_id – the column ID

Returns:

a list of all values of one column

set_entry(row: int, column_id: str, value: any) Self

Sets an entry to the table

Parameters:
  • row – rwo idx starts with 0

  • column_id – the column ID

  • value – of the Entry

:return self