clophfit.prtecan.parsers#

Prtecan/prtecan.py.

Classes#

Metadata

Represents the value of a metadata dictionary.

Functions#

read_xls(path)

Read first sheet of an xls file.

lookup_listoflines(…)

Lookup line numbers (row index) where given pattern occurs.

strip_lines(lines)

Remove empty fields/cells from lines read from a csv file.

extract_metadata(lines)

Extract metadata into both Tecanfile and Labelblock.

merge_md(mds)

Merge a list of metadata dict if the key value is the same in the list.

calculate_conc(additions, conc_stock[, conc_ini])

Calculate concentration values.

dilution_correction(additions)

Apply dilution correction.

Module Contents#

clophfit.prtecan.parsers.read_xls(path)#

Read first sheet of an xls file.

Parameters:

path (Path) – Path to .xls file.

Returns:

Lines as list_of_lines.

Return type:

list[list[str | int | float]]

clophfit.prtecan.parsers.lookup_listoflines(csvl: list[list[str]], pattern: str, col: int) list[int]#
clophfit.prtecan.parsers.lookup_listoflines(csvl: list[list[str | int | float]], pattern: str = 'Label: Label', col: int = 0) list[int]

Lookup line numbers (row index) where given pattern occurs.

Parameters:
  • csvl (list[list[str | int | float]] | list[list[str]]) – Lines (list_of_lines) of a csv/xls file.

  • pattern (str) – Pattern to be searched (default=”Label: Label”).

  • col (int) – Column to search (default=0).

Returns:

Row/line index for all occurrences of pattern. Empty list for no occurrences.

Return type:

list[int]

clophfit.prtecan.parsers.strip_lines(lines)#

Remove empty fields/cells from lines read from a csv file.

Parameters:

lines (list[list[str | int | float]]) – Lines (list_of_lines) that are a list of fields, typically from a csv/xls file.

Returns:

Lines (list_of_lines) removed from blank cells.

Return type:

list[list[str | int | float]]

Examples

>>> lines = [
...     ["Shaking (Linear) Amplitude:", "", "", "", 2, "mm", "", "", "", "", ""]
... ]
>>> strip_lines(lines)
[['Shaking (Linear) Amplitude:', 2, 'mm']]
class clophfit.prtecan.parsers.Metadata#

Represents the value of a metadata dictionary.

Parameters:

value (int | str | float | None) – The value for the dictionary key.

unit: collections.abc.Sequence[str | float | int] | None = None#

The first element represents the unit, while the following elements are only listed.

clophfit.prtecan.parsers.extract_metadata(lines)#

Extract metadata into both Tecanfile and Labelblock.

From a list of stripped lines takes the first field as the key of the metadata dictionary, remaining fields goes into a list of values with the exception of Label ([str]) and Temperature ([float]).

Parameters:

lines (list[list[str | int | float]]) – Lines (list_of_lines) that are a list of fields, typically from a csv/xls file.

Returns:

Metadata for Tecanfile or Labelblock.

Return type:

dict[str, Metadata]

Examples

>>> lines = [
...     ["Shaking (Linear) Amplitude:", "", "", "", 2, "mm", "", "", "", "", ""]
... ]
>>> extract_metadata(lines)
{'Shaking (Linear) Amplitude:': Metadata(value=2, unit=['mm'])}
>>> lines = [["", "Temperature: 26 °C", "", "", "", "", "", "", "", "", ""]]
>>> extract_metadata(lines)
{'Temperature': Metadata(value=26.0, unit=['°C'])}
>>> lines = [["Excitation Wavelength", "", "", "", 400, "nm", "", "", "", "", ""]]
>>> extract_metadata(lines)
{'Excitation Wavelength': Metadata(value=400, unit=['nm'])}
>>> lines = [["Label: Label1", "", "", "", "", "", "", "", "", "", "", "", ""]]
>>> extract_metadata(lines)
{'Label': Metadata(value='Label1', unit=None)}
>>> lines = [["Mode", "", "", "", "Fluorescence Top Reading", "", "", "", "", ""]]
>>> extract_metadata(lines)["Mode"].value
'Fluorescence Top Reading'
clophfit.prtecan.parsers.merge_md(mds)#

Merge a list of metadata dict if the key value is the same in the list.

Parameters:

mds (list[dict[str, Metadata]])

Return type:

dict[str, Metadata]

clophfit.prtecan.parsers.calculate_conc(additions, conc_stock, conc_ini=0.0)#

Calculate concentration values.

additions[0]=vol_ini; Stock concentration is a parameter.

Parameters:
  • additions (Sequence[float]) – Initial volume and all subsequent additions.

  • conc_stock (float) – Concentration of the stock used for additions.

  • conc_ini (float) – Initial concentration (default=0).

Returns:

Concentrations as vector.

Return type:

ArrayF

clophfit.prtecan.parsers.dilution_correction(additions)#

Apply dilution correction.

Parameters:

additions (list[float]) – List of initial volume (index=0) followed by all additions.

Returns:

Dilution correction vector.

Return type:

ArrayF

Raises:

ValueError – If additions list is empty or if initial volume is zero.