
Python course in Bioinformatics by Katja Schuerer and Catherine Letondal Python course in Bioinformatics by Katja Schuerer and Catherine Letondal Copyright © 2002 Pasteur Institute [http://www.pasteur.fr/] Introduction to Python [http://www.python.org/] and Biopython [http://www.biopython.org/] with biological examples. The picture above represents the 3D structure of the Human Ferroxidase [http://srs.ebi.ac.uk/srs6bin/cgi- bin/wgetz?-id+4SU6q1IomZ3+-e+[SWALL:’CERU_HUMAN’]] protein, that we use in some of the exercises in this course. This course is designed for biologists who already have some programming knowledge, in other languages such as perl or C. For this reason, while presenting a substantial introduction to the Python language, it does not constitute an introduction to programming itself (as [Tis2001] or our course in informatics for biology [http://www.pasteur.fr/formation/infobio/infobio-en.html], with an online programming course [http://www.pasteur.fr/formation/infobio/python/] in Python). What distinguishes this course from general Python introductory courses, is however the important focus on biological examples that are used throughout the course, as well as the suggested exercises drawn from the field of biology. The second half of the course describes the Biopython (http://www.biopython.org/) set of modules. This course can be considered a complement to the Biopython tutorial, and what’s more often refers to it, by bringing practical exercises using these components. Contact: [email protected] [mailto:[email protected]] Comments are welcome. PDF version of this course [support.pdf] Table of Contents 1. General introduction ........................................................................ 1 1.1. Running Python ..................................................................... 1 1.2. Documentation ...................................................................... 2 1.2.1. General informations ......................................................... 2 1.2.2. Getting information ........................................................... 2 1.2.3. Making documentation ........................................................ 4 1.3. Working environment ................................................................ 4 1.3.1. Emacs ....................................................................... 4 2. Introduction to basic types in Python .......................................................... 7 2.1. Strings ............................................................................. 7 2.2. Lists .............................................................................. 10 2.3. Tuples ............................................................................. 13 2.4. Sequence types: Summary ........................................................... 15 2.4.1. Lists and Tuples ............................................................. 16 2.4.2. Xrange types ................................................................ 16 2.4.3. Strings and Unicode strings ................................................... 16 2.4.4. Buffers ..................................................................... 17 2.5. Dictionaries ........................................................................ 17 2.6. Numbers .......................................................................... 20 2.7. Type conversions ................................................................... 21 2.8. Files .............................................................................. 23 2.8.1. The print statement .......................................................... 25 3. Syntax rules ............................................................................... 27 3.1. Indentation ........................................................................ 27 3.1.1. Line structure ............................................................... 27 3.1.2. Block structure .............................................................. 27 3.2. Special objects ..................................................................... 28 4. Variables and namespaces .................................................................. 31 4.1. Variables .......................................................................... 31 4.1.1. Multiple assignments ........................................................ 32 4.2. Assignments, references and copies of objects ......................................... 32 4.3. Namespaces ....................................................................... 34 4.3.1. Accessing namespaces ....................................................... 35 5. Control flow .............................................................................. 39 5.1. Conditionals ....................................................................... 39 5.2. Loops ............................................................................. 40 5.2.1. while ....................................................................... 40 5.2.2. for ......................................................................... 41 5.2.3. More about loops ............................................................ 41 6. Functions ................................................................................. 45 6.1. Some definitions ................................................................... 45 6.2. Operators .......................................................................... 46 6.2.1. Order of evaluation .......................................................... 46 6.2.2. Object comparisons .......................................................... 47 6.2.3. (dot) operator .............................................................. 47 6.2.4. String formatting ............................................................ 47 6.3. Defining functions .................................................................. 48 6.4. Passing arguments to parameters ..................................................... 49 6.4.1. Reference arguments ......................................................... 49 6.4.2. Passing arguments by keywords ............................................... 50 6.5. Default values of parameters ......................................................... 51 6.6. Variable number of parameters ....................................................... 52 7. Functional programming or more about lists .................................................. 57 8. Exceptions ................................................................................ 59 8.1. General Mechanism ................................................................ 59 8.2. Python built-in exceptions ........................................................... 59 8.3. Raising exceptions .................................................................. 60 8.4. Defining exceptions ................................................................. 61 9. Modules and packages ..................................................................... 63 9.1. Modules ........................................................................... 63 9.1.1. Where are the modules? ..................................................... 63 9.1.2. Loading .................................................................... 64 9.2. Packages .......................................................................... 66 9.2.1. Loading .................................................................... 67 10. Classes: Using classes .................................................................... 71 10.1. Creating instances ................................................................. 71 10.2. Getting information on a class ...................................................... 72 11. Biopython: Introduction ................................................................... 75 11.1. Introduction ...................................................................... 75 11.2. Documentation .................................................................... 75 11.3. Bio.Seq and Bio.SeqRecord modules ................................................ 76 11.3.1. Using Seq class ............................................................ 77 11.3.2. Sequences reading and writing ............................................... 77 11.3.3. Bio classes for sequences ................................................... 78 11.4. Bio.SwissProt.SProt and Bio.WWW.ExPASy ......................................... 83 11.4.1. Reading entries ............................................................ 83 11.4.2. Regular expressions in Python ............................................... 84 11.4.3. Prosite .................................................................... 86 11.5. Bio.GenBank ..................................................................... 88 11.5.1. Reading entries ............................................................ 88 11.6. Running Blast and Clustalw ........................................................ 89 11.6.1. Blast ...................................................................... 89 11.6.2. Clustalw .................................................................. 91 11.6.3. Running other bioinformatics programs under Pise ............................. 93 12. Classes: Defining a new class .............................................................. 95 12.1. Basic class definition .............................................................. 95 12.2. Defining operators for classes ......................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages186 Page
-
File Size-