From 2a6ced12511f90e09e480b091691e141727f8ecb Mon Sep 17 00:00:00 2001 From: Emilia Allison Date: Tue, 22 Oct 2024 12:08:28 -0500 Subject: [PATCH] Initial --- .gitignore | 2 + sample_inputs/ZiathOutput001.json | 784 ++++++++++++++++++++++++++++++ util/ziath_to_tubes.py | 64 +++ 3 files changed, 850 insertions(+) create mode 100644 .gitignore create mode 100644 sample_inputs/ZiathOutput001.json create mode 100644 util/ziath_to_tubes.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..20dd724 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +output/ +**/__pycache__/ diff --git a/sample_inputs/ZiathOutput001.json b/sample_inputs/ZiathOutput001.json new file mode 100644 index 0000000..f3aad51 --- /dev/null +++ b/sample_inputs/ZiathOutput001.json @@ -0,0 +1,784 @@ +{ + "scanId": "679be0aa-e1ff-4cea-a743-276ff44ea74b", + "scanTime": 1729610672736, + "containerBarcode": "#container-barcode", + "scanTimeAnswer": null, + "containerName": "96 SBS rack", + "containerUid": "express96sbs", + "demoImage": null, + "containerGuid": "5a374e46-73c2-400e-9899-b9841f3941f5", + "rawImage": null, + "annotatedImage": null, + "linearReaderImage": null, + "tubeBarcode": [ + { + "row": 1, + "column": 1, + "barcode": "3574186167", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 1, + "column": 2, + "barcode": "3574186175", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 1, + "column": 3, + "barcode": "3574186183", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 1, + "column": 4, + "barcode": "3574186191", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 1, + "column": 5, + "barcode": "3574186199", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 1, + "column": 6, + "barcode": "3574186207", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 1, + "column": 7, + "barcode": "3574186215", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 1, + "column": 8, + "barcode": "3574186223", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 1, + "column": 9, + "barcode": "3574186231", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 1, + "column": 10, + "barcode": "3574186239", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 1, + "column": 11, + "barcode": "3574186247", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 1, + "column": 12, + "barcode": "3574186255", + "y": 437, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 2, + "column": 1, + "barcode": "3574186168", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 2, + "column": 2, + "barcode": "3574186176", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 2, + "column": 3, + "barcode": "3574186184", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 2, + "column": 4, + "barcode": "3574186192", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 2, + "column": 5, + "barcode": "3574186200", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 2, + "column": 6, + "barcode": "3574186208", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 2, + "column": 7, + "barcode": "3574186216", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 2, + "column": 8, + "barcode": "3574186224", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 2, + "column": 9, + "barcode": "3574186232", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 2, + "column": 10, + "barcode": "3574186240", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 2, + "column": 11, + "barcode": "3574186248", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 2, + "column": 12, + "barcode": "3574186256", + "y": 664, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 3, + "column": 1, + "barcode": "3574186169", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 3, + "column": 2, + "barcode": "3574186177", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 3, + "column": 3, + "barcode": "3574186185", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 3, + "column": 4, + "barcode": "3574186193", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 3, + "column": 5, + "barcode": "3574186201", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 3, + "column": 6, + "barcode": "3574186209", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 3, + "column": 7, + "barcode": "3574186217", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 3, + "column": 8, + "barcode": "3574186225", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 3, + "column": 9, + "barcode": "3574186233", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 3, + "column": 10, + "barcode": "3574186241", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 3, + "column": 11, + "barcode": "3574186249", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 3, + "column": 12, + "barcode": "3574186257", + "y": 892, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 4, + "column": 1, + "barcode": "3574186170", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 4, + "column": 2, + "barcode": "3574186178", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 4, + "column": 3, + "barcode": "3574186186", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 4, + "column": 4, + "barcode": "3574186194", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 4, + "column": 5, + "barcode": "3574186202", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 4, + "column": 6, + "barcode": "3574186210", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 4, + "column": 7, + "barcode": "3574186218", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 4, + "column": 8, + "barcode": "3574186226", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 4, + "column": 9, + "barcode": "3574186234", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 4, + "column": 10, + "barcode": "3574186242", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 4, + "column": 11, + "barcode": "3574186250", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 4, + "column": 12, + "barcode": "3574186258", + "y": 1119, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 5, + "column": 1, + "barcode": "3574186171", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 5, + "column": 2, + "barcode": "3574186179", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 5, + "column": 3, + "barcode": "3574186187", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 5, + "column": 4, + "barcode": "3574186195", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 5, + "column": 5, + "barcode": "3574186203", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 5, + "column": 6, + "barcode": "3574186211", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 5, + "column": 7, + "barcode": "3574186219", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 5, + "column": 8, + "barcode": "3574186227", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 5, + "column": 9, + "barcode": "3574186235", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 5, + "column": 10, + "barcode": "3574186243", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 5, + "column": 11, + "barcode": "3574186251", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 5, + "column": 12, + "barcode": "3574186259", + "y": 1347, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 6, + "column": 1, + "barcode": "3574186172", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 6, + "column": 2, + "barcode": "3574186180", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 6, + "column": 3, + "barcode": "3574186188", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 6, + "column": 4, + "barcode": "3574186196", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 6, + "column": 5, + "barcode": "3574186204", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 6, + "column": 6, + "barcode": "3574186212", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 6, + "column": 7, + "barcode": "3574186220", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 6, + "column": 8, + "barcode": "3574186228", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 6, + "column": 9, + "barcode": "3574186236", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 6, + "column": 10, + "barcode": "3574186244", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 6, + "column": 11, + "barcode": "3574186252", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 6, + "column": 12, + "barcode": "3574186260", + "y": 1574, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 7, + "column": 1, + "barcode": "3574186173", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 7, + "column": 2, + "barcode": "3574186181", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 7, + "column": 3, + "barcode": "3574186189", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 7, + "column": 4, + "barcode": "3574186197", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 7, + "column": 5, + "barcode": "3574186205", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 7, + "column": 6, + "barcode": "3574186213", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 7, + "column": 7, + "barcode": "3574186221", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 7, + "column": 8, + "barcode": "3574186229", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 7, + "column": 9, + "barcode": "3574186237", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 7, + "column": 10, + "barcode": "3574186245", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 7, + "column": 11, + "barcode": "3574186253", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 7, + "column": 12, + "barcode": "3574186261", + "y": 1802, + "decodeStatus": "SUCCESS", + "x": 390 + }, + { + "row": 8, + "column": 1, + "barcode": "3574186174", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 2892 + }, + { + "row": 8, + "column": 2, + "barcode": "3574186182", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 2665 + }, + { + "row": 8, + "column": 3, + "barcode": "3574186190", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 2437 + }, + { + "row": 8, + "column": 4, + "barcode": "3574186198", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 2210 + }, + { + "row": 8, + "column": 5, + "barcode": "3574186206", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 1982 + }, + { + "row": 8, + "column": 6, + "barcode": "3574186214", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 1755 + }, + { + "row": 8, + "column": 7, + "barcode": "3574186222", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 1527 + }, + { + "row": 8, + "column": 8, + "barcode": "3574186230", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 1300 + }, + { + "row": 8, + "column": 9, + "barcode": "3574186238", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 1072 + }, + { + "row": 8, + "column": 10, + "barcode": "3574186246", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 845 + }, + { + "row": 8, + "column": 11, + "barcode": "3574186254", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 617 + }, + { + "row": 8, + "column": 12, + "barcode": "3574186262", + "y": 2029, + "decodeStatus": "SUCCESS", + "x": 390 + } + ], + "orientationBarcode": [] +} diff --git a/util/ziath_to_tubes.py b/util/ziath_to_tubes.py new file mode 100644 index 0000000..1c568e5 --- /dev/null +++ b/util/ziath_to_tubes.py @@ -0,0 +1,64 @@ +import json +from sys import argv +from os import path, kill +from dataclasses import dataclass + + +@dataclass +class Tube: + barcode: str + 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) + + tubes = read_and_parse_ziath_json(input_file) + json_obj = tubes_to_tubes_json(tubes) + + with open(output_file, 'w') as file: + json.dump(json_obj, file) + + +def test_file(p: str) -> bool: + return path.exists(p) and path.isfile(p) + + +def read_and_parse_ziath_json(p: str) -> [Tube]: + with open(p, 'r') as file: + j = json.load(file) + + ziath_tubes = j["tubeBarcode"] + return [Tube(tube["barcode"], tube["row"], tube["column"]) + for tube in ziath_tubes] + + +def tubes_to_tubes_json(i: [Tube]) -> dict: + items_list = [] + target_positions_list = [] + + for tube in i: + items_list.append(tube.barcode) + target_positions_list.append((tube.row - 1) * 12 + + tube.col) + + output_obj = {} + output_obj["Items"] = [{"BarcodeValue": b} + for b in items_list] + output_obj["TargetPositions"] = [{"PositionIndex": p} + for p in target_positions_list] + + return output_obj + + +if __name__ == "__main__": + main()