Home > emacs, Genomic Selection, Linux, Misc, phasing, QTL-detection, SNP > It has to happen !

It has to happen !

You may have goals, that you haven’t reached yet , but you keep believing that one day you’ll achieve them, and… one day it finally happen . This has been the case for two of my secret goal !

As an unconditional emacs user, I knew that soon or later I would try to write my own emacs mode. I had the occasion to achieve this objective while testing a phasing program.

When comparing phased data, you generally want to align two phases and see on which SNP do you observe discrepancies. Nevertheless with thousands SNP, this looks like searching for a needle in a hay stack.  This can be done more efficiently with colored data. The idea is to just to associate a color to a list a character.

But as I am still a bit confused with lisp syntax, I just try to find some good example on the net.

And based on this write this piece of lisp code.

;;Define some attribute for each allele
 (setq myAllele
 '((" [1Aa]" . font-lock-function-name-face)
 (" [2Cc]" . font-lock-warning-face)
 (" [Gg]" . font-lock-constant-face)
 (" [Tt]" . font-lock-comment-face)
 (" [0\.]" . font-lock-builtin-face)
 ;;load this new attribute
 (define-derived-mode SNP-mode fundamental-mode
 (setq font-lock-defaults '(myAllele))
 (setq mode-name "SNP mode")
 (setq truncate-lines t)

All this code is in a file called SNP.el stored in my ~/.emacs.d/

  1. The first block of code define association between allele and font-lock attribute
  2. The second block define the mode and ask for line truncation

And in order to allow use this mode automatically, I add in my .emacs

load "~/.emacs.d/SNP.el")

To go one step forward, as I know that most of my genotype or phase file are named like “phase*” or “typ*”, I add also a hook i.e. these 2 lines

(setq auto-mode-alist
 (cons '("typ+[1-9]" . SNP-mode) auto-mode-alist)
 (cons '("typ+[1-9]" . SNP-mode) auto-mode-alist))

Now everytime I open a genotype file (stariting either by “typ” or “phase”, the SNP-mode is loaded and I thus obtain this kind of screen.

Now there no way I could miss something awesome in the genome !

For the laziest of you the SNP-mode is available here

And for those wondering what was my other achievement, you are certainly not aware of the bedrace World championship !

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: