Subject: | Suggested change to coverage_from_pileup_fun in Sam.xs |
Date: | Sat, 26 Feb 2011 13:08:26 -0800 |
To: | "bug-Bio-SamTools [...] rt.cpan.org" <bug-Bio-SamTools [...] rt.cpan.org> |
From: | Yi-Shiou Chen <Yi-Shiou.Chen [...] accelrys.com> |
Suggest to change coverage_from_pileup_fun in Sam.xs as below so that coverage will not count reads that actually skip the region.
int coverage_from_pileup_fun (uint32_t tid,
uint32_t pos,
int n,
const bam_pileup1_t *pl,
void *data) {
coverage_graph_ptr cgp;
int bin;
int toSkip;
int i;
const bam_pileup1_t* r;
cgp = (coverage_graph_ptr) data;
cgp->reads += n;
if (n > 0 && pos >= cgp->start && pos <= cgp->end) {
toSkip = 0;
for(i = 0; i < n; i++) {
r = pl + i;
if(r->is_refskip == 1 || r->is_del == 1)
toSkip++;
}
n-=toSkip;
bin = (pos-cgp->start)/cgp->width;
cgp->bin[bin] += n;
}
return 0;
}
This is a fix to bug #66138, which occurs when using the latest samtools release.
Thanks,
Yi-Shiou Chen
Accelrys