CS21 Lab 11: Bacteria colony

Due 11:59pm **Friday**, Apr 27 2012

Errata

There are a couple of errors in the lab files that you need to fix.

Option 1: If you have not started on the lab, simply remove bacterium.py and run update21 to get a fresh copy:

$ rm bacterium.py 
rm: remove regular file `bacterium.py'? y
$ update21
  Adding /home/asas/cs21/labs/11/bacterium.py
Option 2: Edit the bacterium.py file to fix the errors. First, hasTrait should add a self parameter:
def hasTrait(self, gene)
            -----
Second, the undraw() method needs to reset the drawn list on line 43:
  def undraw(self):
    """
    Undraws the bacterium from its current window
    """
    self.body.undraw()            #Undraw the cell
    curr = self.drawn.getHead()   #Undraw each spot 
    while curr != None:
      curr.getData().undraw()
      curr = curr.getNext()
   self.drawn = LinkedList()

Run update21, if you haven't already, to create the cs21/labs/11 directory. Then cd into your cs21/labs/11 directory and create the python programs for lab 11 in this directory (handin21 looks for your lab 11 assignments in your cs21/labs/11 directory).

$ update21
$ cd cs21/labs/11

Introduction

A common tool used in biology experiments is to alter the genomes or epigenomes of organisms to see the resulting effects. While early geneticists picked easily visible traits (e.g., flower color) to trace their experiments, most genes of interest do not have an easily visible phenotype. Instead, biologists often tag genes with small fragments that, when present and expressed , produce fluorescent colors. As a result, it becomes easy to identify if a certain gene is present/expressed by detecting if the organism gives off a fluorescence when exposed to ultraviolet light. The Nobel Prize in Chemistry for 2008 was award to a team of chemists who discovered and developed green flourescent proteins.

In this lab, you will simulate the creation of a new bacteria genome and visualize the results. You will complete a class, Bacterium that represents one bacterium object. The bacterium has a genome, which will be a linked list of all of the genes it contains. Each gene is tagged with a fluorescent marker so you can see what genes are present in the cell using graphics in python. Your main program is open ended - I want to see you design your own lab! Your program should allow a user to create several bacterium cells, add and remove genes multiple times, visualizing the changes over time. Below is a brief summary of the files in your directory:


The LinkedList Class

You should implement each class and test them before you move on to the next step.

A linked list represents a collection of items as a set of linked Node objects. The data maintained a linked list includes:

You should review your notes from class to ensure you understand the Node class and the major operations in the list interface. The methods for the LinkedList include: You must complete the test function at the bottom of the class and ensure your linked list works before moving on.

The Bacterium Class

The Bacterium class represents a bacterium cell and its genome. To avoid all the details of an actual genome (in other words, to abstract away the genome), we will use a simplistic representation of a cell. The genome will be a collection of genes. A gene, in turn, is identified simply by the color that it has been tagged with (e.g., yellow, blue, red). A bacterium cell is alive as long as it has some genes to work with, and dies if you try to draw the cell and it has no genes. The genome can grow to as large or as small as you desire, and can have many copies of the same gene. The bacterium can be drawn and undrawn from a graphical window. Each Bacterium object has:

You will need to implement some methods to complete the class:

I have provided a test main for this class to help you validate your implementation before moving in. It is by no means complete, so add more tests as you see fit. Here is the series of you images you should see in the window between mouse clicks (Note: there is some randomness in deleting genes, so your images may have different colors for the spots).

$ python bacterium.py

Removed a yellow gene

Removed a green gene
Removed a blue gene

$
Testing your classes with colony.py

Once you have tested the other classes, you should move on to implementing a main program. This portion of the assignment is largely open ended. I want to see you use your the design skills you have developed throughout the course to implement your own program. Feel free to implement additional methods in your Bacterium class if you need them. For example, it may be useful to have a zombify() method to bring you cell back to life. At a minimum, you should ensure your program does the following:

For example, you can create some cells and then give the user a menu of options such as:
  1. Draw the cells
  2. Undraw the cells
  3. Randomly delete genes from the colony
  4. Randomly (or selectively) insert some genes
  5. Report how many bacterium have a certain genotypic trait. Or how many copies of a gene are in each cell.
Feel free to ask myself or the ninjas for guidance if you want to do something but aren't sure about some of the details.

Submit

Once you are satisfied with your program, hand it in by typing handin21 in a terminal window.