Python Lab: Fundamentals Proteomics Informatics, Spring 2014 Week 3 11 th Feb, 2014

Slides:



Advertisements
Similar presentations
Introduction to Python Week 15. Try It Out! Download Python from Any version will do for this class – By and large they are all mutually.
Advertisements

Chapter 6 Lists and Dictionaries CSC1310 Fall 2009.
Intro to Python. Python is an interpreted language Can be used interactively Identifiers are case-sensitive Operators: + - * / ** Arbitrarily large integer.
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
DICTIONARIES. The Compound Sequence Data Types All of the compound data types we have studies in detail so far – strings – lists – Tuples They are sequence.
Python Lab Proteomics Informatics, Spring 2014 Week 1 28 th Jan, 2014 Himanshu Grover
What is a scripting language? What is Python?
Python: a modern hybrid A language for scripting and prototyping Balance between extensibility and powerful built-in data structures genealogy: –Setl (NYU,
Chapter 2 Writing Simple Programs
CSC 9010: Natural Language Processing
Python Control of Flow.
Python.
Programming for Linguists An Introduction to Python 17/11/2011.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
CIS Computer Programming Logic
Python Lab: Control Statements Conditionals, Loops, Iterations Proteomics Informatics, Spring 2014 Week 4 18 th Feb, 2014
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
CS1022 Computer Programming & Principles Lecture 1.2 A brief introduction to Python.
Python Lab Summary and Resources Proteomics Informatics, Spring 2014 Week nd Apr, 2014
 Expression Tree and Objects 1. Elements of Python  Literals, Strings, Tuples, Lists, …  The order of file reading  The order of execution 2.
If statements while loop for loop
Built-in Data Structures in Python An Introduction.
Python Lab Functions Proteomics Informatics, Spring 2014 Week 6 04 th Mar, 2014
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Dictionaries.   Review on for loops – nested for loops  Dictionaries (p.79 Learning Python)  Sys Module for system arguments  Reverse complementing.
An Introduction. What is Python? Interpreted language Created by Guido Van Rossum – early 90s Named after Monty Python
9/28/2015BCHB Edwards Basic Python Review BCHB Lecture 8.
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
Jim Havrilla. Invoking Python Just type “python –m script.py [arg]” or “python –c command [arg]” To exit, quit() or Control-D is used To just use the.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
Last Week Modules Save functions to a file, e.g., filename.py The file filename.py is a module We can use the functions in filename.py by importing it.
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.
Data Collections CS 127. Lists Lists are ordered sequences of items All programming languages provide a sequence structure similar to a Python list; in.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Guide to Programming with Python Chapter Five Lists and dictionaries (data structure); The Hangman Game.
A Tutorial on the Python Programming Language. Overview Running Python and Output Data Types Input and File I/O Control Flow Functions.
Chapter 10 Loops: while and for CSC1310 Fall 2009.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic.
I NTRODUCTION TO PYTHON - GETTING STARTED ( CONT )
Python Programing: An Introduction to Computer Science
Introduction to Programming Oliver Hawkins. BACKGROUND TO PROGRAMMING LANGUAGES Introduction to Programming.
PYTHON PROGRAMMING. WHAT IS PYTHON?  Python is a high-level language.  Interpreted  Object oriented (use of classes and objects)  Standard library.
Lists/Dictionaries. What we are covering Data structure basics Lists Dictionaries Json.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Indentations makes the scope/block Function definition def print_message (): print “hello” Function usages print_message () hubo.move ()// hubo is a class.
Section06: Sequences Chapter 4 and 5. General Description "Normal" variables x = 19 – The name "x" is associated with a single value Sequence variables:
Python Basics.
Introduction to python programming
Chapter 2 Writing Simple Programs
Introduction to Programming
CS1022 Computer Programming & Principles
Algorithmic complexity: Speed of algorithms
Think What will be the output?
Lecture 10 Data Collections
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
Introduction to Python
Introduction to Python
CS190/295 Programming in Python for Life Sciences: Lecture 6
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Algorithmic complexity: Speed of algorithms
Algorithmic complexity: Speed of algorithms
CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Presentation transcript:

Python Lab: Fundamentals Proteomics Informatics, Spring 2014 Week 3 11 th Feb, 2014

Programs perform computations – on some input data to generate some output according to a well-defined series of steps (algorithm) implemented using some programming language which follows a syntax

Data – Types & Values Fundamental “things” that programs work with (Data) Every data object has a type – Try in ipython shell: type(1), type(‘PEPTIDE’) Creation – from keyboard, files, remote server, through data processing Object TypeExample Creation Numbers (integers or floating- point/real-numbers) 10, , 22.7 Strings“Are you kidding?”, ‘This Python class rocks’ BooleanTrue, False …… ……

Variables Store for later use Assign data to variables – x = 2 – y=‘abc’ or “abc” – name = ‘Roger Federer’ – aa_sequence = “GAMRPODSTK” Use meaningful names

Operations Numbers: – Operators (Ex. *, /, +, -, ** etc. ) – Mathematical funcs (Ex. math.pow, math.sqrt) import math math.pow?, math.pow(10, 2) Strings (aa_seq = “GAMRPODSTK”) – Access: Indexing (forward and backward): x[2], x[-1]; index starts at 0 Slicing: aa_seq[0:3], aa_seq[1:], aa_seq[1:5:2], aa_seq[::2], x[::-1] – Concatenation: aa_seq + aa_seq, aa_seq + “MDP” – aa_sesq. (in ipython shell) – Repetition: aa_seq*8 – Membership: ‘G’ in aa_seq – aa_seq.find(‘E’), aa_seq.replace(“MR”, “NT”), aa_seq.lower(); len(x) Built-in vs. user-defined

Data Structures Containers for build composite/complex data objects Stored in a specific format, depending on data access and processing needs

Lists Most general sequence object Positionally ordered collection of arbitrarily typed objects: x = [1, ‘a’, [1,2,3]] – Heterogeneous – Arbitrarily nest-able Various operations: – Ex. x = [1,2,3,4,5] – Indexing, slicing etc. same as strings – Slice assignment: x[1:3] = [“replacement”, “string”] – Generic functions: len(x), type(x) – Type-specific functions: x.append(‘b’), x.pop(2), x.reverse(), x+y, x*3, x.extend([5,6,7]), x.sort()… x. to check the entire list

Dictionaries Unordered collection of mappings (key-value pairs) – Ex. y = {‘a’: 1, ‘b’: 2} – Ex. codon  AminoAcid – Ex. geneID  nucleotide sequence; protID  AminoAcid seq Keys must be unique Objects are accessed by ‘keys’ and not by relative position – y[‘a’] = 1 Heterogeneous, can be arbitrarily nested: rec = {'name': {'first': 'Bob', 'last': 'Smith'}, 'job': ['dev', 'mgr'], 'age': 30} Various operations: – Generic: len(y), type(y) – Type-specific: y.has_key(‘a’) or ‘a’ in y, y.update( ), y.keys(), y.values(), y.items()

Statements Assignment: thisIs = “Python Lecture 2” Function calls: x.reverse() where x is a list obj Print: print x, “\t”, y Select action: If : action 1 elif : action 2 else: action 3 Sequence Iteration (loops): for x in myList: action while X > Y: action/pass Building Functions: def add(x, y): return x+y Module access: import numpy from numpy import ndarray from matplotlib import pyplot as plt Exception Handling, OOP, global, del, exec, assert, documentation strings/comments etc. Indentation for compound statements

Getting help: Documentation IPython shell – x = [1,2,3,4] – x. – help(x), help(x. ), x. ? Ex. x.append? L.append(object) -- append object to end – Similar to f(x) notation in math. But more general…

Interactive vs. Script Mode

Practice some!! Create some data objects (list, dictionary string) in IPython shell Check their “types”, and explore documentation for some of the their operations/functions Run some functions to see what happens

Next Class Compound statements: – for/while loops Real examples