Skip to main content

Posts

Showing posts from February, 2008

Visualisation of DNA

After some attention has been caought by the wonderfull Rainbow DNA project, I have decided to join the club! Here is a very simplistic, far more useless way of visualising DNA: turtle graphics. I really cannot put up a website with comlete renderings of the DNA using turtle graphics, but I uploaded two sample images to my flikr account. I wanted to find out if turtle graphics could reveal diffrent sets of patterns as those perceivable with a color plot of basepairs. Attached is source code so you can see what the program does. You can also reuse the part that proceses the contents of "gbk" files containing genome data. The code is just a hack done at night while I was waiting in a starbucks for a friend to pick me up, so if you think this code is a mess - you earned your degree, I was just curios after I found out about the rainbow dna project. Well the idea of the program is very simple: 1. Initialise the turtle to be in center of the screen 2. read the next basepair, for ...

Boyer Moore Search Algorithm

I needed to find a String in a text file, so I wrote(rather hacked) a scheme imlementation of the boyer moore string search algoritm. This is just a hack. But it is commented. What do you think? (I decided to use this blog also as my cut-paste-source from now on.) ;; searches for string using boyer moore algorithm (define (>>boyer-moore needle haystack) (define needle-len (string-length needle)) (define hs-len (string-length haystack)) (define r-needle-list (reverse (string->list needle))) ;; two tables are build ;; compute the bad character shift table ;; it contains the number of chars to skip, if a character is encountered that is not the last of the search string. ;; (this table is only used after the search cursor was replaced) (define bad-char-shift-table (let loop ((shift 0) (nlist r-needle-list) (table '())) (if (eq? nlist '()) table (if (assv (car nlist) table) (loop (+ 1 shift) (c...