clophfit.prtecan.parsers ======================== .. py:module:: clophfit.prtecan.parsers .. autoapi-nested-parse:: Prtecan/prtecan.py. Classes ------- .. autoapisummary:: clophfit.prtecan.parsers.Metadata Functions --------- .. autoapisummary:: clophfit.prtecan.parsers.read_xls clophfit.prtecan.parsers.lookup_listoflines clophfit.prtecan.parsers.strip_lines clophfit.prtecan.parsers.extract_metadata clophfit.prtecan.parsers.merge_md clophfit.prtecan.parsers.calculate_conc clophfit.prtecan.parsers.dilution_correction Module Contents --------------- .. py:function:: read_xls(path) Read first sheet of an xls file. :param path: Path to `.xls` file. :type path: Path :returns: Lines as list_of_lines. :rtype: list[list[str | int | float]] .. py:function:: lookup_listoflines(csvl: list[list[str]], pattern: str, col: int) -> list[int] 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. :param csvl: Lines (list_of_lines) of a csv/xls file. :type csvl: list[list[str | int | float]] | list[list[str]] :param pattern: Pattern to be searched (default="Label: Label"). :type pattern: str :param col: Column to search (default=0). :type col: int :returns: Row/line index for all occurrences of pattern. Empty list for no occurrences. :rtype: list[int] .. py:function:: strip_lines(lines) Remove empty fields/cells from lines read from a csv file. :param lines: Lines (list_of_lines) that are a list of fields, typically from a csv/xls file. :type lines: list[list[str | int | float]] :returns: Lines (list_of_lines) removed from blank cells. :rtype: list[list[str | int | float]] .. rubric:: Examples >>> lines = [ ... ["Shaking (Linear) Amplitude:", "", "", "", 2, "mm", "", "", "", "", ""] ... ] >>> strip_lines(lines) [['Shaking (Linear) Amplitude:', 2, 'mm']] .. py:class:: Metadata Represents the value of a metadata dictionary. :param value: The value for the dictionary key. :type value: int | str | float | None .. py:attribute:: unit :type: collections.abc.Sequence[str | float | int] | None :value: None The first element represents the unit, while the following elements are only listed. .. py:function:: 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]). :param lines: Lines (list_of_lines) that are a list of fields, typically from a csv/xls file. :type lines: list[list[str | int | float]] :returns: Metadata for Tecanfile or Labelblock. :rtype: dict[str, Metadata] .. rubric:: 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' .. py:function:: merge_md(mds) Merge a list of metadata dict if the key value is the same in the list. .. py:function:: calculate_conc(additions, conc_stock, conc_ini = 0.0) Calculate concentration values. additions[0]=vol_ini; Stock concentration is a parameter. :param additions: Initial volume and all subsequent additions. :type additions: Sequence[float] :param conc_stock: Concentration of the stock used for additions. :type conc_stock: float :param conc_ini: Initial concentration (default=0). :type conc_ini: float :returns: Concentrations as vector. :rtype: ArrayF .. py:function:: dilution_correction(additions) Apply dilution correction. :param additions: List of initial volume (index=0) followed by all additions. :type additions: list[float] :returns: Dilution correction vector. :rtype: ArrayF :raises ValueError: If additions list is empty or if initial volume is zero.