Overview | Chapter 2: Python

Exercises: Python

Exercise 3.1. Writing a Python script: GC content

Make a script that calculates the GC content (fraction) of a user supplied DNA sequence.

Bonus: check if the input sequence is divisible by three, if not exit

Exercise 3.2. Writing a Python script: reverse complement

For a user inputted nucleotide sequence print the reverse complement.

Hints and tricks:

Exercise 3.3. Writing a Python script: molecular weight

This exercise is replicated from the book: Practical computing for biologists. For more information on Python programming, check: Haddock SHD, Dunn CS. Practical computing for biologists. Sunderland (Massachusetts U.S.A.): Sinauer Associates, Inc.; 2011.

Calculate the molecular weight of a given protein sequence. (hint: use a dictionary)

Dictionary molecular weight amino acids

Dictionary molecular weight amino acids

Exercise 3.4. BioPython: GC content

Calculate the GC content via BioPython.

Bonus: print the reverse complement

Exercise 3.5. BioPython: GC content and NCBI download

Adapt the GC content script to download a sequence directly from NCBI Entrez.

Find your favorite gene or use FMR1: NM_001185075.1 (http://www.ncbi.nlm.nih.gov/nuccore/NM_001185075.1)

Hints and tricks:

Exercise 3.6. BioPython: GC content, NCBI download and alignment of two sequences

Adapt the last script to download two sequences and align them using entrez.needle.

Hints and tricks:


Overview | Chapter 2: Python