Skip to content

Commit

Permalink
Interleave squid acquire from fridge
Browse files Browse the repository at this point in the history
  • Loading branch information
danr committed Feb 28, 2024
1 parent 1c2a00b commit ade4337
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cellpainter/cellpainter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def main():
def cmdline_to_log(cmdline: str):
cmdname = 'cellpainter'
print(cmdline, shlex.split(cmdline))
args, _ = arg.parse_args(Args, args=[cmdname, *shlex.split(cmdline)], exit_on_error=False)
args, _ = arg.parse_args(Args, args=[*shlex.split(cmdline)], exit_on_error=False)
pbutils.pr(args)
if args.log_file_for_visualize:
return Log.connect(args.log_file_for_visualize)
Expand Down
2 changes: 1 addition & 1 deletion cellpainter/cellpainter/gui/start_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def from_config(config: RuntimeConfig):
'1x5': {'project': '', 'plate': ''},
'1x3': {'project': 'sim', 'plate': 'S02'},
},
# **{f'3x{i}': {'project': 'sim', 'plate': f'T{i:03}'} for i in range(100)}
**{f'3x{i}': {'project': 'sim', 'plate': f'T{i:03}'} for i in range(100)}
},
last_barcode = f'PT{random.randint(0, 999999):06}',
squid_protocols = '''
Expand Down
43 changes: 36 additions & 7 deletions cellpainter/cellpainter/small_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,37 +988,66 @@ def squid_acquire_from_fridge(args: SmallProtocolArgs) -> Program:
raise ValueError('Specify some RT time. Example: "1800" for 30 minutes')
if not plates:
raise ValueError('Select some plates.')
ilv = Interleaving.init('''
fridge -> H13
H13 -> squid
fridge -> H13
squid -> fridge
H13 -> squid
fridge -> H13
squid -> fridge
H13 -> squid
squid -> fridge
''')
checks: list[Command] = []
chunks: dict[tuple[str, int], list[Command]] = {}
for i, plate in enumerate(plates, start=1):
protocol_path, project, barcode, name = plate.split(':')
assert_valid_project_name(project)
checks += [SquidStageCmd('check_protocol_exists', protocol_path).fork_and_wait()]
plus_secs = dict(enumerate(RT_time_secs, start=1)).get(i, RT_time_secs[-1])
cmds += [
chunks['fridge -> H13', i] = [
FridgeEject(plate=barcode, project=project, check_barcode=False).fork_and_wait(),
Checkpoint(f'RT {i}'),
PFCmd(f'fridge-to-H11'),
SquidStageCmd('goto_loading').fork_and_wait(),
PFCmd(f'H11-to-H13') if i > 1 else Noop(),
]
chunks['H13 -> squid', i] = [
SquidStageCmd('goto_loading').fork(),
PFCmd(f'H13-to-H11') if i > 1 else Noop(),
WaitForResource('squid'),
PFCmd(f'H11-to-squid'),

Seq(
SquidStageCmd('leave_loading'),
SquidStageCmd('goto_loading'), # go back and forth a few times
SquidStageCmd('leave_loading'), # go back and forth a few times
WaitForCheckpoint(f'RT {i}', plus_secs=plus_secs, assume='nothing'),
WaitForCheckpoint(f'Ok to start {i}', assume='nothing'),
SquidAcquire(protocol_path, project=project, plate=name),
).fork_and_wait(),

Checkpoint(f'Done {i}'),
).fork(),
]
chunks['squid -> fridge', i] = [
Checkpoint(f'Ok to start {i}'),
WaitForCheckpoint(f'Done {i}', assume='nothing'),
SquidStageCmd('goto_loading').fork_and_wait(),
PFCmd(f'squid-to-H11'),
SquidStageCmd('leave_loading').fork_and_wait(),
SquidStageCmd('leave_loading').fork(),
BarcodeClear(),
PFCmd(f'H11-to-fridge'),
FridgeInsert(
project,
assume_barcode=barcode,
).fork_and_wait(),
).fork(),
]
for i, substep in ilv.inst(list([i for i, _ in enumerate(plates, start=1)])):
chunk = Seq(*chunks[substep, i])
chunk = chunk.transform(lambda cmd: cmd.add(Metadata(plate_id=str(i))) if isinstance(cmd, SquidAcquire) else cmd)
if substep == 'squid -> fridge':
t = 10 * (i // 10)
name = f'({1 + t}-{10 + t})'
chunk = chunk.add(Metadata(section=name))
cmds += [chunk]
cmd = Seq(*checks, *cmds)
return Program(cmd)

Expand Down

0 comments on commit ade4337

Please sign in to comment.