Difference between revisions of "Python for Biologists/C2/Introduction-to-Python-for-Biologists/English"
Line 92: | Line 92: | ||
'''Installation''' | '''Installation''' | ||
| style="background-color:#ffffff;border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| | | style="background-color:#ffffff;border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| | ||
− | * '''Python comes installed | + | * '''Python comes installed by default on Ubuntu.''' |
* IPython is an interactive terminal for Python | * IPython is an interactive terminal for Python | ||
* To install '''Python '''on '''Windows, Mac OS '''and '''Android '''devices, visit '''www.python.org''' | * To install '''Python '''on '''Windows, Mac OS '''and '''Android '''devices, visit '''www.python.org''' | ||
Line 103: | Line 103: | ||
Open the '''terminal by pressing '''Ctrl+Alt+T''' simultaneously. | Open the '''terminal by pressing '''Ctrl+Alt+T''' simultaneously. | ||
− | Python comes installed | + | Python comes installed by default on Ubuntu. |
− | In case you don't, then manually install the latest version of | + | In case you don't, then manually install the latest version of '''IPython''', |
+ | By typing | ||
'''sudo apt-get install ipython3''' | '''sudo apt-get install ipython3''' | ||
Line 112: | Line 113: | ||
Give root password if asked. | Give root password if asked. | ||
+ | |||
+ | |||
+ | |||
+ | |- | ||
+ | | style="background-color:#ffffff;border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| Type | ||
+ | |||
+ | '''sudo apt-get install ipython3''' | ||
+ | |||
+ | and press '''Enter.''' | ||
+ | | style="background-color:#ffffff;border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| | ||
+ | |||
+ | In case you don't, then manually install the latest version of '''IPython''', | ||
+ | By typing | ||
+ | |||
+ | '''sudo apt-get install ipython3''' | ||
+ | |||
+ | and press '''Enter.''' | ||
+ | |||
+ | Give root password if asked. | ||
+ | |||
+ | |||
|- | |- | ||
Line 125: | Line 147: | ||
− | Type''' ipython3 | + | Type''' ipython3 ''' and press '''Enter.''' |
|- | |- | ||
Line 132: | Line 154: | ||
Point to “>>>” symbol. | Point to “>>>” symbol. | ||
− | | style="background-color:#ffffff;border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| You will see few lines of information on '''Python '''like, the version number | + | | style="background-color:#ffffff;border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| You will see few lines of information on '''Python '''like, the version number. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | You will also see the '''IPython''' prompt on the terminal. | ||
Revision as of 18:00, 12 August 2014
Title of script: Introduction to Python for Biologists
Author: Trupti Rajesh Kini & Snehalatha
Keywords: video tutorial, Python, DNA seqences, Protein sequences, Biologists
Visual Cue | Narration |
Slide 1 | Welcome to the spoken-tutorial on Introduction to Python for Biologists. |
Slide 2
Learning Objectives |
In this tutorial we will learn,
|
Slide 3
System Requirements
|
To record this tutorial, I am using
|
Slide 4
Prerequisites
|
To practice this tutorial you should be familiar with,
You can also refer to Spoken Tutorials on Python for better understanding of this tutorial.
|
Slide 5
Why Python for biologists? |
Some of the features of Python useful for biologists are as follows:
|
Slide 6
Why Pyhton for biologists? |
Biopython, Modeller, chemopy, BLASTorage, Pymol
|
Slide 7
Installation |
|
Open terminal by pressing Ctrl+Alt+T at the same time. |
Open the terminal by pressing Ctrl+Alt+T simultaneously. Python comes installed by default on Ubuntu. In case you don't, then manually install the latest version of IPython, By typing sudo apt-get install ipython3 and press Enter. Give root password if asked.
|
Type
sudo apt-get install ipython3 and press Enter. |
In case you don't, then manually install the latest version of IPython, By typing sudo apt-get install ipython3 and press Enter. Give root password if asked.
|
Cursor on the terminal. | Wait for a few minutes for the installation to complete.
Note:Python3 does not overwrite the default Python on the system |
Open the terminal
Type ipython3 and press Enter. |
To check whether ipython3 is installed successfully on your system,
|
Cursor on the terminal
|
You will see few lines of information on Python like, the version number.
|
Cursor on terminal | Let's type a few simple Python commands with an example of a DNA sequence. |
Cursor on terminal | To begin with, we will store data, i.e DNA sequence in a variable called my_DNA. |
Slide 8
|
In Python language, data such as protein and DNA sequences are called as strings.
|
Type in the terminal,
my_DNA = "ATGCGCAT" Highlight my_DNA Press Enter |
Type,
my_DNA equal to ATGCGCAT within double quotes
|
Cursor on the panel. | We call this as assigning a variable. |
Cursor on the panel | For writing a code, we can use the variable name instead of the string itself. |
Type,
my_DNA and press Enter |
To print this sequence, type
my_DNA and press Enter. |
Highlight the output,
ATGCGCAT |
This will print the DNA sequence, ATGCGCAT within single quotes as it is a string. |
Cursor on the terminal. | Now let us print the sequence on two separate lines. |
Press up arrow
Add \n and DNA after ATGCGCAT . my_DNA = "ATGCGCAT\nDNA" Press Enter |
Press up arrow on the key board till we get this command on the terminal.
my_DNA = "ATGCGCAT” Lets edit this line. Type \n and DNA after ATGCGCAT within double quotes. Press Enter. |
Type,
print(my_DNA) and press Enter |
Type,
print(my_DNA) and press Enter.
|
Highlight the output
ATGCGCAT DNA |
The output prints the sequence on two separate lines as,
ATGCGCAT DNA
|
Slide 9
Assignment |
As an assignment,
<<PAUSE>> |
Cursor on the terminal | Let's go back to the terminal and learn a few more functions and methods. |
Another useful built-in tool in Python is the len function.
| |
Press up arrow key
my_DNA = "ATGCGCAT" |
Press up arrow on the key board till we get this command on the terminal.
my_DNA = "ATGCGCAT” Press Enter |
Type:
len(my_DNA) |
To find the length of the DNA sequence in a variable, type,
len within brackets my_DNA
|
Cursor on the terminal | The output on the screen shows the number 8.
|
Slide 10
|
Another assignment for you
|
Lets go back to the terminal | |
Many times in biochemistry, sequences are represented either in lowercase or uppercase alphabets.
| |
Type protein =” ”
Press Enter Type my_DNA.lower() Press Enter. |
To convert the uppercase alphabets in a string to lowercase:
We make use of lower() method. Type, my_DNA=”ATGCGCAT”. Press Enter Then type, my_DNA.lower(). In a method, we write,
Press Enter. |
Highlight 'atgcgcat' | The output shows the string in lowercase. |
Slide 11
Assignment |
As an assignment,
Using example of a short protein sequence: cnltftwpeadfypi Convert the sequence to uppercase. Hint: Use upper() method. |
Back to terminal again | |
Type
my_protein = "alspadkanl" |
Lets take an example of an amino acid sequence.
Store it in a variable called protein my_protein = "alspadkanl"
|
Cursor on the terminal | To find out the number of times an amino acid or a sequence of amino acids occurs in a string.
We make use of count function
|
Type
my_protein.count ('a')
|
For example to know the number of times amino acid Alanine occurs in the string
my_protein.count ('a')
|
Cursor on the terminal | Output shows number 3.
There are 3 Alanines in the string.
|
Type
my_protein.count('l') Press enter |
Similarly to find number of Leucines in the string
Type my_protein.count('l') Press enter
|
Cursor on the terminal | We get an output as 2, there are 2 Leucines in the string. |
Cursor on the terminal | Similarly we can use DNA or an RNA sequence as string to count the ocurrences of basepairs . |
Slide 12
Summary
|
Let us summarize,
In this tutorial we have learnt:
examples of DNA and Protein sequences.
|
Slide 13
Summary |
* Find the length of the string
|
Slide 13
Assignment |
Here is an assignment,
Calculate GC content in the given DNA sequence. 'ATGGCATGCGC'
|
Slide 14
About Spoken Tutorial Project
|
The video available at the following link summarizes the Spoken Tutorial project. Pls watch it. |
Slide 15
About Spoken Tutorial workshops
|
The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass an online test.
|
Slide 16
Acknowledgement
|
Spoken Tutorial ProjecThese 3 slides remain as before, on LaTeX. Only the narration will now be as given here.t is supported by the NMEICT, MHRD, Government of India.
More information on this Mission is available at this link. |
This script is contributed by Snehalatha and Trupti Kini.
And this is Trupti Kini from IIT Bombay signing off. Thanks for joining. |