A colony picker is an instrument that is used to automatically localize, pick up or duplicate microbial colonies that grow on a fixed or fluid medium. Usually, a Petri dish is inserted on the light plate of the colony picker, after which algorithms for image analysis choose the right colonies and a operate a robot arm to sample those colonies. Such appliances are used in both research laboratories and industrial surroundings, e.g. to analyze food or blood samples.

koloniepikker
Pickolo — an automatic colony picker that was installed as an extension of a Tecan robot shows a typical laboratory setup. On the light plate of the robot (below) a Petri dish is placed. The camera (above) takes pictures of the dish and image processing software chooses the right colonies for further treatment. A disposable tip (from the rack on the right) is used to touch a colony and carry it over to a collecting dish (bottom right). In a completely automatized setup a stacker (right) is used to process multiple dishes one after another.
Victoria amazonica
Every spot on the agar plate is a bacterial colony from the radius of a sponge. By the time a colony is visible for the human eye, it already consists of at least a million cells. Less than one percent of all bacteria can be grown in this manner in the laboratory, just to indicate how large the reservoir of unknown bacterial diversity still is. In order to map out the unknown bacteria, microbiologists use a combination of new growing techniques for molecular genetic characterization in order to research microbial communities.

The image processing software sees the photo of the Petri dish in the format of a bitmap. This is nothing but a rectangle grid of which the boxes are called bits because they can only take two forms. Every bit of the grid is either empty (represented by a space) or covered by a colony (represented by a hash: #). As an example you can see a bitmap below on which a number of colonies can be seen. In a bitmap, a colony is formed by an area of neighbouring covered bits. Bits are here called neighbouring if they have a side in common. However, the software will never see an area of neighbouring covered bits as a colony, if it contains bits on the outer rim of the bitmap.

bitmap van een petriplaat
Bitmap made of a Petri dish. This bitmap is a rectangluar grid with 20 rows and 60 columns, where the bits that are covered by bacterial colonies are indicates with hashes (#). This bitmap has six areas of neighbouring covered bits, but only five of those are seen as colonies, because one of them has bits that are on the outer rim of the bitmap.

Assignment

Define a class Petridish which can be used to analyze colonies on a Petri dish. the objects of this class must contain at least the following methods:

Example

In the example session below we assume that the text file dish.txt12 is situated in the current directory. This file contains the bitmap of a Petri dish that was graphically shown above.

>>> dish = Petridish('dish.txt')
>>> print(dish)
<BLANKLINE>
                         ###                                
                         #####                              
                         #######                            
                        #######                             
                         ######                             
                         ###### ##                          
                         ####  #####                        
                           ## ######        ####            
                        #    ######       ####              
                      ###  ##########    #####              
                    #######  ####  ##   ######              
                    ######### ##   #      #####             
          #           ####   ###          ###               
         #####        ####    #     ##     ##               
         #####                    ######    #               
        ######                   ########                   
         ####                     ########                  
                                  #######                   
                                  #######                   
>>> dish.colony(10, 35)
42
>>> print(dish)
<BLANKLINE>
                         ###                                
                         #####                              
                         #######                            
                        #######                             
                         ######                             
                         ###### ..                          
                         ####  .....                        
                           ## ......        ####            
                        #    ......       ####              
                      ###  ..........    #####              
                    #######  ....  ..   ######              
                    ######### ..   .      #####             
          #           ####   ...          ###               
         #####        ####    .     ##     ##               
         #####                    ######    #               
        ######                   ########                   
         ####                     ########                  
                                  #######                   
                                  #######                   
>>> dish.colony(10, 40)
Traceback (most recent call last):
AssertionError: no colony was found on position (10, 40)
>>> dish.colony(10, 45)
30
>>> print(dish)
<BLANKLINE>
                         ###                                
                         #####                              
                         #######                            
                        #######                             
                         ######                             
                         ###### ..                          
                         ####  .....                        
                           ## ......        ....            
                        #    ......       ....              
                      ###  ..........    .....              
                    #######  ....  ..   ......              
                    ######### ..   .      .....             
          #           ####   ...          ...               
         #####        ####    .     ##     ..               
         #####                    ######    .               
        ######                   ########                   
         ####                     ########                  
                                  #######                   
                                  #######                   
>>> dish.undo()
>>> print(dish)
<BLANKLINE>
                         ###                                
                         #####                              
                         #######                            
                        #######                             
                         ######                             
                         ###### ##                          
                         ####  #####                        
                           ## ######        ####            
                        #    ######       ####              
                      ###  ##########    #####              
                    #######  ####  ##   ######              
                    ######### ##   #      #####             
          #           ####   ###          ###               
         #####        ####    #     ##     ##               
         #####                    ######    #               
        ######                   ########                   
         ####                     ########                  
                                  #######                   
                                  #######                   
>>> dish.colonies()
5
>>> dish.colonysize()
32.2