High-level Programming with Python Expressions and Variables Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer.

Slides:



Advertisements
Similar presentations
CS 100: Roadmap to Computing Fall 2014 Lecture 0.
Advertisements

Types and Arithmetic Operators
 The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students.
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
Python November 14, Unit 7. Python Hello world, in class.
Variables, Expressions, and Statements
Chapter 2: Variables, Operations, and Strings CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
 The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students.
CS 100: Roadmap to Computing Fall 2014 Lecture 01.
Introduction to Python
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Computing with Numbers Zelle - Chapter 3 Charles Severance - Textbook: Python Programming: An Introduction to Computer Science, John.
 The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students.
Input, Output, and Processing
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
 The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students.
Python Conditionals chapter 5
MARC: Developing Bioinformatics Programs July 2009 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez 1 Essential Computing for Bioinformatics Lecture.
 The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students.
Copyright © – Curt Hill Types What they do.
Strings in Python. Computers store text as strings GATTACA >>> s = "GATTACA" s Each of these are characters.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
5 February 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
BING 6004: Intro to Computational BioEngineering Spring 2016 Lecture 1: Using Python Expressions and Variables Bienvenido Vélez UPR Mayaguez Reference:
Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning with Python 1 Introduction to Python programming for Bioinformatics.
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
Alex Ropelewski Pittsburgh Supercomputing Center National Resource for Biomedical Supercomputing Bienvenido Vélez
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.
MARC: Developing Bioinformatics Programs Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
MARC: Developing Bioinformatics Programs Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning.
CSCI 125 & 161 / ENGR 144 Lecture 6 Martin van Bommel.
1 A Short Introduction to Analyzing Biological Data Using Relational Databases Part II: Creating a Relational Database to Model Biological Data Alex Ropelewski.
MARC: Developing Bioinformatics Programs June 2012 Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist:
String and Lists Dr. José M. Reyes Álamo.
Using Molecular Biology to Teach Computer Science
Topics Designing a Program Input, Processing, and Output
CSc 120 Introduction to Computer Programing II Adapted from slides by
Using Molecular Biology to Teach Computer Science
Introduction to Python programming for biologists
CS 100: Roadmap to Computing
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Essential Computing for Bioinformatics
Presented By S.Yamuna AP/IT
Variables, Expressions, and Statements
Data types Numeric types Sequence types float int bool list str
Introduction to Programming
CS 100: Roadmap to Computing
String and Lists Dr. José M. Reyes Álamo.
Variables, Expressions, and Statements
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Variables, Expressions, and Statements
Strings in Python.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Introduction to Python Strings in Python Strings.
Introduction to Strings
Introduction to Programming
Introduction to C Programming
CS 100: Roadmap to Computing
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Presentation transcript:

High-level Programming with Python Expressions and Variables Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez Reference: How to Think Like a Computer Scientist: Learning with Python Essential Computing for Bioinformatics 1

The following material is the result of a curriculum development effort to provide a set of courses to support bioinformatics efforts involving students from the biological sciences, computer science, and mathematics departments. They have been developed as a part of the NIH funded project “Assisting Bioinformatics Efforts at Minority Schools” (2T36 GM008789). The people involved with the curriculum development effort include: Dr. Hugh B. Nicholas, Dr. Troy Wymore, Mr. Alexander Ropelewski and Dr. David Deerfield II, National Resource for Biomedical Supercomputing, Pittsburgh Supercomputing Center, Carnegie Mellon University. Dr. Ricardo González Méndez, University of Puerto Rico Medical Sciences Campus. Dr. Alade Tokuta, North Carolina Central University. Dr. Jaime Seguel and Dr. Bienvenido Vélez, University of Puerto Rico at Mayagüez. Dr. Satish Bhalla, Johnson C. Smith University. Unless otherwise specified, all the information contained within is Copyrighted © by Carnegie Mellon University. Permission is granted for use, modify, and reproduce these materials for teaching purposes. Most recent versions of these presentations can be found at

Integer Expressions 3 >>> print >>> print 6 * 7 42 >>> print 6 * >>> print * 7 44 >>> print >>> print 6 - ( 2 - 3) 7 >>> print 1 / 3 0 >>> / and * higher precedence than + and - integer division truncates fractional part Operators are left associative Parenthesis can override precedence

Floating Point Expressions 4 >>> print 1.0 / >>> print >>> print 3.3 * >>> print 3.3e23 * 2 6.6e+023 >>> print float(1) / >>> Mixed operations converted to float Scientific notation allowed 12 decimal digits default precision Explicit conversion

String Expressions 5 >>> print "aaa" aaa >>> print "aaa" + "ccc" aaaccc >>> len("aaa") 3 >>> len ("aaa" + "ccc") 6 >>> print "aaa" * 4 aaaaaaaaaaaa >>> "aaa" 'aaa' >>> "c" in "atc" True >>> "g" in "atc" False >>> + concatenates string len is a function that returns the length of its argument string any expression can be an argument * replicates strings a value is an expression that yields itself in operator finds a string inside another And returns a boolean result

MEANINGFUL Values Can Have (MEANINGFUL) Names 6 >>> numAminoAcids = 20 >>> eValue = 6.022e23 >>> prompt = "Enter a sequence ->" >>> print numAminoAcids 20 >>> print eValue 6.022e+023 >>> print prompt Enter a sequence -> >>> print "prompt" prompt >>> >>> prompt = 5 >>> print prompt 5 >>> = binds a name to a value prints the value bound to a name = can change the value associated with a name even to a different type use Camel case for compound names

Values Have Types 7 >>> type("hello") >>> type(3) >>> type(3.0) >>> type(eValue) >>> type (prompt) >>> type(numAminoAcids) >>> type is another function the type of a name is the type of the value bound to it the “type” is itself a value

In Bioinformatics Words … 8 >>> codon=“atg” >>> codon * 3 ’atgatgatg’ >>> seq1 =“agcgccttgaattcggcaccaggcaaatctcaaggagaagttccggggagaaggtgaaga” >>> seq2 = “cggggagtggggagttgagtcgcaagatgagcgagcggatgtccactatgagcgataata” >>> seq = seq1 + seq2 >>> seq 'agcgccttgaattcggcaccaggcaaatctcaaggagaagttccggggagaaggtgaagacggggagtggggagttgagtc gcaagatgagcgagcggatgtccactatgagcgataata‘ >>> seq[1] 'g' >>> seq[0] 'a' >>> “a” in seq True >>> len(seq1) 60 >>> len(seq) 120 First nucleotide starts at 0

More Bioinformatics Extracting Information from Sequences 9 >>> seq[0] + seq[1] + seq[2] ’agc’ >>> seq[0:3] ’agc’ >>> seq[3:6] ’gcc’ >>> seq.count(’a’) 35 >>> seq.count(’c’) 21 >>> seq.count(’g’) 44 >>> seq.count(’t’) 12 >>> long = len(seq) >>> pctA = seq.count(’a’) >>> float(pctA) / long * Find the first codon from the sequence get ’slices’ from strings: How many of each base does this sequence contain? Count the percentage of each base on the sequence.

Additional Note About Python Strings 10 >>> seq=“ACGT” >>> print seq ACGT >>> seq=“TATATA” >>> print seq TATATA >>> seq[0] = seq[1] Traceback (most recent call last): File " ", line 1, in seq[0]=seq[1] TypeError: 'str' object does not support item assignment seq = seq[1] + seq[1:] Can replace one whole string with another whole string Can NOT simply replace a sequence character with another sequence character, but… Can replace a whole string using substrings