06 July 2010

BAM, javascript and some stuff

My project at Inserm UMR915 is now becoming larger. I stored all the mutations found with samtools in a relational database (the size of the data is ok, I'm just looking at the exome) and I re-used my XSLT stylesheet sql2java.xsl to generate a simple API to pull out the data. I can now use this library in conjunction with ${JAVA_HOME}/jrunscript (rhino) to quickly write a JS script: something as simple as:

importClass(Packages.fr.inserm.umr915.core.db.Database);

database=new Database();

var variations = database.variations;
var samples = database.samples;
for(i=0;i< variations.size();++i)
{
var variation=variations.get(i),
for(j=0;j< samples.size();++j)
{
var sample=samples.get(j),
println(variation.chrom+" "+variation.position+" "+sample.name+" "+ variation.getCalls(sample) );
}
}

database.close();
I also wrote a java web application to browse the results and a custom JSP Tag displaying the context of a BAM file at a given location. This tag (source code) uses the Picard Library (samtools for java) to read the Bam files. When this tag is invoked in a JSP file, it needs the path of the BAM file on the server and the segment (chromosome,start,end) to be printed.
<u:bam file="${bam.file}" chrom="${variation.chrom}" start="${variation.position-10}" end="${variation.position+10}" highlight="${variation.position}"/>
The custom tag will produce something like this:
------+---------+-----
C GCAGTTCGTACTATACC
CT CAGTTTGTACTATACC
CTC AGTTTGTACTATACC
CTC AGTTCGTACTATACC
CTCTT AGTTCGTACTATACC
CTCTTG GTTTGTACTATACC
CTCTTGC TTCGTACTATACC
TTCTGCAG TGTACTATACC
CTCTTGCA TTGTACTATACC
CTCTTGCA GTACTATACC
CTCTTGCAG GTACTATACC
CTCTTGAAG TACTATACC
CTCTTGCAG ACTATACC


That's it

Pierre

No comments: