Using Molecular Biology to Teach Computer Science

Slides:



Advertisements
Similar presentations
ThinkPython Ch. 10 CS104 Students o CS104 n Prof. Norman.
Advertisements

Chapter 6 Lists and Dictionaries CSC1310 Fall 2009.
Python Mini-Course University of Oklahoma Department of Psychology Day 4 – Lesson 15 Tuples 5/02/09 Python Mini-Course: Day 4 – Lesson 15 1.
Tuples. Tuples 1 A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The only difference is that tuples can't be.
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.
1 Essential Computing for Bioinformatics Bienvenido Vélez UPR Mayaguez Lecture 5 High-level Programming with Python Part II: Container Objects Reference:
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
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 
10. Python - Lists The list is a most versatile datatype available in Python, which can be written as a list of comma-separated values (items) between.
Lists. The list is a most versatile datatype available in Python which can be written as a list of comma-separated values (items) between square brackets.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 8 Lists and Tuples.
Lists CS303E: Elements of Computers and Programming.
Introduction to Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
Python Mini-Course University of Oklahoma Department of Psychology Day 3 – Lesson 11 Using strings and sequences 5/02/09 Python Mini-Course: Day 3 – Lesson.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
Python Programing: An Introduction to Computer Science
Python Strings. String  A String is a sequence of characters  Access characters one at a time with a bracket operator and an offset index >>> fruit.
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.
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.
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:
String and Lists Dr. José M. Reyes Álamo.
Topic: Python Lists – Part 1
CMSC201 Computer Science I for Majors Lecture 14 – Tuples
Module 4 String and list – String traversal and comparison with examples, List operation with example, Tuples and Dictionaries-Operations and examples.
Using Molecular Biology to Teach Computer Science
Tuples and Lists.
Essential Computing for Bioinformatics
Essential BioPython Retrieving Sequences from the Web
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Strings
Introduction to Strings
Chapter 7: Strings and Characters
Lists in Python.
Chapter 8 More on Strings and Special Methods
Chapter 8 More on Strings and Special Methods
Data types Numeric types Sequence types float int bool list str
8 – Lists and tuples John R. Woodward.
4. sequence data type Rocky K. C. Chang 16 September 2018
Chapter 8 More on Strings and Special Methods
CEV208 Computer Programming
Lists A list is an ordered set of values, where each value is identified by an index. The values that make up a list are called its elements. Lists are.
String and Lists Dr. José M. Reyes Álamo.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Topics Sequences Introduction to Lists List Slicing
Basic String Operations
Introduction to Strings
CS1110 Today: collections.
15-110: Principles of Computing
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Topics Sequences Lists Copying Lists Processing Lists
By- Anshul Kumar Class: XI “B”
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Topics Basic String Operations String Slicing
Topics Sequences Introduction to Lists List Slicing
And now for something completely different . . .
Introduction to Strings
CMSC201 Computer Science I for Majors Lecture 16 – Tuples
Topics Basic String Operations String Slicing
By Himanshi dixit 11th ’B’
Introduction to Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Topics Basic String Operations String Slicing
Presentation transcript:

Using Molecular Biology to Teach Computer Science High-level Programming with Python Lists and Sequences Alex Ropelewski PSC-NRBSC Bienvenido Vélez UPR Mayaguez These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Essential Computing for Bioinformatics

List Values Homogeneous [10, 20, 30, 40] Lists ['spam', 'bungee', 'swallow'] ['hello', 2.0, 5, [10, 20]] [‘cga’, tgt’, ‘acc’] [] Lists can be heterogeneous and nested A List of DNA Sequences The empty list These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Generating Integer Lists >>> range(1,5) [1, 2, 3, 4] >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> range(1, 10, 2) [1, 3, 5, 7, 9] In General range(first,last+1,step) These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Accessing List Elements >>> sequences=['cga', 'tgt', 'acc’] >>> sequences[1] 'tgt’ >>> sequences[1:3] ['tgt', 'acc'] >>> words[-1] 'acc’ >>> ’tgt' in sequences True >>> sequences[0] = ’cct’ >>> sequences ['cct', 'tgt', 'acc'] Fetch an element slices negative index Testing List membership Lists are mutable These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

More List Expressions Slicing operator always returns a NEW list >>> numbers = range(1,5) >>> numbers[1:] [1, 2, 3, 4] >>> numbers[:3] [1, 2] >>> numbers[:] >>> [1,2,3] + [4,5,6] [1, 2, 3, 4, 5, 6] >>> Slicing operator always returns a NEW list These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Modifying Slices of Lists >>> list = ['a', 'b', 'c', 'd', 'e', 'f'] >>> list[1:3] = ['x', 'y'] >>> print list ['a', 'x', 'y', 'd', 'e', 'f'] >>> list[1:3] = [] ['a', 'd', 'e', 'f'] >>> list = ['a', 'd', 'f'] >>> list[1:1] = ['b', 'c'] ['a', 'b', 'c', 'd', 'f'] >>> list[4:4] = ['e'] ['a', 'b', 'c', 'd', 'e', 'f'] Replacing slices Deleting slices Inserting slices These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Lists are Special Types of Sequences Characteristics of Different Types of Python Sequences Type Description Elements Mutable StringType Character string Characters only no UnicodeType Unicode character string Unicode characters only no ListType List Arbitrary objects yes TupleType Immutable List Arbitrary objects no XRangeType return by xrange() Integers no BufferType Buffer return by buffer() arbitrary objects of one type yes/no These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center

Operations on Sequences Operator/Function Action Action on Numbers [ ], ( ), ' ' creation s + t concatenation addition s * n repetition n times multiplication s[i] indexation s[i:k] slice x in s membership x not in s absence for a in s traversal len(s) length min(s) return smallest element max(s) return greatest element These materials were developed with funding from the US National Institutes of Health grant #2T36 GM008789 to the Pittsburgh Supercomputing Center