From 63925ec0ba3613a363e4be2e1d17e3415f264c1c Mon Sep 17 00:00:00 2001 From: Emilia Allison Date: Tue, 22 Oct 2024 16:21:00 -0500 Subject: [PATCH] Spelling utilities --- sample_inputs/E.csv | 65 +++++++++++++++++++++++++++++++++++ sample_inputs/H.csv | 57 ++++++++++++++++++++++++++++++ sample_inputs/O.csv | 65 +++++++++++++++++++++++++++++++++++ sample_inputs/R.csv | 61 ++++++++++++++++++++++++++++++++ sample_inputs/S.csv | 61 ++++++++++++++++++++++++++++++++ util/picklist_to_locations.py | 65 +++++++++++++++++++++++++++++++++++ 6 files changed, 374 insertions(+) create mode 100755 sample_inputs/E.csv create mode 100755 sample_inputs/H.csv create mode 100755 sample_inputs/O.csv create mode 100755 sample_inputs/R.csv create mode 100755 sample_inputs/S.csv create mode 100644 util/picklist_to_locations.py diff --git a/sample_inputs/E.csv b/sample_inputs/E.csv new file mode 100755 index 0000000..6ba17c5 --- /dev/null +++ b/sample_inputs/E.csv @@ -0,0 +1,65 @@ +SrcWell,DestWell,XferVol +A1,A1,2.5 +A2,A2,2.5 +B1,B1,2.5 +B2,B2,2.5 +C1,C1,2.5 +C2,C2,2.5 +D1,D1,2.5 +D2,D2,2.5 +E1,E1,2.5 +E2,E2,2.5 +F1,F1,2.5 +F2,F2,2.5 +G1,G1,2.5 +G2,G2,2.5 +H1,H1,2.5 +H2,H2,2.5 +A6,A1,2.5 +A7,A2,2.5 +B6,B1,2.5 +B7,B2,2.5 +C6,C1,2.5 +C7,C2,2.5 +D6,D1,2.5 +D7,D2,2.5 +E6,E1,2.5 +E7,E2,2.5 +F6,F1,2.5 +F7,F2,2.5 +G6,G1,2.5 +G7,G2,2.5 +H6,H1,2.5 +H7,H2,2.5 +A11,A1,2.5 +A12,A2,2.5 +B11,B1,2.5 +B12,B2,2.5 +C11,C1,2.5 +C12,C2,2.5 +D11,D1,2.5 +D12,D2,2.5 +E11,E1,2.5 +E12,E2,2.5 +F11,F1,2.5 +F12,F2,2.5 +G11,G1,2.5 +G12,G2,2.5 +H11,H1,2.5 +H12,H2,2.5 +G3,A1,2.5 +G4,A2,2.5 +G5,A3,2.5 +G6,A4,2.5 +G7,A5,2.5 +G8,A6,2.5 +G9,A7,2.5 +G10,A8,2.5 +H3,B1,2.5 +H4,B2,2.5 +H5,B3,2.5 +H6,B4,2.5 +H7,B5,2.5 +H8,B6,2.5 +H9,B7,2.5 +H10,B8,2.5 diff --git a/sample_inputs/H.csv b/sample_inputs/H.csv new file mode 100755 index 0000000..0dd57f9 --- /dev/null +++ b/sample_inputs/H.csv @@ -0,0 +1,57 @@ +SrcWell,DestWell,XferVol +A1,A1,2.5 +A2,A2,2.5 +A3,A3,2.5 +A4,A4,2.5 +A5,A5,2.5 +A6,A6,2.5 +A7,A7,2.5 +A8,A8,2.5 +A9,A9,2.5 +A10,A10,2.5 +A11,A11,2.5 +A12,A12,2.5 +B1,B1,2.5 +B2,B2,2.5 +B3,B3,2.5 +B4,B4,2.5 +B5,B5,2.5 +B6,B6,2.5 +B7,B7,2.5 +B8,B8,2.5 +B9,B9,2.5 +B10,B10,2.5 +B11,B11,2.5 +B12,B12,2.5 +G1,A1,2.5 +G2,A2,2.5 +G3,A3,2.5 +G4,A4,2.5 +G5,A5,2.5 +G6,A6,2.5 +G7,A7,2.5 +G8,A8,2.5 +G9,A9,2.5 +G10,A10,2.5 +G11,A11,2.5 +G12,A12,2.5 +H1,B1,2.5 +H2,B2,2.5 +H3,B3,2.5 +H4,B4,2.5 +H5,B5,2.5 +H6,B6,2.5 +H7,B7,2.5 +H8,B8,2.5 +H9,B9,2.5 +H10,B10,2.5 +H11,B11,2.5 +H12,B12,2.5 +C6,A1,2.5 +C7,A2,2.5 +D6,B1,2.5 +D7,B2,2.5 +E6,C1,2.5 +E7,C2,2.5 +F6,D1,2.5 +F7,D2,2.5 diff --git a/sample_inputs/O.csv b/sample_inputs/O.csv new file mode 100755 index 0000000..5e5e6d0 --- /dev/null +++ b/sample_inputs/O.csv @@ -0,0 +1,65 @@ +SrcWell,DestWell,XferVol +A1,A1,2.5 +A2,A2,2.5 +B1,B1,2.5 +B2,B2,2.5 +C1,C1,2.5 +C2,C2,2.5 +D1,D1,2.5 +D2,D2,2.5 +E1,E1,2.5 +E2,E2,2.5 +F1,F1,2.5 +F2,F2,2.5 +G1,G1,2.5 +G2,G2,2.5 +H1,H1,2.5 +H2,H2,2.5 +A3,A1,2.5 +A4,A2,2.5 +A5,A3,2.5 +A6,A4,2.5 +A7,A5,2.5 +A8,A6,2.5 +A9,A7,2.5 +A10,A8,2.5 +A11,A9,2.5 +A12,A10,2.5 +B3,B1,2.5 +B4,B2,2.5 +B5,B3,2.5 +B6,B4,2.5 +B7,B5,2.5 +B8,B6,2.5 +B9,B7,2.5 +B10,B8,2.5 +B11,B9,2.5 +B12,B10,2.5 +C11,A1,2.5 +C12,A2,2.5 +D11,B1,2.5 +D12,B2,2.5 +E11,C1,2.5 +E12,C2,2.5 +F11,D1,2.5 +F12,D2,2.5 +G11,E1,2.5 +G12,E2,2.5 +H11,F1,2.5 +H12,F2,2.5 +G3,A1,2.5 +G4,A2,2.5 +G5,A3,2.5 +G6,A4,2.5 +G7,A5,2.5 +G8,A6,2.5 +G9,A7,2.5 +G10,A8,2.5 +H3,B1,2.5 +H4,B2,2.5 +H5,B3,2.5 +H6,B4,2.5 +H7,B5,2.5 +H8,B6,2.5 +H9,B7,2.5 +H10,B8,2.5 diff --git a/sample_inputs/R.csv b/sample_inputs/R.csv new file mode 100755 index 0000000..af22775 --- /dev/null +++ b/sample_inputs/R.csv @@ -0,0 +1,61 @@ +SrcWell,DestWell,XferVol +G1,A1,2.5 +G2,A2,2.5 +G3,A3,2.5 +G4,A4,2.5 +G5,A5,2.5 +G6,A6,2.5 +G7,A7,2.5 +G8,A8,2.5 +G9,A9,2.5 +G10,A10,2.5 +G11,A11,2.5 +G12,A12,2.5 +H1,B1,2.5 +H2,B2,2.5 +H3,B3,2.5 +H4,B4,2.5 +H5,B5,2.5 +H6,B6,2.5 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2.5 +F11,F1,2.5 +F12,F2,2.5 +G11,G1,2.5 +G12,G2,2.5 +H11,H1,2.5 +H12,H2,2.5 +G3,A1,2.5 +G4,A2,2.5 +G5,A3,2.5 +H3,B1,2.5 +H4,B2,2.5 +H5,B3,2.5 +A8,A1,2.5 +A9,A2,2.5 +A10,A3,2.5 +B8,B1,2.5 +B9,B2,2.5 +B10,B3,2.5 diff --git a/util/picklist_to_locations.py b/util/picklist_to_locations.py new file mode 100644 index 0000000..fd5455d --- /dev/null +++ b/util/picklist_to_locations.py @@ -0,0 +1,65 @@ +import json +from sys import argv +from os import path, kill +from dataclasses import dataclass + + +@dataclass(frozen=True) +class Location: + row: int + col: int + + +def main(): + input_file = argv[1] + output_file = argv[2] + + if not test_file(input_file): + print("Input file does not exist") + kill(1) + if test_file(output_file): + print("Output file already exists") + kill(1) + + locations = read_input_csv_to_wells(input_file) + json_obj = tubes_to_tubes_json(locations) + + with open(output_file, 'w') as file: + json.dump(json_obj, file) + + +def read_input_csv_to_wells(p: str) -> [Location]: + with open(p, 'r') as file: + lines = file.readlines() + # Assume 96w format only + def get_first_col(line): return line.split(',')[0] + def get_row(x): return ord(x.upper()) - 64 + + def get_row_col(line: str) -> Location: + col = get_first_col(line)[1:] + row = get_row(get_first_col(line)[0]) + return Location(row, int(col)) + + return list(set([get_row_col(line) for line in lines[1:]])) + + +def tubes_to_tubes_json(i: [Location]) -> dict: + target_positions_list = [] + + for tube in i: + target_positions_list.append((tube.row - 1) * 12 + + tube.col) + + output_obj = {} + output_obj["TargetPositions"] = [{"PositionIndex": p} + for p in target_positions_list] + + return output_obj + + +def test_file(p: str) -> bool: + return path.exists(p) and path.isfile(p) + + +if __name__ == "__main__": + main()