Skip to content

Commit

Permalink
feat(abr-testing): add plate reader + tartrazine protocol (#16920)
Browse files Browse the repository at this point in the history
<!--
Thanks for taking the time to open a Pull Request (PR)! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

GitHub provides robust markdown to format your PR. Links, diagrams,
pictures, and videos along with text formatting make it possible to
create a rich and informative PR. For more information on GitHub
markdown, see:


https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview

Adds protocol that uses tartrazine and takes plate reader measurements

## Test Plan and Hands on Testing

- passed simulate test and runs on robot

## Changelog

- removed OT3 ABR Normalize with Tubes protocol
- added plate reader + tartrazine protocol

## Review requests

<!--
- What do you need from reviewers to feel confident this PR is ready to
merge?
- Ask questions.
-->

## Risk assessment

<!--
- Indicate the level of attention this PR needs.
- Provide context to guide reviewers.
- Discuss trade-offs, coupling, and side effects.
- Look for the possibility, even if you think it's small, that your
change may affect some other part of the system.
- For instance, changing return tip behavior may also change the
behavior of labware calibration.
- How do your unit tests and on hands on testing mitigate this PR's
risks and the risk of future regressions?
- Especially in high risk PRs, explain how you know your testing is
enough.
-->

---------

Co-authored-by: CaseyBatten <[email protected]>
  • Loading branch information
rclarke0 and CaseyBatten authored Nov 21, 2024
1 parent a166bc3 commit 49454f0
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 394 deletions.
7 changes: 6 additions & 1 deletion abr-testing/abr_testing/data_collection/abr_google_drive.py
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

0 comments on commit 49454f0

Please sign in to comment.