How to create random DNA sequences with Python

Python’s random module makes it extremely easy to generate random DNA bases. Now to generate a specific number of random bases, all we have to do is use Python’s range function:

Read More
Some interesting talks from PyCon 2014

Here are several talks from PyCon 2014 I thought looked rather interesting from a research perspective:    

Read More
Explicit is better than implicit

Line two of the zen of Python reads “explicit is better than implicit” and until relatively recently I never truly appreciated the wisdom of those words. My change of heart stems from a series of Python scripts, where a large portion of my code dealt with automating and retrieving the results of a BLAST search using the …

Read More
BioPython Tutorial

This tutorial is a brief overview of what you can achieve using the Python BioPython module. Although I’m hoping to write up some more articles on this site for beginners when time permits, this post will assume that you have experience programming in Python and have a bit of an understanding of basic biological concepts …

Read More
Pyral Project

Pyral (Python + Viral) was the name of a project I worked on in Dr Joanne Macdonald’s lab between September 2012 – January 2013 (although I am still providing tech support for the code and helping manage the server to this date). Throughout this time I wrote a lot of Perl and Python code to run …

Read More
Python sys Module

The main use I’ve found for the Python sys module is allowing command-line arguments to be made to a script. Here is an example of how it looks: This script checks that 2 command-line arguments had been passed to the program before assigning the value sys.argv[1] to a variable. We check for two command-line arguments …

Read More
Python os Module

You can use the Python os module to send commands out to the operating system. Through os you can do anything from changing the current working directory through to listing the contents of a directory.

Read More
Parsing CSV Files in Python

Almost anyone doing research at some point will have to input or extract data from an Excel spreadsheet. However, it is possible to export an Excel file as a .csv file (comma separated file) and then use Python to grab all the data instantly. The Python csv module makes all this incredibly simple: This script …

Read More
Running an R script through Python

Before I made the switch to developing on a Linux machine, I noticed that the Python module for calling R (RPy2) seemed to be having some problems on Windows. This gave me an excuse to play around with writing my own Python script to create and run an R script. As you’ll see in the …

Read More