Thanks for visiting my blog - I have now moved to a new location at Nature Networks. Url: http://blogs.nature.com/fejes - Please come visit my blog there.

Wednesday, November 29, 2006

Whole Pictures and Python

  Yes, this is an unusual combination of topics, but it's not worth writing two separate posts for them. First, On the subject of seeing the 'whole picture', as I ranted on about the other day, I'd like to point out that - despite my criticism - I really don't know how to do this in my own respective field, let alone in other people's. Thus, my comments on Dr. Black's lecture are more a reflection of my own interest in breaking out of the "one gene - one thesis" picture, than a comment on Dr. Black's Research.

  I really believe there's a need for scientists, and particularly those dealing with biology, to look on from outside objectively and ask what it is they're contributing to the general pool of knowledge. However, that doesn't mean we should stop working on the focused projects that abound and that make up the vast majority of tractable projects in the field.

  Anyhow, with that said, I also wanted to jump over and mention Python. A couple of recent classes on the subject have been given here at the GSC, which have given me a very light feel for the language. At first, I figured it was just as wonky as perl, but after writing my very first Python script, I can see the beauty, elegance and flexibility of the language. With no further ado, let me unveil my first script for processing a large data flat file:


import os, sys, re

readfile = file('/home/afejes/Desktop/SNPanalysis.TUandREADS', "r")

Mutation= re.compile(r"[1-9]+[A-Z]+>>>[A-Z]\s\(\w+\)", re.VERBOSE)
Genename = re.compile (r"------>\sENSG", re.VERBOSE)

writefile = file('/home/afejes/Desktop/SNPanalysis.SNPS', "w")

for line in readfile:
if Genename.match(line):
Gene = line[8:23]
elif Mutation.match(line):
writefile.write(Gene + '\t' + line)
else:
pass

readfile.close()
writefile.close()

0 Comments:

Post a Comment

<< Home