Monthly Archives: October 2008

Python command line tricks for reverse primer design

If I were to list one of the most attractive things about python , the interactive command line would rank among the top few.

Well today I was forced with a rather simple task. I had to order a primer for a sub-cloning experiment that was the reverse primer corresponding to the last twenty bases of a given protein coding gene sequence.

Here is how python made the task super easy

1) First I opened the pubmed page with my sequence and copied the forward strand to my interactive python session

2) Then I wrote a couple of  lines to generate the reverse complement at the same time reversing the order of the string

>>> c={“A”:”T”,”T”:”A”,”G”:”C”,”C”:”G”}
>>> p=””
>>> for i in x :
…  p = c[i] + p

>>> p

So in the above example the

c = {“A”:”T”,”T”:”A”,”G”:”C”,”C”:”G”}

Is the reverse complement dictionary. The for loop replaces each nucleotide with its complement and simultaneously reverses the order , because every nucleotide is added to the begining ( i.e prepended) . So the last nucleotide ends up first.

The other way to do the same thing would be to use python string reversal as demonstrated in the code below

>>> c={“A”:”T”,”T”:”A”,”G”:”C”,”C”:”G”}
>>> for i in x :
…  p = p + c[i]

>>> p
>>> reverse_5prime_3prime = p[::-1]
>>> reverse_5prime_3prime

The cool part here is the funky and admittedly unreadable string-reversal syntax,

[python] reverse_5prime_3prime = p[::-1]

So In python string reversal is powerful. The p[::-1] basically says , give me the string from start to finish in backwards order (-1) . This elegant string reversal in python is explained well in this post and gives us the primer sequence in the correct 5-prime to 3-prime order as required by the oligo-synthesizing order forms.

The amazing chrome comic

First for some disclaimers: I  have not yet used chrome since I mostly use Linux and Mac OSX .

Although I believe that forking and straying from the beaten path are great things , my gut reaction to the chrome announcement was that it was definitely going to dull the impact of firefox which google had championned for many years and that this would fragment the developer community and further muddle the browser playing fields.   Kinda like Linux where sometime I wish that that we had fewer distros which may result in the surviving distributions being better than any of them are now. But all these feelings changed after I read the chrome comic.

The comic was brilliant. I read all 39 pages of it and it represents a significant enhancement in developer/end-user communication. The comic had the perfect blend of “selling chrome” to the developer and end-users. It did not dumb things down, that comics tend to do often , nor did it get too absorbed with the browser jargon.

Often product launches come in two flavors , lots of PR centric media hype with rather sorry documentation or the opposite kind where the API and documentation are extensive to the point that you immediately reach for the PR hype to make sense of it all. Neither of these were true in the chrome comic case.

In this world where we live in the browser , the attempts the chrome comic made to reach out to everyone are significant. Now if only other launches would take notes .