mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
Convert LH action to biomek.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# import requests
|
||||
# from typing import List, Sequence, Optional, Union, Literal
|
||||
import requests
|
||||
from typing import List, Sequence, Optional, Union, Literal
|
||||
|
||||
# from .liquid_handler_abstract import LiquidHandlerAbstract
|
||||
from .liquid_handler_abstract import LiquidHandlerAbstract
|
||||
|
||||
|
||||
|
||||
@@ -125,6 +125,8 @@ class LiquidHandlerBiomek(LiquidHandlerAbstract):
|
||||
sources: Sequence[Container],
|
||||
targets: Sequence[Container],
|
||||
tip_racks: Sequence[TipRack],
|
||||
solvent: Optional[str] = None,
|
||||
TipLocation: Optional[str] = None,
|
||||
*,
|
||||
use_channels: Optional[List[int]] = None,
|
||||
asp_vols: Union[List[float], float],
|
||||
@@ -145,27 +147,62 @@ class LiquidHandlerBiomek(LiquidHandlerAbstract):
|
||||
delays: Optional[List[int]] = None,
|
||||
none_keys: List[str] = []
|
||||
):
|
||||
# TODO:需要对好接口,下面这个是临时的
|
||||
self.temp_protocol["steps"].append({
|
||||
"type": "transfer",
|
||||
"sources": [source.to_dict() for source in sources],
|
||||
"targets": [target.to_dict() for target in targets],
|
||||
"tip_racks": [tip_rack.to_dict() for tip_rack in tip_racks],
|
||||
"use_channels": use_channels,
|
||||
"asp_vols": asp_vols,
|
||||
"dis_vols": dis_vols,
|
||||
"asp_flow_rates": asp_flow_rates,
|
||||
"dis_flow_rates": dis_flow_rates,
|
||||
"offsets": offsets,
|
||||
"touch_tip": touch_tip,
|
||||
"liquid_height": liquid_height,
|
||||
"blow_out_air_volume": blow_out_air_volume,
|
||||
"spread": spread,
|
||||
"is_96_well": is_96_well,
|
||||
"mix_stage": mix_stage,
|
||||
"mix_times": mix_times,
|
||||
"mix_vol": mix_vol,
|
||||
"mix_rate": mix_rate,
|
||||
"mix_liquid_height": mix_liquid_height,
|
||||
"delays": delays,
|
||||
})
|
||||
|
||||
transfer_params = {
|
||||
"Span8": False,
|
||||
"Pod": "Pod1",
|
||||
"items": {},
|
||||
"Wash": False,
|
||||
"Dynamic?": True,
|
||||
"AutoSelectActiveWashTechnique": False,
|
||||
"ActiveWashTechnique": "",
|
||||
"ChangeTipsBetweenDests": False,
|
||||
"ChangeTipsBetweenSources": False,
|
||||
"DefaultCaption": "",
|
||||
"UseExpression": False,
|
||||
"LeaveTipsOn": False,
|
||||
"MandrelExpression": "",
|
||||
"Repeats": "1",
|
||||
"RepeatsByVolume": False,
|
||||
"Replicates": "1",
|
||||
"ShowTipHandlingDetails": False,
|
||||
"ShowTransferDetails": True,
|
||||
"Solvent": "Water",
|
||||
"Span8Wash": False,
|
||||
"Span8WashVolume": "2",
|
||||
"Span8WasteVolume": "1",
|
||||
"SplitVolume": False,
|
||||
"SplitVolumeCleaning": False,
|
||||
"Stop": "Destinations",
|
||||
"TipLocation": "BC1025F",
|
||||
"UseCurrentTips": False,
|
||||
"UseDisposableTips": True,
|
||||
"UseFixedTips": False,
|
||||
"UseJIT": True,
|
||||
"UseMandrelSelection": True,
|
||||
"UseProbes": [True, True, True, True, True, True, True, True],
|
||||
"WashCycles": "1",
|
||||
"WashVolume": "110%",
|
||||
"Wizard": False
|
||||
}
|
||||
|
||||
items: dict = {}
|
||||
for idx, (src, dst) in enumerate(zip(sources, targets)):
|
||||
items[str(idx)] = {
|
||||
"Source": str(src),
|
||||
"Destination": str(dst),
|
||||
"Volume": asp_vols[idx]
|
||||
}
|
||||
transfer_params["items"] = items
|
||||
transfer_params["Solvent"] = solvent if solvent else "Water"
|
||||
transfer_params["TipLocation"] = TipLocation
|
||||
|
||||
if len(tip_racks) == 1:
|
||||
transfer_params['UseCurrentTips'] = True
|
||||
elif len(tip_racks) > 1:
|
||||
transfer_params["ChangeTipsBetweenDests"] = True
|
||||
|
||||
self.temp_protocol["steps"].append(transfer_params)
|
||||
|
||||
return
|
||||
|
||||
@@ -11,20 +11,23 @@ transfer_example = data[0]
|
||||
|
||||
|
||||
temp_protocol = []
|
||||
|
||||
TipLocation = "BC1025F" # Assuming this is a fixed tip location for the transfer
|
||||
sources = transfer_example["sources"] # Assuming sources is a list of Container objects
|
||||
targets = transfer_example["targets"] # Assuming targets is a list of Container objects
|
||||
tip_racks = transfer_example["tip_racks"] # Assuming tip_racks is a list of TipRack objects
|
||||
asp_vols = transfer_example["asp_vols"] # Assuming asp_vols is a list of volumes
|
||||
solvent = "PBS"
|
||||
|
||||
def transfer_liquid(
|
||||
#self,
|
||||
sources,#: Sequence[Container],
|
||||
targets,#: Sequence[Container],
|
||||
tip_racks,#: Sequence[TipRack],
|
||||
TipLocation,
|
||||
# *,
|
||||
# use_channels: Optional[List[int]] = None,
|
||||
asp_vols: Union[List[float], float],
|
||||
solvent: Optional[str] = None,
|
||||
# dis_vols: Union[List[float], float],
|
||||
# asp_flow_rates: Optional[List[Optional[float]]] = None,
|
||||
# dis_flow_rates: Optional[List[Optional[float]]] = None,
|
||||
@@ -44,6 +47,7 @@ def transfer_liquid(
|
||||
):
|
||||
# -------- Build Biomek transfer step --------
|
||||
# 1) Construct default parameter scaffold (values mirror Biomek “Transfer” block).
|
||||
|
||||
transfer_params = {
|
||||
"Span8": False,
|
||||
"Pod": "Pod1",
|
||||
@@ -52,7 +56,7 @@ def transfer_liquid(
|
||||
"Dynamic?": True,
|
||||
"AutoSelectActiveWashTechnique": False,
|
||||
"ActiveWashTechnique": "",
|
||||
"ChangeTipsBetweenDests": True,
|
||||
"ChangeTipsBetweenDests": False,
|
||||
"ChangeTipsBetweenSources": False,
|
||||
"DefaultCaption": "", # filled after we know first pair/vol
|
||||
"UseExpression": False,
|
||||
@@ -72,18 +76,16 @@ def transfer_liquid(
|
||||
"Stop": "Destinations",
|
||||
"TipLocation": "BC1025F",
|
||||
"UseCurrentTips": False,
|
||||
"UseDisposableTips": False,
|
||||
"UseDisposableTips": True,
|
||||
"UseFixedTips": False,
|
||||
"UseJIT": True,
|
||||
"UseMandrelSelection": True,
|
||||
"UseProbes": [True, True, True, True, True, True, True, True],
|
||||
"WashCycles": "3",
|
||||
"WashCycles": "1",
|
||||
"WashVolume": "110%",
|
||||
"Wizard": False
|
||||
}
|
||||
|
||||
# 2) Build the items mapping (source/dest/volume triplets).
|
||||
# Priority: user‑provided sources, targets, dis_vols.
|
||||
items: dict = {}
|
||||
for idx, (src, dst) in enumerate(zip(sources, targets)):
|
||||
items[str(idx)] = {
|
||||
@@ -92,24 +94,18 @@ def transfer_liquid(
|
||||
"Volume": asp_vols[idx]
|
||||
}
|
||||
transfer_params["items"] = items
|
||||
transfer_params["Solvent"] = solvent if solvent else "Water"
|
||||
transfer_params["TipLocation"] = TipLocation
|
||||
|
||||
if len(tip_racks) == 1:
|
||||
transfer_params['UseCurrentTips'] = True
|
||||
elif len(tip_racks) > 1:
|
||||
transfer_params["ChangeTipsBetweenDests"] = True
|
||||
|
||||
return transfer_params
|
||||
|
||||
# # 3) Set a readable caption using the first source/target if available.
|
||||
# if items:
|
||||
# first_item = next(iter(items.values()))
|
||||
# transfer_params["DefaultCaption"] = (
|
||||
# f"Transfer {first_item['Volume']} µL from "
|
||||
# f"{first_item['Source']} to {first_item['Destination']}"
|
||||
# )
|
||||
|
||||
# # 4) Append the fully‑formed step to the temp protocol.
|
||||
# self.temp_protocol.setdefault("steps", []).append({"transfer": transfer_params})
|
||||
|
||||
|
||||
|
||||
action = transfer_liquid(sources=sources,targets=targets,tip_racks=tip_racks)
|
||||
print(action)
|
||||
action = transfer_liquid(sources=sources,targets=targets,tip_racks=tip_racks, asp_vols=asp_vols,solvent = solvent, TipLocation=TipLocation)
|
||||
print(json.dumps(action,indent=2))
|
||||
# print(action)
|
||||
|
||||
|
||||
@@ -132,9 +128,9 @@ print(action)
|
||||
"Repeats": "1",
|
||||
"RepeatsByVolume": false,
|
||||
"Replicates": "1",
|
||||
"ShowTipHandlingDetails": false,
|
||||
"ShowTipHandlingDetails": true,
|
||||
"ShowTransferDetails": true,
|
||||
"Solvent": "Water",
|
||||
|
||||
"Span8Wash": false,
|
||||
"Span8WashVolume": "2",
|
||||
"Span8WasteVolume": "1",
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user