All posts by anki

#4 Pandas

This session was about the beautiful data analysis library pandas.
We will add the IPython notebook as soon as possible.

Homework:
Read the 10 minutes introduction to pandas.

Ensure you got the following aspects of pandas:

  • Difference between DataFrames and Series
  • Load and write csv and excel files
  • Indexing DataFrames, accessing rows ( df.ix[0]) and columns ( df['Column']) and transpose them ( df.T)
  • Calculating mean, sum, std and sem
  • Using the  df.head() ,  df.tail()  and  df.describe() command
  • Plotting your data using  df.plot() , try to use different kinds, e.g.  df.plot(kind='bar')

Here’s Michael’s pandas Jupyter notebook and the munich climate file:
#4 Pandas

Organizing your oligos automatically

Ordering any random oligos is fairly fast. In my case, I order oligos @eurofins, and I ordered them in a couple of minutes. I normally decide on an arbitrary name (that makes at least sense in this second) and paste my sequence. At the same time, I am using ApE, a wonderful plasmid editor, and annotate the respective oligo sequence as a feature. This is kind of cumbersome, I don’t have a proper list of all my oligos and can hardly annotate for what reason I ordered that oligo. At the same time, I am working on several projects and would love to re-use oligos in one or the other way, so it would be wonderful having this “oligo list” as a feature file. So I was thinking of creating an automated workflow that catches every ordered oligo, parses all the meta data, stores it in a MySQL database and then creates every now and then an ApE feature libary. Here, I show you how I did it!

Continue reading Organizing your oligos automatically

Use Python to translate DNA to Protein

Hi there, this is a minimal code example to translate DNA to protein:

import re

# ACTB ORF (from http://www.ncbi.nlm.nih.gov/gene/60) as an example
dna = "ATGGATGATGATATCGCCGCGCTCGTCGTCGACAACGGCTCCGGCATGTGCAAGGCCGGCTTCGCGGGCGACGATGCCCCCCGGGCCGTCTTCCCCTCCATCGTGGGGCGCCCCAGGCACCAGGGCGTGATGGTGGGCATGGGTCAGAAGGATTCCTATGTGGGCGACGAGGCCCAGAGCAAGAGAGGCATCCTCACCCTGAAGTACCCCATCGAGCACGGCATCGTCACCAACTGGGACGACATGGAGAAAATCTGGCACCACACCTTCTACAATGAGCTGCGTGTGGCTCCCGAGGAGCACCCCGTGCTGCTGACCGAGGCCCCCCTGAACCCCAAGGCCAACCGCGAGAAGATGACCCAGATCATGTTTGAGACCTTCAACACCCCAGCCATGTACGTTGCTATCCAGGCTGTGCTATCCCTGTACGCCTCTGGCCGTACCACTGGCATCGTGATGGACTCCGGTGACGGGGTCACCCACACTGTGCCCATCTACGAGGGGTATGCCCTCCCCCATGCCATCCTGCGTCTGGACCTGGCTGGCCGGGACCTGACTGACTACCTCATGAAGATCCTCACCGAGCGCGGCTACAGCTTCACCACCACGGCCGAGCGGGAAATCGTGCGTGACATTAAGGAGAAGCTGTGCTACGTCGCCCTGGACTTCGAGCAAGAGATGGCCACGGCTGCTTCCAGCTCCTCCCTGGAGAAGAGCTACGAGCTGCCTGACGGCCAGGTCATCACCATTGGCAATGAGCGGTTCCGCTGCCCTGAGGCACTCTTCCAGCCTTCCTTCCTGGGCATGGAGTCCTGTGGCATCCACGAAACTACCTTCAACTCCATCATGAAGTGTGACGTGGACATCCGCAAAGACCTGTACGCCAACACAGTGCTGTCTGGCGGCACCACCATGTACCCTGGCATTGCCGACAGGATGCAGAAGGAGATCACTGCCCTGGCACCCAGCACAATGAAGATCAAGATCATTGCTCCTCCTGAGCGCAAGTACTCCGTGTGGATCGGCGGCTCCATCCTGGCCTCGCTGTCCACCTTCCAGCAGATGTGGATCAGCAAGCAGGAGTATGACGAGTCCGGCCCCTCCATCGTCCACCGCAAATGCTTCTAG"

bases = ['T', 'C', 'A', 'G'] # it may be U instead of T if you're translating RNA
codons = [a+b+c for a in bases for b in bases for c in bases]
aminoAcids = 'FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG'
codonTable = dict(zip(codons, aminoAcids))

codonPattern = re.compile("[TCAG]{3}")

translated = "".join([codonTable[x] for x in codonPattern.findall(dna)])

print(translated)

Enjoy 🙂

#1 Classes and Objects

Classes and Objects are an essential part in the programming paradigm called “object-oriented programming“.  Compared to “classical” procedural code – just like C – it is a form of code abstraction. It is mainly powerful when you’re working with a lot of instances (instance is at the same time a technical term) of the same kind. And luckily, we have this feature in Python as well.

Continue reading #1 Classes and Objects

Ligation Independent Cloning

The well established restriction enzyme cloning method, i.e. looking for a (unique) restriction site, cutting out a fragment and inserting another one with corresponding sites, ligate the two fragments and then transform it into bacteria, has a few limitations. First, having the correct restriction sites at the perfect place is not always happening. Second, some of your inserts or fragments carry that restriction site as well, all you will do is just chopping your insert into pieces. Fortunately, there’s another great option: Ligation-independent cloning. All you do is putting two fragments with some homology together, add some fancy proteins and voila, it’s done. Here, I will mention two great system: Gibson assembly and SLiCE.

Continue reading Ligation Independent Cloning