Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
import re
from typing import Any

import pandas as pd
Expand All @@ -18,8 +19,6 @@
from allotropy.parsers.utils.pandas import SeriesData
from allotropy.parsers.utils.uuids import random_uuid_str

WELL_LABELS = ["A", "B", "C", "D", "E", "F", "G", "H"]


@dataclass(frozen=True)
class Header:
Expand All @@ -38,6 +37,10 @@ def create(data: SeriesData) -> Header:
)


def _is_valid_well_label(label: str) -> bool:
return bool(re.match("[A-Z]+", label))


@dataclass(frozen=True)
class PlateData:
measurement_time: str
Expand All @@ -56,7 +59,7 @@ def create(
) -> PlateData:
well_plate_id = header[str, "Barcode1"].strip("<>")
unique_well_labels = [
label for label in data.index.unique() if label in WELL_LABELS
label for label in data.index.unique() if _is_valid_well_label(label)
]
spot_id = header.get(int, "SpotID")
well_data = [
Expand All @@ -70,7 +73,7 @@ def create(
for row_name in unique_well_labels
for row_index, (_, row) in enumerate(data.loc[[row_name]].iterrows())
for col_name, value in row.items()
if row_name in WELL_LABELS
if _is_valid_well_label(row_name)
# Only include if the measurement is not an empty string, this skips blank entries for non-visible
# measurements.
if str(value).strip()
Expand Down
Loading
Loading