STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Python Tutorial II Monty Python, Game of Life and Sequence Alignment Feb 1, 2011 Daniel.

Slides:



Advertisements
Similar presentations
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Advertisements

Dynamic Programming Nithya Tarek. Dynamic Programming Dynamic programming solves problems by combining the solutions to sub problems. Paradigms: Divide.
Programming project #2 1 CS502 Spring 2006 Programming Project #2 CS-502 Operating Systems Spring 2006.
Games as Emergent Systems first schema on “rules”.
Exercise 4 1. Write a program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. Let the program toss the.
Section 16.1: Basic Principles of Probability
Game of Life Rules and Games Linh Tran ECE 573. What is Life? Life is just one example of a cellular automaton, which is any system in which rules are.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Lec 18 Nov 12 Probability – definitions and simulation.
1 The Game of Life Supplement 2. 2 Background The Game of Life was devised by the British mathematician John Horton Conway in More sophisticated.
1 Chapter 13 Artificial Life: Learning through Emergent Behavior.
Recursion Introduction to Computing Science and Programming I.
Game of Life Changhyo Yu Game of Life2 Introduction Conway’s Game of Life  Rule Dies if # of alive neighbor cells =< 2 (loneliness) Dies.
© 2004 Goodrich, Tamassia Dynamic Programming1. © 2004 Goodrich, Tamassia Dynamic Programming2 Matrix Chain-Products (not in book) Dynamic Programming.
CS305j Introduction to Computing Two Dimensional Arrays 1 Topic 22 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right.
Project 1CS-4513, D-Term Programming Project #1 Concurrent Game of Life Due Friday, March 20.
Class 2: Basic Sequence Alignment
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Does not Compute 3: Awesomer Cellular Automata In which we consider how to upgrade our cellular automata A few key choices are considered, but eventually.
Variations of Conway’s Game of Life Eswar Kondapavuluri.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
AP ® Marine Biology Simulation Case Study Alyce Brady Kalamazoo College.
Independence and Dependence 1 Krishna.V.Palem Kenneth and Audrey Kennedy Professor of Computing Department of Computer Science, Rice University.
MOM! Phineas and Ferb are … Aims:
ECS 10 10/8. Outline Announcements Homework 2 questions Boolean expressions If/else statements State variables and avoiding sys.exit(…) Example: Coin.
Randomized Turing Machines
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
CS 484 – Artificial Intelligence1 Announcements Lab 4 due today, November 8 Homework 8 due Tuesday, November 13 ½ to 1 page description of final project.
1 Data Structures CSCI 132, Spring 2014 Lecture 3 Programming Principles and Life Read Ch. 1.
Recursion. Recursive Methods HAVE: 1.A base case or termination condition that causes the method to end 2.A non-base case whose actions move the algorithm.
Does not Compute 4: Finite Automata In which we temporarily admit defeat with cellular automata (we will face them again, in the epic final “Does Not Compute”
1.2 – Random Samples Simple Random Sample – Every sample of size n from the population has an equal chance of being selected – Every member of the population.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
1 Chapter 13 Artificial Life: Learning through Emergent Behavior.
The Game of Life A simulation of "life". From simple rules, complex behavior arises Rules –A cell that is alive and has fewer than two live neighbors dies.
Introduction to Lattice Simulations. Cellular Automata What are Cellular Automata or CA? A cellular automata is a discrete model used to study a range.
Topic 26 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable.
Cellular Automata. The Game The Game of Life is not your typical computer game. It is a 'cellular automation', and was invented by the Cambridge mathematician.
Parallel Programming 0024 Spring Semester 2010 May 6, 2010.
Programming Principles Chapter 1. Objectives Discuss the program design process. Introduce the Game of Life. Discuss object oriented design. – Information.
This week in CS 5 HW 9 (2 problems) M/T sections W/Th sections due Sunday, 11/4 at midnight due Monday, 11/5 at midnight Recitation for HW9 -- Friday 11/2.
Lecture21: Dynamic Programming Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Recursion Review: A recursive function calls itself, but with a smaller problem – at least one of the parameters must decrease. The function uses the results.
CS 121 Today Fractals and Turtles! The Koch Curve how random…
Sequence Comparison Algorithms Ellen Walker Bioinformatics Hiram College.
MATH CHALLENGE Challenge your mind!  Math is all around you in …  Nature  Art  Games  The following slides have links and puzzles for you.  Select.
C++ Programming Lecture 10 Functions – Part II
Loops Wrap Up 10/21/13. Topics *Sentinel Loops *Nested Loops *Random Numbers.
The Northern Lights: Demonstrations. Programmability Overview A major aspect of our project is programmability- it is an interactive display medium, the.
Basics on Probability Jingrui He 09/11/2007. Coin Flips  You flip a coin Head with probability 0.5  You flip 100 coins How many heads would you expect.
The Monty Hall Simulation
Introduction Lecture 25 Section 6.1 Wed, Mar 22, 2006.
Ionut Trestian Northwestern University
Independence and Dependence 1 Krishna.V.Palem Kenneth and Audrey Kennedy Professor of Computing Department of Computer Science, Rice University.
Great Theoretical Ideas in Computer Science for Some.
Microsoft produces a New operating system on a disk. There is 0
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
INTRO2CS Tirgul 8 1. Searching and Sorting  Tips for debugging  Binary search  Sorting algorithms:  Bogo sort  Bubble sort  Quick sort and maybe.
Ray Karol 2/26/2013. Let’s Make a Deal Monte Hall Problem Suppose you’re on a game show, and you’re given a choice of three doors: Behind one door is.
CS 121 Today Fractals and Turtles! The Koch Curve how random…
Introduction to Computing Science and Programming I
Discrete Probability Chapter 7 With Question/Answer Animations
WARM - UP The American Red Cross says that about 45% of the US Population has Type O blood, 40% Type A, 11% Type B, and the rest Type AB. a.) Selecting.
Random numbers What does it mean for a number to be random?
Random numbers What does it mean for a number to be random?
Probabilities and Proportions
Dynamic Programming II DP over Intervals
Random numbers What does it mean for a number to be random?
Presentation transcript:

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Python Tutorial II Monty Python, Game of Life and Sequence Alignment Feb 1, 2011 Daniel Fernandez and Alejandro Quiroz 1

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology 1 st ACT (1 hour) Random Module Monty Hall Game of Life Sequence Alignment INTERMISSION Chillout sessions (10 min) 2 nd ACT (1 hour 50 min) Homework help Q5, Q6, Q7 and Q8. 2

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Important Module: random MethodResult randint(x,y)Integer Random numbers between integer x and y rand()Random() distname(a,b)Uniform, Triangular, Gaussian, Lognormal, Negative, Exponential, Gamma, Beta, Pareto, Weibull choice(list)Choose an element from a list at random sample(list, k)Choose k elements from a list at random – without replacement! shuffle(list)Shuffles the element in list seed()Change the seed to generate random numbers

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Example. Simulate Flip of a Coin. import random coin = [‘heads’, ‘tails’] num_heads = 0 num_tails = 0 for i in range(0,1000): flip = random.choice(coin) if flip == ‘heads’: num_heads += 1 else: num_tails += 1 print ‘number of heads: ‘, num_heads print ‘number of heads: ‘, num_tails

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Monty Hall Problem Suppose you’re on a game show, and you’re given a choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say number 3, and the host, who knows what’s behind the doors, opens another door, say number 2, which has a goat. He says to you, ‘Do you want to pick door number 1?’ Is it to your advantage to switch your choice of doors? 5

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Monty Hall Problem Run montyhall.py to see the results. Read montyhall.py and try to understand what did the program do? Visual SimulationVisual Simulation. Python sourcePython source. 6 Solution: montyhall.py Usage: python montyhall.py

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Exercise 1. Read a fasta file. Write a python module for reading fasta files – add it to your utils.py module – if feeling lazy read q7 code. Solution: ex1_fasta.py Usage: from ex1_fasta import * 7

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Exercise 2. Complimentary DNA sequence and palindromic sequence Write a program that takes as an input a DNA sequence 5’ to 3’ and returns the same sequence 3’ to 5’ end (i.e., its reverse complement). Also make the program to output if the sequence is a palindromic sequence or not. HINT: _biology) Solution: ex2_complimentarydna.py Usage: python ex2_complimentarydna.py 8

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology9 Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works.

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Game of Life 10 Life is a "game" or cellular automaton developed by Conway. Instructions: Start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works.

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Game of Life Run the game of life (in the terminal) –First Install Jython Standard package into –Then add to your.bash_profile # For Jython export JYTHON_HOME=/Users/dfernan/bin/jython2.5.2/ export PATH=$JYTHON_HOME:$PATH export CLASSPATH=$JYTHON_HOME/jython.jar:$CLASSPATH –jython LifeGame.py 11 Solution: LifeGame.py (GridMutator.py) Usage: jython LifeGame.py

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology HH Question 5. Melting Temp 12

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology HH Question 5. Melting Temp 13 Usage: python q5.py q5_input.txt q5.output 20 55

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology HH Question 6. Longest Sequence Any ideas for retrieving the longest exact matching sequence between two sequences? How to read a fasta file? Write a function that takes a file name as an input and outputs a list containing each sequence in the fasta file. –If lazy, just look at homework q7. Solution: fasta.py, Q8_input.fasta Usage: Use it as a python module containing the fasta class and the read_fasta function 14

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Sequence Alignment 15 Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works. How many operations? _____

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Sequence Alignment 16 HOMOLOGOUSHOMOLOGOUS Paralogs Orthologous

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Sequence Alignment 17 Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works.

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology18 Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works. Align the following sequences and explain it. Bellow are the sequences and the match/mismatch (sub)BLOSUM matrix (HH1 and HH7) Sequence Alignment

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Sequence Alignment 19 Dynamic Programming: “The art of dividing a problem into simpler (sub)problems and then apply the sub-solutions recursively in order to obtain the final solution” Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works. i j New best alignment = Best previous alignment + align (i,j) How many operations? _____ Memory cost? _______

STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Sequence Alignment 20 Life is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules are: (i) if an empty cell has three neighbors, fill it next turn; (ii) if an occupied cell has zero or one neighbor, it dies of loneliness; and (iii) if an occupied cell has four or more neighbors, it dies of overcrowding. You can get really strange, unpredictable behavior out of very simple initial patterns, and many mathematicians have spent a lot of time thinking about how this works. Strategy: Align the two sequences. Read template code and think how to fill it in.