September 6th, 2006

Previous Entry Next Entry
07:16 pm - You will fall before my Screaming Eagle Fist technique
We had our first "real" project in the C++ class today, which was actually surprisingly cool considering how simplistic a first project needs to be. We had to write a small program to compare the contents of two chromosome sites, nucleotide by nucleotide, and give an overall "genetic distance" between those sites, based on the chart on the right.

Dr. Tang said we all ought to be able to get it done in less than 20 lines of code, but I'm pretty sure he was smoking crack. I mean don't get me wrong, I got it done in 14 - but only by noticing the fact that, if you treat each character as a byte-sized integer, adding any given nucleotide combination will give you a unique result: that is to say, A+G is not equal to A+A or A+C or A+T or C+G or C+T or G+T. Once you realize that, you can do the individual nucleotide comparisons with a single line of code: increment the value of a counter by the Boolean value of one lazy OR comparison plus the Boolean value of another lazy OR comparison multiplied by 5.
distance += ((n1+n2)==132 || (n1+n2)==138 || (n1+n2)==149 || (n1+n2)==155))*5 + ((n1+n2)==136 || (n1+n2)==151);
I seriously doubt he was expecting all - if any - of his students to take that approach. Regardless, I was pleased as hell with it, even though this is such a simple problem: after all, it's a very simple problem that's likely to need resolving on very large datasets, and my additive method is a pretty damn efficient way to do it.

It is sooooo nice to finally be taking a class that teaches a language I actually want to learn. =)

Current Mood: gleeful
Current Music: Big Country - In A Big Country

(5 comments | Leave a comment)


[User Picture] From: goldfischegirl
Date: September 6th, 2006 - 11:17 pm
i am severely pissy and feel like crying today
come make me feel better

[User Picture] From: goldfischegirl
Date: September 6th, 2006 - 11:20 pm
oh but i'm avoiding aim so this is gonna be hard, shit.

[User Picture] From: jimbojones
Date: September 6th, 2006 - 11:31 pm
Yes, that makes it VERRAH DIFFICULT.

You could always log on to AIM in Romulan Invisible mode?

[User Picture] From: discogravy
Date: September 7th, 2006 - 03:30 am
what, no phones in deepest darkest bible-belt america?

[User Picture] From: lindapendant
Date: September 7th, 2006 - 11:34 am
*blink blink*

> Go to Top