Skip to content

Commit 503c6de

Browse files
committed
Two batches and loading to R incu locs
1 parent c1ff3ec commit 503c6de

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

cellpainter/cellpainter/protocol.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def out_get(self):
8080

8181
class Locations:
8282
HA = [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
83-
HB = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]
83+
HB = [21, 19, 17, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
8484
I = [i+1 for i in range(22)]
8585

8686
A: list[str] = [f'A{i}' for i in HA]
@@ -89,7 +89,17 @@ class Locations:
8989
Lid: list[str] = ['B19', 'B17']
9090
Incu: list[str] = [f'L{i}' for i in I] + [f'R{i}' for i in I]
9191
RT: list[str] = A[:21]
92-
Out: list[str] = A[:21] # 13:][::-1] + [b for b in B if b not in 'B21 B19 B17 B15'.split()][::-1]
92+
Out: dict[str, list[str]] = {
93+
'1 of 1': A[:21],
94+
'2 of 2': A[:17], # up to 17 plates, last batch goes to A
95+
'1 of 2': B[4:][::-1] + A[17:][::-1], # first batch goes to B then starts to fill A from below
96+
}
97+
98+
'''
99+
8,8: 4.5s
100+
10,10: 8.9s
101+
14,14: 114s
102+
'''
93103

94104
def initial_world(plates: list[Plate], p: ProtocolConfig) -> World:
95105
if p.steps and p.steps[0].name in ['Mito', 'PFA']:
@@ -99,14 +109,18 @@ def initial_world(plates: list[Plate], p: ProtocolConfig) -> World:
99109

100110
def define_plates(batch_sizes: list[int]) -> list[list[Plate]]:
101111

102-
if len(batch_sizes) > 1:
103-
raise ValueError('More than one batch is disabled after C hotel displaced')
104-
105112
plates: list[list[Plate]] = []
106113

107114
index = 0
108115
for batch_index, batch_size in enumerate(batch_sizes):
109116
assert batch_size > 0
117+
118+
out_key = f'{batch_index + 1} of {len(batch_sizes)}'
119+
Out = Locations.Out.get(out_key)
120+
# print(out_key, len(Out), Out)
121+
if not Out:
122+
raise ValueError(f'This configuration of batches, {out_key}, not defined. Try one of {", ".join(Locations.Out.keys())}.')
123+
110124
batch: list[Plate] = []
111125
rt = Locations.RT
112126
for index_in_batch in range(batch_size):
@@ -117,7 +131,7 @@ def define_plates(batch_sizes: list[int]) -> list[list[Plate]]:
117131
# lid_loc=Locations.Lid[index_in_batch],
118132
lid_loc=Locations.Lid[index_in_batch % 2],
119133
# lid_loc=Locations.Lid[0],
120-
out_loc=Locations.Out[index],
134+
out_loc=Out[index_in_batch],
121135
batch_index=batch_index,
122136
)]
123137
index += 1

cellpainter/cellpainter/small_protocols.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __getattr__(self, key: str):
8080
@ur_protocols.append
8181
def incu_load(args: SmallProtocolArgs):
8282
'''
83-
Load incubator from A hotel, starting at the bottom, to incubator positions L1, ...
83+
Load incubator from A hotel, starting at the bottom, to incubator positions L1, L2, ... or starting as specified in params
8484
8585
Required lab prerequisites:
8686
1. incubator transfer door: empty!
@@ -89,12 +89,20 @@ def incu_load(args: SmallProtocolArgs):
8989
4. robotarm: in neutral position by B hotel
9090
'''
9191
num_plates = args.num_plates
92+
starting_loc = ' '.join(args.params) or 'L1'
93+
incu_locs = []
94+
for _, focus, next in pbutils.iterate_with_full_context(Locations.Incu):
95+
if focus == starting_loc:
96+
incu_locs = [focus, *next]
97+
break
98+
if not incu_locs:
99+
raise ValueError(f'Cannot start from {starting_loc}, try for example L1 or R1')
92100
cmds: list[Command] = []
93101
world0: dict[str, str] = {}
94102
assert 1 <= num_plates <= 21, 'Number of plates should be in 1..21'
95-
assert num_plates <= len(Locations.A)
96-
assert num_plates <= len(Locations.Incu)
97-
for i, (incu_loc, a_loc) in enumerate(zip(Locations.Incu, Locations.A[::-1]), start=1):
103+
assert num_plates <= len(Locations.A), 'Too many plates'
104+
assert num_plates <= len(incu_locs), 'Too few incubator locations left'
105+
for i, (incu_loc, a_loc) in enumerate(zip(incu_locs, Locations.A[::-1]), start=1):
98106
if i > num_plates:
99107
break
100108
p = Plate(

0 commit comments

Comments
 (0)