@@ -141,10 +141,12 @@ async def __run_part1(self, scrapable_image_count, constants, output_directory):
141141 # Make the plate on which the wells reside.
142142 visit = "cm00001-1_otherstuff"
143143 created_crystal_plate_models = []
144+
145+ scrabable_barcode = "98ab"
144146 created_crystal_plate_models .append (
145147 CrystalPlateModel (
146148 formulatrix__plate__id = 10 ,
147- barcode = "98ab" ,
149+ barcode = scrabable_barcode ,
148150 visit = visit ,
149151 thing_type = CrystalPlateObjectThingTypes .SWISS3 ,
150152 )
@@ -183,8 +185,8 @@ async def __run_part1(self, scrapable_image_count, constants, output_directory):
183185 # This one gets scraped as normal.
184186 plate_directory1 = plates_directory / "98ab_2023-04-06_RI1000-0276-3drop"
185187 plate_directory1 .mkdir (parents = True )
186- for i in range (10 , 10 + scrapable_image_count ):
187- filename = plate_directory1 / ( "98ab_%03dA_1.jpg" % ( i ) )
188+ for i in range (scrapable_image_count ):
189+ filename = plate_directory1 / self . __subwell_filename ( scrabable_barcode , i )
188190 with open (filename , "w" ) as stream :
189191 stream .write ("" )
190192
@@ -195,8 +197,8 @@ async def __run_part1(self, scrapable_image_count, constants, output_directory):
195197 )
196198 plate_directory2 .mkdir (parents = True )
197199 nobarcode_image_count = 3
198- for i in range (10 , 10 + nobarcode_image_count ):
199- filename = plate_directory2 / ( "%s_%03dA_1.jpg" % (nobarcode_barcode , i ) )
200+ for i in range (nobarcode_image_count ):
201+ filename = plate_directory2 / self . __subwell_filename (nobarcode_barcode , i )
200202 with open (filename , "w" ) as stream :
201203 stream .write ("" )
202204
@@ -207,8 +209,8 @@ async def __run_part1(self, scrapable_image_count, constants, output_directory):
207209 )
208210 plate_directory3 .mkdir (parents = True )
209211 novisit_image_count = 6
210- for i in range (10 , 10 + novisit_image_count ):
211- filename = plate_directory3 / ( "%s_%03dA_1.jpg" % (novisit_barcode , i ) )
212+ for i in range (novisit_image_count ):
213+ filename = plate_directory3 / self . __subwell_filename (novisit_barcode , i )
212214 with open (filename , "w" ) as stream :
213215 stream .write ("" )
214216
@@ -219,8 +221,8 @@ async def __run_part1(self, scrapable_image_count, constants, output_directory):
219221 )
220222 plate_directory4 .mkdir (parents = True )
221223 excluded_image_count = 2
222- for i in range (10 , 10 + excluded_image_count ):
223- filename = plate_directory4 / ( "%s_%03dA_1.jpg" % (excluded_barcode , i ) )
224+ for i in range (excluded_image_count ):
225+ filename = plate_directory4 / self . __subwell_filename (excluded_barcode , i )
224226 with open (filename , "w" ) as stream :
225227 stream .write ("" )
226228
@@ -259,10 +261,8 @@ async def __run_part1(self, scrapable_image_count, constants, output_directory):
259261 ), "images after scraping"
260262
261263 # Make sure the positions got recorded right in the wells.
262- i = 10
263- for crystal_well_model in crystal_well_models :
264- assert crystal_well_model .position == "%03dA1" % (i )
265- i += 1
264+ assert crystal_well_models [0 ].position == "A01a"
265+ assert crystal_well_models [- 1 ].position == "H12d"
266266
267267 # The first "scrapable" plate directory should still exist.
268268 count = sum (1 for _ in plate_directory1 .glob ("*" ) if _ .is_file ())
@@ -305,3 +305,21 @@ async def __run_part2(self, scrapable_image_count, constants, output_directory):
305305 records = await xchembku .fetch_crystal_wells_filenames ()
306306
307307 assert len (records ) == scrapable_image_count , "images after restarting scraper"
308+
309+ # ----------------------------------------------------------------------------------------
310+
311+ def __subwell_filename (self , barcode , index ):
312+ """
313+ Make a subwell image name which can be parsed by swiss3.
314+ """
315+
316+ well_letters = "ABCDEFGH"
317+
318+ well = int (index / 3 )
319+ subwell = index % 3 + 1
320+ row = well_letters [int (well / 12 )]
321+ col = "%02d" % (well % 12 + 1 )
322+
323+ subwell_filename = f"{ barcode } _{ col } { row } _{ subwell } "
324+
325+ return subwell_filename
0 commit comments