33from collections import defaultdict
44from dataclasses import dataclass
55from pathlib import Path
6+ import re
67from typing import Any
78
89import pandas as pd
1819from allotropy .parsers .utils .pandas import SeriesData
1920from allotropy .parsers .utils .uuids import random_uuid_str
2021
21- WELL_LABELS = ["A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" ]
22-
2322
2423@dataclass (frozen = True )
2524class Header :
@@ -38,6 +37,10 @@ def create(data: SeriesData) -> Header:
3837 )
3938
4039
40+ def _is_valid_well_label (label : str ) -> bool :
41+ return bool (re .match ("[A-Z]+" , label ))
42+
43+
4144@dataclass (frozen = True )
4245class PlateData :
4346 measurement_time : str
@@ -56,7 +59,7 @@ def create(
5659 ) -> PlateData :
5760 well_plate_id = header [str , "Barcode1" ].strip ("<>" )
5861 unique_well_labels = [
59- label for label in data .index .unique () if label in WELL_LABELS
62+ label for label in data .index .unique () if _is_valid_well_label ( label )
6063 ]
6164 spot_id = header .get (int , "SpotID" )
6265 well_data = [
@@ -70,7 +73,7 @@ def create(
7073 for row_name in unique_well_labels
7174 for row_index , (_ , row ) in enumerate (data .loc [[row_name ]].iterrows ())
7275 for col_name , value in row .items ()
73- if row_name in WELL_LABELS
76+ if _is_valid_well_label ( row_name )
7477 # Only include if the measurement is not an empty string, this skips blank entries for non-visible
7578 # measurements.
7679 if str (value ).strip ()
0 commit comments