;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CSU211 Lab 6 - Trees with application in Pathology ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Author: Prof. Kathi Fisler, WPI ;; Edited: Matthias Felleisen ;; SOURCE ;; "Untangling the Roots of Cancer" by W. Wayt Gibbs. ;; Published in _Scientific American_, July 2003. #| Lab Motivation and Goals: This lab is designed to help you practice - programming with trees - using the random function - representing biological data as a progamming construct - using programs to simulate cancer experiments Background Information: Although cancer is one of the leading causes of death in the United States, research on the subject still has a long way to go before any cures might be discovered. Little is known about the causes of cancer, but there are several widely accepted theories. Previously, scientists believed that after an initial mutation into a malignant form, cancer cells essentially create clones of themselves within the tumors as they multiply. However, recent research has shown that this may not be the case. In fact, several studies have revealed that cancer cells within a tumor are very diverse, with many different mutations occuring simultaneously. In this lab, you will use Scheme programs to simulate and investigate mutations within malignant cancer tumors. You will need to consider the following six traits that distinguish cancer cells from normal cells: - Growth without "Go" signals (G) Normals cells wait for an external message before dividing, but cancer cells often create their own messages, causing them to multiply without external control. - Growth despite "Stop" commands (S) Under normal conditions, if one group of cells becomes too big, its neighbors send messages to stop the division of that group. Cancer cells have the ability to ignore these. - Evasion of built-in autodestruct mechanisms (A) In healthy cells, genetic damage can activate a self-destruct mechanism which destroys possibly dangerous cells. Without outside intervention, cancer cells can bypass these mechanisms and continue dividing. - Ability to construct blood vessels (B) Since tumors need oxygen and nutrients to survive, some cancer cells have the ability to stimulate construction of blood vessels through the growing mass. - Effective immortality (I) Normal cells can only divide approximately 70 times before dying, but since cancer cells need to divide much more than this to form a tumor, they work around systems that control reproductive limits. - Power to invade other tissues and spread to other organs (O) Cancer cells have the unique ability to move from one area of the body to another and continue multiplying, which is often life-threatening. Just like normal cells, each cancerous cell divides into two new cells. In order to keep track of mutations that occur as cancerous cells divide it is helpful to think of tumors as their history, a tree, with the original cell at the root. This way, it is possible to see how the cells mutate as they divide and the point where mutations happen in the big picture. To do this, we will use the following data definitions: |# ;; A CellGroup is either: ;; -- (make-cell number cancer-quality) ;; -- (make-cell-group cancer-quality CellGroup CellGroup) (define-struct cell (time factor)) (define-struct group (factor div1 div2)) ;; A (cancer)Quality is a ;; -- (make-cancer-quality Boolean Boolean Boolean ;; Boolean Boolean Boolean) (define-struct quality (G S A B I O)) ;; In this definition, time is the time it takes to divide ;; once, factor consists of the factors described ;; above, and div1 and div2 are the results of a cell's ;; division. ;; --------------------------------------------------------- ;; Exercises: ;; --------------------------------------------------------- ;; 1. Define a History of 4 normal cells (i.e. cells with ;; false for all cancer qualities) that take 20 minutes ;; to divide. ;; TODO: define the examples here... ;; --------------------------------------------------------- ;; 2. Develop a template for functions over cells. ;; TODO: write the templates (and use them later!!!) ;; --------------------------------------------------------- ;; 2a. Develop the functions flipG, flipS, flipA, flipB, ;; flipI, and flipO, which consumes and produce a ;; Quality and in the process "flip" the switch ;; for the respective property. ;; flipG : Quality -> Quality ;; flips the G field of q ;; TODO: define flipG... ;; flipS : Quality -> Quality ;; flips the S field of q ;; TODO: define flipS... ;; flipA : Quality -> Quality ;; flips the A field of q ;; TODO: define flipA... ;; flipB : Quality -> Quality ;; flips the B field of q ;; TODO: define flipB... ;; flipI : Quality -> Quality ;; flips the I field of q ;; TODO: define flipI... ;; flipO : Quality -> Quality ;; flips the O field of q ;; TODO: define flipO... ;; Takes ;; TODO: write at least two test cases... ;; --------------------------------------------------------- ;; 3. Develop the function count-cells, which consumes a ;; History and computes the number of cells that are ;; present. ;; count-cells: History -> Number ;; counts the number of cells in a group ;; TODO: define count-cells... ;; test cases: ;; TODO: write at least two test cases... ;; --------------------------------------------------------- ;; 4. For the experiments you will be performing, it will be ;; helpful to see if all the cells in a group ;; are healthy. Develop the function all-healthy?, which ;; consumes a cell-group and produces true if no cell has ;; any cancer-qualities. ;; all-healthy? : History -> Boolean ;; true if all cells in the cell-group are healthy ;; TODO: define all-healthy? ;; HINT: You may want a helper function! ;; test cases: ;; TODO: write at least two test cases... ;; --------------------------------------------------------- ;; Random: ;; Scheme has a built-in function called 'random'... find ;; out what it does by using the Help Desk. ;; TODO: Use the interactions window to experiment with ;; random and make some examples. ;; --------------------------------------------------------- ;; 5. Since cancer causes mutations in cells, you will need ;; to write a function that simulates random mutations. ;; Using Scheme's random function, write a function ;; called mutate which takes in a History and applies a ;; random mutation on all the cells in it. For this lab, ;; assume that there is a 50% chance that a mutation will ;; change one of the cancer qualities to true. ;; ;; Hint: The contract and purpose of the random function ;; are as follows: ;; random : (int -> int) ;; generates a random natural number less ;; than some given integer ;; ;; Since there are 6 cancer traits and 50% chance ;; that one will be changed to true, you may call ;; the function with an argument of 12. This way, ;; there will be a 50% chance that the number ;; returned will be between 0 and 6. Your function ;; should check whether a change is needed based on ;; this number, and should change one of the 6 ;; traits if necessary. ;; mutate : Cancer-group -> Cancer-group ;; applies one random mutation to the given cancer-group ;; TODO: define mutate... ;; HINT: use the helper function apply-mutation and local! ;; apply-mutation: Quality -> Quality ;; randomly flip one of the six qualities in qual ;; TODO: define apply-mutation... ;; Examples: ;; TODO: write at least two examples ;; why are these not test cases? ;; what could you test about the results? ;; --------------------------------------------------------- ;; 6. Develop the function grow-cells, which consumes a ;; History and produces a History in which each cell has ;; split once. Naturally, a splitting may create a mutated ;; cell. Use mutate to simulate the mutation. ;; grow-cells: History -> History ;; grows the cell-group over the given amount of time ;; TODO: define grow-cells... ;; Examples: ;; TODO: write at least two examples ;; why are these not test cases? ;; --------------------------------------------------------- ;; 7. Assume for this lab that a person's risk of developing ;; a malignant tumor is determined by how many cancerous ;; qualities are present in a cell sample from his body. ;; ;; (a) Write a function risk that takes in a cell-group ;; and returns the percent of cancer qualities that ;; are true among all its cells. ;; risk : History -> Number ;; returns the risk of malignant tumors of the cell sample ;; TODO: define risk... ;; HINT: use the helper functions you define below! ;; num-true : History -> Number ;; number of qualities true for the cells in the given group ;; TODO: define num-true... ;; num-true-quality: Quality -> Number ;; TODO: define num-true-quality... ;; bool-to-num: boolean -> number ;; returns 1 if the boolean is true, 0 if false ;; TODO: define bool-to-num... ;; (b) Use the function you just wrote to show that ;; as cells continue to multiply, a person's risk ;; for cancer becomes greater. ;; tests: (uncomment to test risk) ;(equal? (risk healthy-group) 0) ;(<= 0 (risk (mutate healthy-group)) 0.9) ;; if you can grow many times, develop this into a text ;; (risk (grow-cells healthy-group 100)) ;; " should be around " .167 ;; --------------------------------------------------------- ;; 8. You have discovered a new possible cancer treatment ;; and would like to simulate its effectiveness using ;; the tools you have written before testing it on live ;; subjects. Your treatment can stop cancer ;; from spreading into other parts of the body (O quality) ;; and it enforces a division limit so that the cancer ;; does not continue to grow infinitely (I Quality). ;; ;; (a) Write a function new-treatment, which takes in a ;; cancer-quality and makes all I and O qualities ;; false. ;; new-treatment : quality -> quality ;; changes all I and O qualities to true ;; TODO: define new-treatment... ;; Tests: ;; TODO: write at least two test cases... ;; (b) It is possible in Scheme to pass functions as ;; arguments. You do this just like all other ;; arguments, but you can apply the function to ;; other parts of your program. For example, ;; you may wish to write an ;; arithmetic function that takes two numbers ;; and applies some arithmetic operator on them ;; (such as +, -, *, or /). This function would ;; look like this: ;; ;; ;; arithmetic : ;; number number ;; (number number -> number) -> number ;; (define (arithmetic num1 num2 operator) ;; (operator num1 num2)) ;; ;; To call this you would use a statement like ;; (arithmetic 2 3 +). ;; ;; Develop the function apply-treatment, which ;; consumes a History and a treatment (a ;; function that consumes a cancer-quality and ;; changes it in some way); it applies the ;; treatment to all the cells in the given ;; history. ;; apply-treatment : group (quality -> quality) -> group ;; applies the given treatment to all cells in the group ;; TODO: define apply-treatment... ;; test cases: ;; TODO: write at least two test cases...