Tuesday, March 30, 2010

mpt2sas raid card from Dell r710 driver installation with Centos 5.3

The REDACTED at Dell don't support Centos 5.3 on r610s raid card (Dell H200). I seriously REDRACTED hate propriety drivers and it's going to be a constant nightmare as we change kernel versions, but whatever. The problem is basically that the drivers are signed for Redhat Enterprise and Centos doesn't like that. So you have to crack open the driver package and remove the signing. A fixed package is available here: i686 x86_64.

I robbed most of the instructions to do this from here:


Thursday, March 25, 2010

Replace all instance of string with an incrementing number

Perl solution with thanks to rmp. In this case replace all instances of MAGIC in the file small.sam:

cat small.sam | perl -pe 's/MAGIC/$c++/eg'

Sunday, March 21, 2010

Pausing/Suspending a running process

I had a couple of analysis jobs running they appeared to be stepping all over each other, with both jobs trashing a lot. I wanted to suspend one of the jobs to allow the other to continue in peace. You can do this using kill:

kill -STOP processid

and to continue it later:

kill -CONT processid

Found here:


Wednesday, March 17, 2010

Very simple OpenCL example

This blog post has been moved HERE


netcat one line webserver

Modified from the wikipedia article. Sets up a webserver on the local box (using only the netcat command) and serves a single file (called myfile) to all clients.

while true;do ( echo -e "HTTP/1.0 200 Ok\n\r"; cat myfile; ) | nc -l 8080 ;done

Wednesday, March 3, 2010

Samtools C example

A simple samtools C api example. This program reads the bam file provided in the first argument and dumps the contents:

#include <stdlib.h>
#include <stdio.h>

#include "bam.h"
#include "sam.h"

int main(int argc, char *argv[]) {

samfile_t *fp_in = NULL;
bam1_t *b=NULL;

fp_in = samopen(argv[1], "rb", 0);

if(NULL == fp_in) {
printf("Could not open file\n");

b = bam_init1();
int pos=0;
int lastpos=0;

while(samread(fp_in, b) > 0) {
lastpos = pos;
pos = b->core.pos;

if(pos != lastpos) {
printf("tid : %d\n",b->core.tid);
printf("pos : %d\n",b->core.pos);
char *name = bam1_qname(b);
char *qual = bam1_qual(b);

int n=0;
char *qseq = (char *) malloc(b->core.l_qseq+1);
char *s = bam1_seq(b);
for(n=0;n<(b->core.l_qseq);n++) {
char v = bam1_seqi(s,n);
qseq[n] = bam_nt16_rev_table[v];
qseq[n] = 0;

printf("name : %s\n",name);
printf("qseq : %s\n",qseq);
//printf("s cigar: %s\n",cigar);

printf("qual :");
for(n=0;n<(b->core.l_qseq);n++) {
printf(" %d",qual[n]);
b = bam_init1();

return 0;

Monday, March 1, 2010

Print contents of all files prefixing lines with filename

Print contents of all files (in this case all files starting with features.2d_table.* but not ending with png) prefixing the lines of the file with the filename:

find . -name "features.2d_table.*" | grep -v png | xargs awk '{print substr(FILENAME,3) " " $0}' > bigtable