25 July 2011

The samtools C API: creating a WIG file for the genome coverage

I wrote a tool which uses the samtools API to generate a WIG file for the genome coverage. This tool, bam2wig, as well as some other tools using this library are available in the following git repository:
My code is based on this original C source hosted on: http://samtools.sourceforge.net/sam-exam.shtml. (I hope I understood this API as many functions/structures remain undocumented).

Example

#compile
$ export SAMDIR=/path/to/samtools-0.1.17
$ cd amtools-utilities
$ make
#invoke bam2wig
$ .bin/bam2wig -t /path/to/my/sample.bam "chr1:120408225-120558920" | head
track name="__TRACK_NAME__" description="__TRACK_DESC__" type="wiggle_0"
fixedStep chrom=chr1 start=120408225 step=1 span=1
1
1
1
2
2
3
4
5

Result

The wig file uploaded as a custom track in the UCSC genome browser:


That's it

Pierre

No comments:

Post a Comment