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