Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(abr-testing): add plate reader + tartrazine protocol #16920

Merged
merged 8 commits into from
Nov 21, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def create_data_dictionary(
headers: List[str] = []
headers_lpc: List[str] = []
list_of_heights: List[List[Any]] = [[], [], [], [], [], [], [], []]
hellma_plate_orientation = False # default hellma plate is not rotated.
for filename in os.listdir(storage_directory):
file_path = os.path.join(storage_directory, filename)
if file_path.endswith(".json"):
Expand All @@ -67,6 +68,10 @@ def create_data_dictionary(
if run_id in runs_to_save:
print(f"started reading run {run_id}.")
robot = file_results.get("robot_name")
parameters = file_results.get("runTimeParameters", "")
for parameter in parameters:
if parameter["displayName"] == "Hellma Plate Orientation":
hellma_plate_orientation = bool(parameter["value"])
protocol_name = file_results["protocol"]["metadata"].get("protocolName", "")
software_version = file_results.get("API_Version", "")
left_pipette = file_results.get("left", "")
Expand Down Expand Up @@ -123,7 +128,7 @@ def create_data_dictionary(
file_results, labware_name="opentrons_tough_pcr_auto_sealing_lid"
)
plate_reader_dict = read_robot_logs.plate_reader_commands(
file_results, hellma_plate_standards
file_results, hellma_plate_standards, hellma_plate_orientation
)
list_of_heights = read_robot_logs.liquid_height_commands(
file_results, list_of_heights
Expand Down
72 changes: 41 additions & 31 deletions abr-testing/abr_testing/data_collection/read_robot_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ def liquid_height_commands(


def plate_reader_commands(
file_results: Dict[str, Any], hellma_plate_standards: List[Dict[str, Any]]
file_results: Dict[str, Any],
hellma_plate_standards: List[Dict[str, Any]],
orientation: bool,
) -> Dict[str, object]:
"""Plate Reader Command Counts."""
commandData = file_results.get("commands", "")
Expand Down Expand Up @@ -279,38 +281,46 @@ def plate_reader_commands(
read = "yes"
elif read == "yes" and commandType == "comment":
result = command["params"].get("message", "")
formatted_result = result.split("result: ")[1]
result_dict = eval(formatted_result)
result_dict_keys = list(result_dict.keys())
if len(result_dict_keys) > 1:
read_type = "multi"
else:
read_type = "single"
for wavelength in result_dict_keys:
one_wavelength_dict = result_dict.get(wavelength)
result_ndarray = plate_reader.convert_read_dictionary_to_array(
one_wavelength_dict
)
for item in hellma_plate_standards:
wavelength_of_interest = item["wavelength"]
if str(wavelength) == str(wavelength_of_interest):
error_cells = plate_reader.check_byonoy_data_accuracy(
result_ndarray, item, False
if "result:" in result:
plate_name = result.split("result:")[0]
formatted_result = result.split("result: ")[1]
print(formatted_result)
result_dict = eval(formatted_result)
result_dict_keys = list(result_dict.keys())
if len(result_dict_keys) > 1:
read_type = "multi"
else:
read_type = "single"
if "hellma_plate" in plate_name:
for wavelength in result_dict_keys:
one_wavelength_dict = result_dict.get(wavelength)
result_ndarray = plate_reader.convert_read_dictionary_to_array(
one_wavelength_dict
)
if len(error_cells[0]) > 0:
percent = (96 - len(error_cells)) / 96 * 100
for cell in error_cells:
print(
"FAIL: Cell " + str(cell) + " out of accuracy spec."
for item in hellma_plate_standards:
wavelength_of_interest = item["wavelength"]
if str(wavelength) == str(wavelength_of_interest):
error_cells = plate_reader.check_byonoy_data_accuracy(
result_ndarray, item, orientation
)
else:
percent = 100
print(
f"PASS: {wavelength_of_interest} meet accuracy specification"
)
final_result[read_type, wavelength, read_num] = percent
read_num += 1
read = "no"
if len(error_cells[0]) > 0:
percent = (96 - len(error_cells)) / 96 * 100
for cell in error_cells:
print(
"FAIL: Cell "
+ str(cell)
+ " out of accuracy spec."
)
else:
percent = 100
print(
f"PASS: {wavelength_of_interest} meet accuracy spec."
)
final_result[read_type, wavelength, read_num] = percent
read_num += 1
else:
final_result = result_dict
read = "no"
plate_dict = {
"Plate Reader # of Reads": read_count,
"Plate Reader Avg Read Time (sec)": avg_read_time,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ def parse_results_volume(
else:
print(f"Expected JSON object (dict) but got {type(json_data).__name__}.")
commands = {}

hellma_plate_orientation = False
parameters = json_data.get("runTimeParameters", "")
for parameter in parameters:
if parameter["displayName"] == "Hellma Plate Orientation":
hellma_plate_orientation = bool(parameter["value"])
start_time = datetime.fromisoformat(commands[0]["createdAt"])
end_time = datetime.fromisoformat(commands[len(commands) - 1]["completedAt"])
header = ["", "Protocol Name", "Date", "Time"]
Expand Down Expand Up @@ -283,7 +287,7 @@ def parse_results_volume(
temp_module_dict = read_robot_logs.temperature_module_commands(json_data)
thermo_cycler_dict = read_robot_logs.thermocycler_commands(json_data)
plate_reader_dict = read_robot_logs.plate_reader_commands(
json_data, hellma_plate_standards
json_data, hellma_plate_standards, hellma_plate_orientation
)
instrument_dict = read_robot_logs.instrument_commands(
json_data, labware_name=None
Expand Down Expand Up @@ -499,12 +503,12 @@ def check_params(protocol_path: str) -> str:
def get_extra_files(protocol_file_path: str) -> tuple[str, List[Path]]:
"""Get supporting files for protocol simulation if needed."""
params = check_params(protocol_file_path)
needs_files = input("Does your protocol utilize custom labware? (y/n): ")
needs_files = input("Does your protocol utilize custom labware? (Y/N): ")
labware_files = []
if needs_files == "y":
if needs_files == "Y":
num_labware = input("How many custom labware?: ")
for labware_num in range(int(num_labware)):
path = input("Enter custom labware definition: ")
path = input("Enter custom labware definition path: ")
labware_files.append(Path(path))
return (params, labware_files)

Expand Down
Loading
Loading