I'll show here how to use java JNI to call the C methods developped by Jim Kent's team at UCSC to handle a BigWig file.
The Makefile for compiling the following sources is defined below:
Export the LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/path/to/current/directory
Download Jim Kent's sources from http://hgdownload.cse.ucsc.edu/admin/jksrc.zip. See the README file to compile jksrc/lib and jksrc/jkOwnLib.
The java source BigWig.java declares seven natives JNI methods. They will call the C methods for opening and closing the bigWig file, and getting the summaries in a given genomic range.
After compiling the java source, the following C header is generated with javah:
The C source implements the native methods defined in the java source. The code was inspired from ${JKENTSRC}/src/utils/bigWigSummary/bigWigSummary.c.
Download a bigwig file for a test: http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeMapability/wgEncodeCrgMapabilityAlign100mer.bigWig.
The main method in BigWig.java contains.a test:
java BigWig wgEncodeCrgMapabilityAlign100mer.bigWig
0.394749239542279
0.394749239542279
And here is the original output of the utility 'bigWigSummary':
bigWigSummary wgEncodeCrgMapabilityAlign100mer.bigWig -type=mean chr1 1 1000000 1
0.394749
0.394749
That's it,
Piere
No comments:
Post a Comment