9781492346135
Python for Biologists: A complete programming course for beginners
by: Dr Martin Jones
ISBN-10: 1492346136
ISBN-13: 9781492346135
Edition 版次: 1
Publication Date 出版日期: 2013-09-07
Print Length 页数: 244
Learning to program is one of the best investments that you can make for your research and your career. Python for biologists is a complete programming course for beginners that will give you the skills you need to tackle common biological and bioinformatics problems.
Why learn programming?
Maybe you see colleagues writing programs to save time and deal with large datasets.
Maybe your supervisor has told you that you need to learn programming for your next project.
Maybe you’ve been looking at job ads and noticed just how many of them are asking for programming skills.
Table of contents
In chapter one,you’ll learn why Python is a good choice for biologists and beginners alike. You’ll also learn how to install Python for your operating system and how to set up your programming environment,complete with links to all the free software you’ll need.
In chapter two,you’ll learn how to manipulate text (including DNA and protein sequences) and how to fix errors in your programs. Exercises: calculating AT content,splicing introns.
In chapter three,you’ll learn how to read and write data to and from files. You’ll also learn how to deal with file paths and the FASTA file format.Exercises: splitting genomic DNA,writing a FASTA file.
In chapter four,you’ll learn how to process many pieces of data in a single program and more advanced tools for sequence manipulation. Exercises: trimming adapter sequences,concatenating exons.
In chapter five,you’ll learn how to make Python even more useful by creating your own functions,including the best ways to test those functions in order to speed up development. Exercises: Analyzing the amino acid composition of protein sequences.
In chapter six,you’ll learn how to write programs that can make smart decisions about how to handle data and how to make your programs follow complex rules. Exercises: filtering genes based on multiple criteria.
In chapter seven,you’ll learn an incredibly powerful tool for working with patterns in text – regular expressions – and how to use it to search in DNA and protein sequences. Exercises: filtering accession names and calculating restriction fragment sizes.
In chapter eight,you’ll learn how to store huge amounts of data in a way that can still allows it to be retrived very efficiently. This allows simplification of much of the code from previous chapters. Exercises: translating DNA sequences to protein.
In chapter nine,you’ll learn how to make your Python programs work in harmony with existing tools,and how to polish up your programs so that they’re ready for other people to use. Exercises: counting k-mers,binning DNA sequences by length.
Contents
About the author » ii
Preface » iii
1: Introduction and environment 1
Why have a programming book for biologists? » 1
Why Python? » 2
How to use this book » 5
Exercises and solutions » 7
Getting in touch » 8
Setting up your environment » 8
Text editors » 11
Reading the documentation » 12
2: Printing and manipulating text 13
Why are we so interested in working with text? » 13
Printing a message to the screen » 14
Quotes are important » 15
Use comments to annotate your code » 16
Error messages and debugging » 18
Printing special characters » 21
Storing strings in variables » 21
Tools for manipulating strings » 24
Recap » 34
Exercises » 36
Solutions » 39
3: Reading and writing files 52
Why are we so interested in working with files? » 52
Reading text from a file » 53
Files,contents and file names » 55
Dealing with newlines » 57
Missing files » 60
Writing text to files » 60
Closing files » 63
Paths and folders » 63
Recap » 64
Exercises » 65
Solutions » 67
4: Lists and loops 74
Why do we need lists and loops? » 74
Creating lists and retrieving elements » 76
Working with list elements » 77
Writing a loop » 79
Indentation errors » 82
Using a string as a list » 83
Splitting a string to make a list » 84
Iterating over lines in a file » 84
Looping with ranges » 85
Recap » 87
Exercises » 89
Solutions » 90
5: Writing our own functions 99
Why do we want to write our own functions? » 99
Defining a function » 100
Calling and improving our function » 103
Encapsulation with functions » 105
Functions don’t always have to take an argument » 106
Functions don’t always have to return a value » 108
Functions can be called with named arguments » 108
Function arguments can have defaults » 110
Testing functions » 111
Recap » 113
Exercises » 115
Solutions » 116
6: Conditional tests 121
Programs need to make decisions » 121
Conditions,True and False » 121
if statements » 124
else statements » 125
elif statements » 126
while loops » 128
Building up complex conditions » 128
Writing true/false functions » 130
Recap » 131
Exercises » 133
Solutions » 135
7: Regular expressions 141
The importance of patterns in biology » 141
Modules in Python » 143
Raw strings » 144
Searching for a pattern in a string » 145
Extracting the part of the string that matched » 150
Getting the position of a match » 152
Splitting a string using a regular expression » 153
Finding multiple matches » 154
Recap » 155
Exercises » 157
Solutions » 158
8: Dictionaries 168
Storing paired data » 168
Creating a dictionary » 173
Iterating over a dictionary » 179
Recap » 182
Exercises » 183
Solutions » 184
9: Files,programs,and user input 195
File contents and manipulation » 195
Basic file manipulation » 196
Deleting files and folders » 198
Listing folder contents » 198
Running external programs » 199
Running a program » 200
Saving program output » 201
User input makes our programs more flexible » 201
Interactive user input » 203
Command line arguments » 204
Recap » 205
Exercises » 207
Solutions » 208
Python for Biologists A complete programming course for beginners 9781492346135.epub
Python for Biologists A complete programming course for beginners 9781492346135.pdf