Essential Computing for Bioinformatics

Slides:



Advertisements
Similar presentations
Roles of Variables with Examples in Scratch
Advertisements

Statement-Level Control Structures
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Essential Computing for Bioinformatics 1 Lecture.
LOOP / REPETITION while loop. for loop do/while loop We assume that loops are not meant to be infinite. That is, there should always be a way out of the.
Week 5 while loops; logic; random numbers; tuples Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except.
1 Essential Computing for Bioinformatics Bienvenido Vélez UPR Mayaguez Lecture 4 High-level Programming with Python Part I: Controlling the flow of your.
Python Control of Flow.
4. Python - Basic Operators
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
These materials were developed with funding from the US National Institutes of Health grant #2T36 GM to the Pittsburgh Supercomputing Center 1 
 The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students.
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
8 For-Statements © 2010 David A Watt, University of Glasgow Accelerated Programming 2 Part I: Python Programming 1.
Roles of Variables with Examples in Python ® © 2014 Project Lead The Way, Inc.Computer Science and Software Engineering.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
9/14/2015BCHB Edwards Introduction to Python BCHB Lecture 4.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
1 Looping Dale/Weems/Headington. 2 KA/JS/P Warning l Save your work often! l In the Khan Academy, JavaScript environment, infinite loops will lock up.
I NTRODUCTION TO PYTHON - GETTING STARTED ( CONT )
Introduction to Computing Using Python Repetition: the for loop  Execution control structures  for loop – iterating over a sequence  range() function.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Computer Science 101 For Statement. For-Statement The For-Statement is a loop statement that is especially convenient for loops that are to be executed.
1 Essential Computing for Bioinformatics Bienvenido Vélez UPR Mayaguez Lecture 3 High-level Programming with Python Part III: Files and Directories Reference:
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning with Python 1 Introduction to Python programming for Bioinformatics.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
 Python for-statements can be treated the same as for-each loops in Java Syntax: for variable in listOrstring: body statements Example) x = "string"
MARC: Developing Bioinformatics Programs Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning.
MARC: Developing Bioinformatics Programs June 2012 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Using Molecular Biology to Teach Computer Science High-level Programming with Python Finding Patterns.
High-level Programming with Python Expressions and Variables Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer.
MARC: Developing Bioinformatics Programs Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning.
MARC: Developing Bioinformatics Programs Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning.
PH2150 Scientific Computing Skills Control Structures in Python In general, statements are executed sequentially, top to bottom. There are many instances.
Bienvenido Vélez UPR Mayaguez Using Molecular Biology to Teach Computer Science 1 These materials were developed with funding from the US National Institutes.
MARC: Developing Bioinformatics Programs June 2012 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
Introduction to Python
Using Molecular Biology to Teach Computer Science
Chapter 6: Loops.
Using Molecular Biology to Teach Computer Science
Computer Programming Fundamentals
Lesson 05: Iterations Class Chat: Attendance: Participation
CS 115 Lecture 8 Structured Programming; for loops
Essential BioPython Retrieving Sequences from the Web
Repetition: the for loop
Iterations Programming Condition Controlled Loops (WHILE Loop)
While Loops.
Arrays, For loop While loop Do while loop
For & do/while Loops.
Arithmetic operations, decisions and looping
Python Primer 2: Functions and Control Flow
Example: Finding the Mode
Chapter (3) - Looping Questions.
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Python
Statement-Level Control Structures
For loops Taken from notes by Dr. Neil Moore
Introduction to Python
The structure of programming
Repetition: the for loop
Introduction to Computer Science
The structure of programming
Types of loops definite loop: A loop that executes a known number of times. Examples: Repeat these statements 10 times. Repeat these statements k times.
Thinking procedurally
REPETITION Why Repetition?
COMPUTING.
Introduction to Python
Presentation transcript:

Essential Computing for Bioinformatics High-level Programming with Python Iteration Over Sequences MARC: Developing Bioinformatics Programs Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning with Python

Essential Computing for Bioinformatics

Iterative Factorial Example def iterFact(n): result = 1 for i in xrange(1,n+1): result = result * i return result xrange(start,end,step) generates a sequence of values : The for loop is a somewhat less general iterative construct Every for can be written as a while, yet for loops tend to be easier to read and understand. For loops are recommended when we have an a priori list of values that we want to iterate over Examples of such lists of values are: Python lists or tuples Discrete ranges of integer numbers start = first value end = value right after last one step = increment These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Anatomy of the For Loop for <var> in <sequence>: <block> SYNTAX Repeat the execution of the <block> binding variable <var> to each element of the sequence SEMANTICS These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Complementing a DNA sequence Write a Python function that takes a DNA sequences as an parameter and returns its complement: Check validity of DNA sequence Repeat for each nucleotide in sequence Fetch the next nucleotide Find its DNA complement nucleotide Append the complement nucleotide to result sequence Return the complement sequence

Complementing a DNA sequence return result return True These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Complementing a DNA sequence from string import * DNANucleotides='acgt' DNAComplements='tgca' raise Exception (" Invalid DNA sequence: " + n) return (type(nucleotide) == type("") and len(nucleotide)==1 and nucleotide.lower() in DNANucleotides) These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center